Commit 07a33c68 authored by Hafiyyan Sayyid Fadhlillah's avatar Hafiyyan Sayyid Fadhlillah

Merge branch 'Task-0-0-integration' into 'master'

[Task-0-0] Integration

See merge request !28
parents a912c88e 923ce6c3
Pipeline #172653017 passed with stage
in 3 minutes and 21 seconds
......@@ -74,7 +74,8 @@ export default function ItemDisplay({
</Button>)
const headerTitle = typeof title === 'string' ? <h3 className={classes.headerTitle}>{title}</h3> : title
const showHeader = isNil(title) && !showDeleteButton && !showEditButton
const hideHeader = isNil(headerTitle) && !showDeleteButton && !showEditButton
const showHeader = !hideHeader
return (
<div>
......
......@@ -154,12 +154,6 @@ export default function VendorListItemCreateUpdate({
defaultValue={formData.address}
/>
<TextField {...settings}
label="Address 2"
id="address2"
defaultValue={formData.address2}
/>
<TextField {...settings}
label="Address 2 (Optional)"
id="address2"
......
import {devPort} from './allocatedPortConstants'
export const API_LOGIN_URL = devPort+'/api/authentication/login.abs';
\ No newline at end of file
export const API_LOGIN_URL = devPort+'/apigraph/graphql-mutation-auth';
\ No newline at end of file
......@@ -46,6 +46,7 @@ const LoginPage = () => {
if (e.message === "AUTHENTICATION_FAILED") {
setErrorCode(ERR_AUTH_FAILED)
} else {
console.error(e)
setErrorCode(ERR_UNKNOWN)
}
setLoading(false)
......
import { API_LOGIN_URL } from 'constants/apiConstants';
import { ROUTE_HOMEPAGE } from 'constants/routeConstants';
import { MULTIPART_FORM_HEADER } from 'constants/httpRequestConstants';
import history from 'app-history';
import axios from 'axios';
import { axios, setToken } from 'services/constants';
import { fetchAccessToken, fetchAccessTokenSuccess } from 'state/user/userActions';
import { forEach } from 'lodash';
export const performLogin = async (username, password, dispatch) => {
const getData = { 'username': username, 'password': password };
dispatch(fetchAccessToken(dispatch));
const res = await axios.post(API_LOGIN_URL,{
query: `
mutation {
login(name: "${username}", password: "${password}") {
accessToken,
refreshToken
}
}`
});
const formBodyData = new FormData();
forEach(getData, (val, key) => {
formBodyData.append(key, val);
});
const res = await axios.post(API_LOGIN_URL, formBodyData, MULTIPART_FORM_HEADER);
const accessToken = res.data.data;
if (!accessToken) {
throw new Error("AUTHENTICATION_FAILED");
try{
const accessToken = res.data.data.login.accessToken
setToken(accessToken)
localStorage.setItem("accessToken", accessToken)
await dispatch(fetchAccessTokenSuccess(accessToken, dispatch));
history.push(ROUTE_HOMEPAGE);
} catch (e) {
throw new Error("AUTHENTICATION_FAILED");
}
await dispatch(fetchAccessTokenSuccess(accessToken, dispatch));
localStorage.setItem("accessToken", accessToken)
history.push(ROUTE_HOMEPAGE);
};
\ No newline at end of file
import axios from 'axios';
import { axios } from './constants';
import { ENDPOINT } from './constants'
import { dictToStringParam, handleSilentApiError } from './utils';
......
import axios from 'axios';
import { axios } from './constants';
import cloneDeep from 'lodash/cloneDeep';
import { ENDPOINT } from './constants'
......
import axios from 'axios';
import { axios } from './constants';
import { ENDPOINT } from './constants'
import { dictToStringParam, handleSilentApiError } from './utils'
......@@ -69,7 +69,7 @@ export default class ApiMasterDataMaterial {
query: `
mutation {
deleteMaterialImpl(idMaterial: ${idMaterial}) {
material {
materialImpl {
idMaterial
}
}
......@@ -90,7 +90,7 @@ export default class ApiMasterDataMaterial {
query: `
mutation {
updateMaterialImpl (${payloadAsParam}) {
material {
materialImpl {
${ITEM_DETAIL_QUERY}
}
}
......
import axios from 'axios';
import { axios } from './constants';
import { ENDPOINT } from './constants'
import { dictToStringParam, handleSilentApiError } from './utils'
......
import axios from 'axios';
import { axios } from './constants';
import { ENDPOINT } from './constants'
import { dictToStringParam, handleSilentApiError } from './utils'
......@@ -63,7 +63,7 @@ export default class ApiMasterDataProcess {
query: `
mutation {
deleteProcessImpl(idProcess: ${idProcess}) {
process {
processImpl {
idProcess
}
}
......@@ -84,7 +84,7 @@ export default class ApiMasterDataProcess {
query: `
mutation {
updateProcessImpl (${payloadAsParam}) {
process {
processImpl {
${ITEM_DETAIL_QUERY}
}
}
......
import axios from 'axios';
import { axios } from './constants';
import { ENDPOINT } from './constants'
import { dictToStringParam, handleSilentApiError } from './utils'
......
import axios from 'axios';
import { axios } from './constants';
import { ENDPOINT } from './constants'
import { dictToStringParam, handleSilentApiError } from './utils'
......
import axios from 'axios';
import { axios } from './constants';
import { ENDPOINT } from './constants'
import { dictToStringParam, handleSilentApiError } from './utils'
......
import environment from '../utils/environment';
import axiosOri from 'axios'
export const ENDPOINT = {
QUERY: `${environment.rootApi}/graphql-query`,
DELETE: `${environment.rootApi}/graphql-mutation-delete`,
CREATE: `${environment.rootApi}/graphql-mutation-create`,
UPDATE: `${environment.rootApi}/graphql-mutation-update`,
}
// Create axios instance
export const axios = axiosOri.create()
export const setToken = (accessToken) => {
axios.defaults.headers.common['Authorization'] = `Bearer ${accessToken}`
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment