Browse Source

update Url and resolve conflict

pull/2/head
root 12 months ago
parent
commit
9095390b53
  1. 1081
      src/views/Dashboard/DashboardProjectCarousell.js
  2. 1
      src/views/Master/MasterRoles/DialogForm.js
  3. 61
      src/views/Master/MasterRoles/index.js
  4. 40
      src/views/Master/ProjectPhase/index.js
  5. 18
      src/views/Master/RoleProject/index.js
  6. 10
      src/views/Pages/Login/Login.js
  7. 35
      src/views/SimproV2/Divisi/index.js
  8. 6
      src/views/SimproV2/Gantt/index.js
  9. 42
      src/views/SimproV2/ProjectType/index.js
  10. 43
      src/views/SimproV2/ResourceWorker/index.js
  11. 36
      src/views/SimproV2/Satuan/index.js

1081
src/views/Dashboard/DashboardProjectCarousell.js

File diff suppressed because it is too large Load Diff

1
src/views/Master/MasterRoles/DialogForm.js

@ -37,7 +37,6 @@ class DialogForm extends Component {
this.props.showDialog(this.showDialog); this.props.showDialog(this.showDialog);
this.getAllMenu(); this.getAllMenu();
} }
async componentDidUpdate() { async componentDidUpdate() {
if (this.state.isParentClick === true) { if (this.state.isParentClick === true) {
if (this.props.typeDialog === "Edit") { if (this.props.typeDialog === "Edit") {

61
src/views/Master/MasterRoles/index.js

@ -11,28 +11,33 @@ import { Pagination, Tooltip, Table } from 'antd';
import { ROLE_ADD, ROLE_SEARCH, ROLE_EDIT, ROLE_DELETE, ROLEMENU_ADD, ROLEMENU_SEARCH, ROLEMENU_DELETE_ROLE } from '../../../const/ApiConst.js'; import { ROLE_ADD, ROLE_SEARCH, ROLE_EDIT, ROLE_DELETE, ROLEMENU_ADD, ROLEMENU_SEARCH, ROLEMENU_DELETE_ROLE } from '../../../const/ApiConst.js';
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const company_id = window.localStorage.getItem('company_id');
const role_name = window.localStorage.getItem('role_name');
const BASE_URL = "http://siopas.co.id/custom-php/api/geohr/";
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const momentFormat = 'HH:mm';
const LENGTH_DATA = 10 const LENGTH_DATA = 10
class index extends Component { class index extends Component {
constructor(props) { constructor(props) {
let role_id = '', user_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
company_id = props.location.state.company_id;
role_name = props.location.state.role_name;
} else {
token = window.localStorage.getItem('token');
role_name = window.localStorage.getItem('role_name');
company_id = window.localStorage.getItem('company_id');
}
super(props) super(props)
this.config = {
headers: {
Authorization: `Bearer ${token}`,
"Content-type": "application/json"
}
};
this.state = { this.state = {
alertDelete: false, alertDelete: false,
alertNotDelete: false, alertNotDelete: false,
@ -58,9 +63,9 @@ class index extends Component {
tooltipTambah: false, tooltipTambah: false,
totalPage: 0, totalPage: 0,
typeDialog: 'Save', typeDialog: 'Save',
company_id: company_id company_id: company_id,
role_name: role_name
} }
this.columns = [ this.columns = [
{ {
title: this.props.t('action'), title: this.props.t('action'),
@ -117,7 +122,7 @@ class index extends Component {
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
if (role_name !== "Super Admin") { if (this.state.role_name !== "Super Admin") {
formData.columns.push( formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" },
) )
@ -127,7 +132,7 @@ class index extends Component {
) )
} }
const result = await axios const result = await axios
.post(ROLE_SEARCH, formData, config) .post(ROLE_SEARCH, formData, this.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -172,7 +177,7 @@ class index extends Component {
const { idDelete } = this.state const { idDelete } = this.state
const url = ROLE_DELETE(idDelete) const url = ROLE_DELETE(idDelete)
const result = await axios.delete(url, config) const result = await axios.delete(url, this.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -193,10 +198,10 @@ class index extends Component {
name: data.name, name: data.name,
description: data.description, description: data.description,
default_page: data.selectedMenu, default_page: data.selectedMenu,
company_id: company_id company_id: this.company_id
} }
const result = await axios.post(ROLE_ADD, formData, config) const result = await axios.post(ROLE_ADD, formData, this.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -216,7 +221,7 @@ class index extends Component {
default_page: data.selectedMenu default_page: data.selectedMenu
} }
const url = ROLE_EDIT(data.id) const url = ROLE_EDIT(data.id)
const result = await axios.put(url, formData, config) const result = await axios.put(url, formData, this.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -285,7 +290,7 @@ class index extends Component {
} }
const result = await axios const result = await axios
.post(ROLEMENU_SEARCH, formData, config) .post(ROLEMENU_SEARCH, formData, this.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
@ -309,7 +314,7 @@ class index extends Component {
menu_id: val.menu_id, menu_id: val.menu_id,
role_id: val.roles_id role_id: val.roles_id
} }
promises.push(axios.post(ROLEMENU_ADD, formData, config) promises.push(axios.post(ROLEMENU_ADD, formData, this.config)
.then(res => result.push(res))) .then(res => result.push(res)))
} }
}) })
@ -329,7 +334,7 @@ class index extends Component {
deleteCurrentRoleMenu = async (id) => { deleteCurrentRoleMenu = async (id) => {
let urlDel = ROLEMENU_DELETE_ROLE(id) let urlDel = ROLEMENU_DELETE_ROLE(id)
const result = await axios.delete(urlDel, config) const result = await axios.delete(urlDel, this.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code === 200) { if (result && result.data && result.data.code === 200) {
@ -352,7 +357,7 @@ class index extends Component {
} }
const result = await axios const result = await axios
.post(ROLE_SEARCH, formData, config) .post(ROLE_SEARCH, formData, this.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);

40
src/views/Master/ProjectPhase/index.js

@ -9,27 +9,27 @@ import { NotificationContainer, NotificationManager } from 'react-notifications'
import { PROJECT_PHASE_ADD, PROJECT_PHASE_EDIT, PROJECT_PHASE_DELETE, PROJECT_PHASE_SEARCH, PROJECT_PHASE_LIST, BASE_OSPRO } from '../../../const/ApiConst'; import { PROJECT_PHASE_ADD, PROJECT_PHASE_EDIT, PROJECT_PHASE_DELETE, PROJECT_PHASE_SEARCH, PROJECT_PHASE_LIST, BASE_OSPRO } from '../../../const/ApiConst';
import { Pagination, Button, Tooltip, Table } from 'antd'; import { Pagination, Button, Tooltip, Table } from 'antd';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const company_id = window.localStorage.getItem('company_id');
const role_name = window.localStorage.getItem('role_name'); const ProjectPhase = ({ params, ...props }) => {
const config = { let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
headers: if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
{ role_id = props.location.state.role_id;
Authorization: `Bearer ${token}`, user_id = props.location.state.user_id;
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", token = props.location.state.token;
isLogin = props.location.state.isLogin;
role_name = props.location.state.role_name;
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
} }
};
const ProjectPhase = ({ params }) => { console.log('company_id', company_id);
const token = localStorage.getItem("token")
const company_id = localStorage.getItem("company_id")
/*const HEADER = {
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Access-Control-Allow-Origin": "*",
"Authorization": `Bearer ${token}`
}
}*/
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -257,7 +257,7 @@ const ProjectPhase = ({ params }) => {
const onConfirmDelete = async () => { const onConfirmDelete = async () => {
let url = PROJECT_PHASE_DELETE(idDelete); let url = PROJECT_PHASE_DELETE(idDelete);
const result = await axios.delete(url, config) const result = await axios.delete(url, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);

18
src/views/Master/RoleProject/index.js

@ -35,6 +35,19 @@ const LENGTH_DATA = 10
class index extends Component { class index extends Component {
constructor(props) { constructor(props) {
let role_id = '', user_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
company_id = props.location.state.company_id;
role_name = props.location.state.role_name;
} else {
token = window.localStorage.getItem('token');
role_name = window.localStorage.getItem('role_name');
company_id = window.localStorage.getItem('company_id');
}
super(props) super(props)
this.state = { this.state = {
alertDelete: false, alertDelete: false,
@ -61,7 +74,8 @@ class index extends Component {
tooltipTambah: false, tooltipTambah: false,
totalPage: 0, totalPage: 0,
typeDialog: 'Save', typeDialog: 'Save',
company_id company_id: company_id,
role_name: role_name
} }
this.columns = [ this.columns = [
{ {
@ -115,7 +129,7 @@ class index extends Component {
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
if (role_name !== "Super Admin") { if (this.state.role_name !== "Super Admin") {
formData.columns.push( formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" },
) )

10
src/views/Pages/Login/Login.js

@ -133,7 +133,7 @@ class Login extends Component {
} }
} }
getDataMenu = async (token, role_id, user_id) => { getDataMenu = async (token, role_id, user_id, company_id, role_name) => {
const config = { const config = {
headers: headers:
{ {
@ -159,14 +159,14 @@ class Login extends Component {
else { else {
this.props.history.push({ this.props.history.push({
pathname: "/dashboard", pathname: "/dashboard",
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true } state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name }
}); });
} }
if (this.state.defaultPage) { if (this.state.defaultPage) {
if (role_id === 44) { if (role_id === 44) {
this.props.history.push({ this.props.history.push({
pathname: this.state.defaultPage, pathname: this.state.defaultPage,
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true } state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name }
}); });
} else { } else {
this.props.history.push(this.state.defaultPage); this.props.history.push(this.state.defaultPage);
@ -177,7 +177,7 @@ class Login extends Component {
else { else {
this.props.history.push({ this.props.history.push({
pathname: "/dashboard", pathname: "/dashboard",
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true } state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name }
}); });
} }
} else { } else {
@ -222,7 +222,7 @@ class Login extends Component {
if (doLogin && doLogin.data && doLogin.data.code === 200) { if (doLogin && doLogin.data && doLogin.data.code === 200) {
const { access_token, data_user } = doLogin.data.data const { access_token, data_user } = doLogin.data.data
this.getDataRole(access_token, data_user.role_id) this.getDataRole(access_token, data_user.role_id)
this.getDataMenu(access_token, data_user.role_id, data_user.id) this.getDataMenu(access_token, data_user.role_id, data_user.id, data_user.company_id, data_user.role.name)
window.localStorage.setItem('isLogin', true); window.localStorage.setItem('isLogin', true);
window.localStorage.setItem('token', access_token); window.localStorage.setItem('token', access_token);
window.localStorage.setItem('user_id', data_user.id); window.localStorage.setItem('user_id', data_user.id);

35
src/views/SimproV2/Divisi/index.js

@ -9,20 +9,6 @@ import { NotificationContainer, NotificationManager } from 'react-notifications'
import { Pagination, Button, Tooltip } from 'antd'; import { Pagination, Button, Tooltip } from 'antd';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
const role_id = localStorage.getItem('role_id');
const company_id = localStorage.getItem("company_id")
const role_name = window.localStorage.getItem('role_name');
const format = "DD-MM-YYYY";
const token = window.localStorage.getItem('token');
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const column = [ const column = [
{ name: "Nama" }, { name: "Nama" },
@ -30,8 +16,23 @@ const column = [
{ name: "Color" }, { name: "Color" },
] ]
const ProjectType = ({ params }) => { const ProjectType = ({ params, ...props }) => {
const token = localStorage.getItem("token") let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
role_name = props.location.state.role_name;
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
}
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -256,7 +257,7 @@ const ProjectType = ({ params }) => {
const onConfirmDelete = async () => { const onConfirmDelete = async () => {
let url = DIVISI_DELETE(idDelete); let url = DIVISI_DELETE(idDelete);
const result = await axios.delete(url, config) const result = await axios.delete(url, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);

6
src/views/SimproV2/Gantt/index.js

@ -15,7 +15,7 @@ import GanttFrame from "./GanttFrame";
let roCount = 0; let roCount = 0;
const Gantt = (props) => { const Gantt = (props) => {
let role_id = '', userId='',isLogin='',token=''; let role_id = '', userId = '', isLogin = '', token = '';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) { if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id; role_id = props.location.state.role_id;
userId = props.location.state.user_id; userId = props.location.state.user_id;
@ -56,7 +56,7 @@ const Gantt = (props) => {
cekPermission(); cekPermission();
}, [listUserGant]); }, [listUserGant]);
useEffect(() => {}, [ro]); useEffect(() => { }, [ro]);
const getDataUserGantt = async () => { const getDataUserGantt = async () => {
const payload = { const payload = {
@ -94,7 +94,7 @@ const Gantt = (props) => {
}; };
const cekPermission = () => { const cekPermission = () => {
let check = listUserGant.includes(userId); let check = listUserGant.includes(parseInt(userId));
if (check) { if (check) {
setRo(0); setRo(0);
} else { } else {

42
src/views/SimproV2/ProjectType/index.js

@ -11,28 +11,24 @@ import { NotificationContainer, NotificationManager } from 'react-notifications'
import { PROJECT_TYPE_ADD, PROJECT_TYPE_EDIT, PROJECT_TYPE_DELETE, PROJECT_TYPE_SEARCH } from '../../../const/ApiConst'; import { PROJECT_TYPE_ADD, PROJECT_TYPE_EDIT, PROJECT_TYPE_DELETE, PROJECT_TYPE_SEARCH } from '../../../const/ApiConst';
import { Pagination, Button, Tooltip, Table } from 'antd'; import { Pagination, Button, Tooltip, Table } from 'antd';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
const role_id = localStorage.getItem('role_id');
const format = "DD-MM-YYYY";
const token = window.localStorage.getItem('token');
const company_id = window.localStorage.getItem('company_id');
const role_name = window.localStorage.getItem('role_name');
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const column = [
{ name: "Nama" },
{ name: "Deskripsi" },
]
const ProjectType = ({ params }) => { const ProjectType = ({ params, ...props }) => {
const token = localStorage.getItem("token") let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
role_name = props.location.state.role_name;
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
}
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -106,7 +102,7 @@ const ProjectType = ({ params }) => {
) )
} }
const result = await axios const result = await axios
.post(PROJECT_TYPE_SEARCH, payload, config, HEADER) .post(PROJECT_TYPE_SEARCH, payload, HEADER, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -263,7 +259,7 @@ const ProjectType = ({ params }) => {
const onConfirmDelete = async () => { const onConfirmDelete = async () => {
let url = PROJECT_TYPE_DELETE(idDelete); let url = PROJECT_TYPE_DELETE(idDelete);
const result = await axios.delete(url, config) const result = await axios.delete(url, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);

43
src/views/SimproV2/ResourceWorker/index.js

@ -13,24 +13,25 @@ import {
PROYEK_SEARCH, USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, USER_SHIFT_ADD, USER_SYNC PROYEK_SEARCH, USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, USER_SHIFT_ADD, USER_SYNC
} from '../../../const/ApiConst'; } from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const url = "";
const proyek_id = localStorage.getItem('proyek_id'); const ResourceWorker = ({ params, ...props }) => {
const role_id = localStorage.getItem('role_id'); let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
const format = "DD-MM-YYYY"; if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
const token = window.localStorage.getItem('token'); role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
const config = { token = props.location.state.token;
headers: isLogin = props.location.state.isLogin;
{ role_name = props.location.state.role_name;
Authorization: `Bearer ${token}`, } else {
"Content-type": `application/json` role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
} }
};
const role_name = window.localStorage.getItem('role_name');
const company_id = window.localStorage.getItem('company_id');
const ResourceWorker = ({ params }) => {
const token = localStorage.getItem("token")
const company_id = localStorage.getItem("company_id")
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -90,7 +91,7 @@ const ResourceWorker = ({ params }) => {
} }
const result = await axios const result = await axios
.post(ROLE_SEARCH, formData, config) .post(ROLE_SEARCH, formData, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -106,7 +107,7 @@ const ResourceWorker = ({ params }) => {
} }
const result = await axios const result = await axios
.post(DIVISI_SEARCH, formData, config) .post(DIVISI_SEARCH, formData, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -215,7 +216,7 @@ const ResourceWorker = ({ params }) => {
} }
const result = await axios const result = await axios
.post(USER_SEARCH, payload, config) .post(USER_SEARCH, payload, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -468,7 +469,7 @@ const ResourceWorker = ({ params }) => {
const onConfirmDelete = async () => { const onConfirmDelete = async () => {
let url = USER_DELETE(idDelete); let url = USER_DELETE(idDelete);
const result = await axios.delete(url, config) const result = await axios.delete(url, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);

36
src/views/SimproV2/Satuan/index.js

@ -9,20 +9,24 @@ import { Pagination, Button, Tooltip } from 'antd';
import { SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE, SATUAN_SEARCH } from '../../../const/ApiConst'; import { SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE, SATUAN_SEARCH } from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const company_id = window.localStorage.getItem('company_id');
const role_name = window.localStorage.getItem('role_name');
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const Satuan = ({ params }) => { const Satuan = ({ params, ...props }) => {
const token = localStorage.getItem("token") let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
const company_id = localStorage.getItem("company_id") if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
role_name = props.location.state.role_name;
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
}
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -101,7 +105,7 @@ const Satuan = ({ params }) => {
const result = await axios const result = await axios
.post(SATUAN_SEARCH, payload, config) .post(SATUAN_SEARCH, payload, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
@ -132,7 +136,7 @@ const Satuan = ({ params }) => {
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
const result = await axios const result = await axios
.post(SATUAN_SEARCH, payload, config) .post(SATUAN_SEARCH, payload, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
@ -218,7 +222,7 @@ const Satuan = ({ params }) => {
const onConfirmDelete = async () => { const onConfirmDelete = async () => {
let url = SATUAN_DELETE(idDelete); let url = SATUAN_DELETE(idDelete);
const result = await axios.delete(url, config) const result = await axios.delete(url, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);

Loading…
Cancel
Save