From bc9b855b7500170a00fb4808df553169e8babcfe Mon Sep 17 00:00:00 2001 From: root Date: Tue, 21 Nov 2023 14:56:07 +0700 Subject: [PATCH 1/3] save update from server --- .../CreatedProyek/.DialogHierarchy.js.swp | Bin 0 -> 16384 bytes .../SimproV2/CreatedProyek/DialogHierarchy.js | 2 +- .../CreatedProyek/ImportActivity/index.js | 14 +++++++------- src/views/SimproV2/CreatedProyek/index.js | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 src/views/SimproV2/CreatedProyek/.DialogHierarchy.js.swp diff --git a/src/views/SimproV2/CreatedProyek/.DialogHierarchy.js.swp b/src/views/SimproV2/CreatedProyek/.DialogHierarchy.js.swp new file mode 100644 index 0000000000000000000000000000000000000000..426e022212eed132edc77a6f21437bfbeb612060 GIT binary patch literal 16384 zcmeI3Ta08y8OP7UdVv+?qVWl=Z7$t|J>9dbZpd!;;LOe}(`Ij(ncYPv>r73b>gmIt zKBsd|^;~Gi1!IC5^??VF;Db+S;w38h01tqX$b&{Cga-m4K4C-+L6I1P;=eBERGl+D z%U~ov&>em|-Bn*zef52H{mx-|>~!N8xv8?x!RKs9$Y{LCm9GlY3!MZSv7p6b76HZZ(dY)m4wJ#nm~l zgA%9rR}V*wa^{|l!VPw=I^|J6T$%AuP1I~}RBnrRq{L8YXo2^l1$w+Sdedd6KDB?} znCSksg}vmeD^I-_Eivr#&;mmX3@tFUz|aCi3k)qVw7}2;?^z4*?#0e|^!_4k0j~e< z%Kd#yf0BSe@;8zDx6WVH?I?gp{_fio6!1Mp){{Q4h9OrJZ3@YFX@cM@x=W+09a1r>)WsY+moCKc$ zZ+ysceg*CY9dH~R0MGAnoF9O1gRg-_Z~%;fGWaC81iWym<2(p@;AXH3{NfVF*#P^% zKR)O4um%>u888Aq z241_^ah?OufZu^1gCBwW!8+g|2A=~5z%^hO_!s>3CU_n^3VseA2HyY+;0!noMu70` zKa)U>8DnJY$7_*N%qj21q+Tb5xYum5I4+EkzC(z7Rf9DBFlO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E!J3{oYXPdQ~QzohyM@Cyd=J5lI@j?~X7%rg@aw;c2crB42*&rq=M$6P_?R65G!VlgU2gNFyo9V5 { if (!openDialog) { diff --git a/src/views/SimproV2/CreatedProyek/ImportActivity/index.js b/src/views/SimproV2/CreatedProyek/ImportActivity/index.js index 4e20276..2e9212d 100644 --- a/src/views/SimproV2/CreatedProyek/ImportActivity/index.js +++ b/src/views/SimproV2/CreatedProyek/ImportActivity/index.js @@ -9,13 +9,13 @@ import './table.css'; import { BASE_OSPRO, ASSIGN_HR_PROJECT_SEARCH } from '../../../../const/ApiConst'; import { Prompt } from 'react-router-dom'; // -const config = { - headers: - { - Authorization: `Bearer ${token}`, - "Content-type": `application/json` - } -}; +//const config = { +// headers: +// { +// Authorization: `Bearer ${token}`, +// "Content-type": `application/json` +// } +//}; //const token = window.localStorage.getItem('token'); const token = localStorage.getItem("token"); const HEADER = { diff --git a/src/views/SimproV2/CreatedProyek/index.js b/src/views/SimproV2/CreatedProyek/index.js index f331f84..f2942ce 100644 --- a/src/views/SimproV2/CreatedProyek/index.js +++ b/src/views/SimproV2/CreatedProyek/index.js @@ -304,7 +304,7 @@ const CreatedProyek = ({ params, ...props }) => { const getDataProyek = async () => { let start = 0; let hierarchy = []; - hierarchy.push(JSON.parse(localStorage.getItem("hierarchy"))); + //hierarchy.push(JSON.parse(localStorage.getItem("hierarchy"))); if (currentPage !== 1 && currentPage > 1) { start = currentPage * rowsPerPage - rowsPerPage; } From ec2b0224e41cb4cfb440500fb08eddb02568a6ba Mon Sep 17 00:00:00 2001 From: farhantock Date: Wed, 22 Nov 2023 16:25:36 +0700 Subject: [PATCH 2/3] update condition by company_id or super admin --- src/views/Master/MasterRoles/DialogForm.js | 1 - src/views/Master/MasterRoles/index.js | 61 ++++++++++++---------- src/views/Master/ProjectPhase/index.js | 40 +++++++------- src/views/Master/RoleProject/index.js | 18 ++++++- src/views/Pages/Login/Login.js | 10 ++-- src/views/SimproV2/Divisi/index.js | 35 +++++++------ src/views/SimproV2/Gantt/index.js | 6 +-- src/views/SimproV2/ProjectType/index.js | 42 +++++++-------- src/views/SimproV2/ResourceWorker/index.js | 43 +++++++-------- src/views/SimproV2/Satuan/index.js | 36 +++++++------ 10 files changed, 156 insertions(+), 136 deletions(-) diff --git a/src/views/Master/MasterRoles/DialogForm.js b/src/views/Master/MasterRoles/DialogForm.js index 4bc3ab1..fab37b4 100644 --- a/src/views/Master/MasterRoles/DialogForm.js +++ b/src/views/Master/MasterRoles/DialogForm.js @@ -37,7 +37,6 @@ class DialogForm extends Component { this.props.showDialog(this.showDialog); this.getAllMenu(); } - async componentDidUpdate() { if (this.state.isParentClick === true) { if (this.props.typeDialog === "Edit") { diff --git a/src/views/Master/MasterRoles/index.js b/src/views/Master/MasterRoles/index.js index af94704..243519f 100644 --- a/src/views/Master/MasterRoles/index.js +++ b/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 { 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 class index extends Component { 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) + this.config = { + headers: { + Authorization: `Bearer ${token}`, + "Content-type": "application/json" + } + }; this.state = { alertDelete: false, alertNotDelete: false, @@ -58,9 +63,9 @@ class index extends Component { tooltipTambah: false, totalPage: 0, typeDialog: 'Save', - company_id: company_id + company_id: company_id, + role_name: role_name } - this.columns = [ { title: this.props.t('action'), @@ -117,7 +122,7 @@ class index extends Component { "joins": [], "orders": { "columns": ["id"], "ascending": false } } - if (role_name !== "Super Admin") { + if (this.state.role_name !== "Super Admin") { formData.columns.push( { "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" }, ) @@ -127,7 +132,7 @@ class index extends Component { ) } const result = await axios - .post(ROLE_SEARCH, formData, config) + .post(ROLE_SEARCH, formData, this.config) .then(res => res) .catch((error) => error.response); @@ -172,7 +177,7 @@ class index extends Component { const { idDelete } = this.state const url = ROLE_DELETE(idDelete) - const result = await axios.delete(url, config) + const result = await axios.delete(url, this.config) .then(res => res) .catch((error) => error.response); @@ -193,10 +198,10 @@ class index extends Component { name: data.name, description: data.description, 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) .catch((error) => error.response); @@ -216,7 +221,7 @@ class index extends Component { default_page: data.selectedMenu } 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) .catch((error) => error.response); @@ -285,7 +290,7 @@ class index extends Component { } const result = await axios - .post(ROLEMENU_SEARCH, formData, config) + .post(ROLEMENU_SEARCH, formData, this.config) .then(res => res) .catch((error) => error.response); if (result && result.data && result.data.code == 200) { @@ -309,7 +314,7 @@ class index extends Component { menu_id: val.menu_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))) } }) @@ -329,7 +334,7 @@ class index extends Component { deleteCurrentRoleMenu = async (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) .catch((error) => error.response); if (result && result.data && result.data.code === 200) { @@ -352,7 +357,7 @@ class index extends Component { } const result = await axios - .post(ROLE_SEARCH, formData, config) + .post(ROLE_SEARCH, formData, this.config) .then(res => res) .catch((error) => error.response); diff --git a/src/views/Master/ProjectPhase/index.js b/src/views/Master/ProjectPhase/index.js index 56a3821..8d80b93 100644 --- a/src/views/Master/ProjectPhase/index.js +++ b/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 { Pagination, Button, Tooltip, Table } from 'antd'; 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/x-www-form-urlencoded; charset=UTF-8", + + +const ProjectPhase = ({ params, ...props }) => { + 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 ProjectPhase = ({ params }) => { - 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}` - } - }*/ + console.log('company_id', company_id); const HEADER = { headers: { "Content-Type": "application/json", @@ -257,7 +257,7 @@ const ProjectPhase = ({ params }) => { const onConfirmDelete = async () => { let url = PROJECT_PHASE_DELETE(idDelete); - const result = await axios.delete(url, config) + const result = await axios.delete(url, HEADER) .then(res => res) .catch((error) => error.response); diff --git a/src/views/Master/RoleProject/index.js b/src/views/Master/RoleProject/index.js index d96c1d7..1a91e10 100644 --- a/src/views/Master/RoleProject/index.js +++ b/src/views/Master/RoleProject/index.js @@ -35,6 +35,19 @@ const LENGTH_DATA = 10 class index extends Component { 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) this.state = { alertDelete: false, @@ -61,7 +74,8 @@ class index extends Component { tooltipTambah: false, totalPage: 0, typeDialog: 'Save', - company_id + company_id: company_id, + role_name: role_name } this.columns = [ { @@ -115,7 +129,7 @@ class index extends Component { "joins": [], "orders": { "columns": ["id"], "ascending": false } } - if (role_name !== "Super Admin") { + if (this.state.role_name !== "Super Admin") { formData.columns.push( { "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" }, ) diff --git a/src/views/Pages/Login/Login.js b/src/views/Pages/Login/Login.js index 9b64976..f3c7379 100644 --- a/src/views/Pages/Login/Login.js +++ b/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 = { headers: { @@ -159,14 +159,14 @@ class Login extends Component { else { this.props.history.push({ 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 (role_id === 44) { this.props.history.push({ 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 { this.props.history.push(this.state.defaultPage); @@ -177,7 +177,7 @@ class Login extends Component { else { this.props.history.push({ 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 { @@ -222,7 +222,7 @@ class Login extends Component { if (doLogin && doLogin.data && doLogin.data.code === 200) { const { access_token, data_user } = doLogin.data.data 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('token', access_token); window.localStorage.setItem('user_id', data_user.id); diff --git a/src/views/SimproV2/Divisi/index.js b/src/views/SimproV2/Divisi/index.js index 89b0b79..08a4d0d 100644 --- a/src/views/SimproV2/Divisi/index.js +++ b/src/views/SimproV2/Divisi/index.js @@ -9,20 +9,6 @@ import { NotificationContainer, NotificationManager } from 'react-notifications' import { Pagination, Button, Tooltip } from 'antd'; 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 = [ { name: "Nama" }, @@ -30,8 +16,23 @@ const column = [ { name: "Color" }, ] -const ProjectType = ({ params }) => { - const token = localStorage.getItem("token") +const ProjectType = ({ params, ...props }) => { + 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 = { headers: { "Content-Type": "application/json", @@ -256,7 +257,7 @@ const ProjectType = ({ params }) => { const onConfirmDelete = async () => { let url = DIVISI_DELETE(idDelete); - const result = await axios.delete(url, config) + const result = await axios.delete(url, HEADER) .then(res => res) .catch((error) => error.response); diff --git a/src/views/SimproV2/Gantt/index.js b/src/views/SimproV2/Gantt/index.js index b46b34d..4693f66 100644 --- a/src/views/SimproV2/Gantt/index.js +++ b/src/views/SimproV2/Gantt/index.js @@ -15,7 +15,7 @@ import GanttFrame from "./GanttFrame"; let roCount = 0; 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) { role_id = props.location.state.role_id; userId = props.location.state.user_id; @@ -56,7 +56,7 @@ const Gantt = (props) => { cekPermission(); }, [listUserGant]); - useEffect(() => {}, [ro]); + useEffect(() => { }, [ro]); const getDataUserGantt = async () => { const payload = { @@ -94,7 +94,7 @@ const Gantt = (props) => { }; const cekPermission = () => { - let check = listUserGant.includes(userId); + let check = listUserGant.includes(parseInt(userId)); if (check) { setRo(0); } else { diff --git a/src/views/SimproV2/ProjectType/index.js b/src/views/SimproV2/ProjectType/index.js index 408fb93..9ca0621 100644 --- a/src/views/SimproV2/ProjectType/index.js +++ b/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 { Pagination, Button, Tooltip, Table } from 'antd'; 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 token = localStorage.getItem("token") +const ProjectType = ({ params, ...props }) => { + 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 = { headers: { "Content-Type": "application/json", @@ -106,7 +102,7 @@ const ProjectType = ({ params }) => { ) } const result = await axios - .post(PROJECT_TYPE_SEARCH, payload, config, HEADER) + .post(PROJECT_TYPE_SEARCH, payload, HEADER, HEADER) .then(res => res) .catch((error) => error.response); @@ -263,7 +259,7 @@ const ProjectType = ({ params }) => { const onConfirmDelete = async () => { let url = PROJECT_TYPE_DELETE(idDelete); - const result = await axios.delete(url, config) + const result = await axios.delete(url, HEADER) .then(res => res) .catch((error) => error.response); diff --git a/src/views/SimproV2/ResourceWorker/index.js b/src/views/SimproV2/ResourceWorker/index.js index a466811..e7e9c78 100644 --- a/src/views/SimproV2/ResourceWorker/index.js +++ b/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 } from '../../../const/ApiConst'; 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 config = { - headers: - { - Authorization: `Bearer ${token}`, - "Content-type": `application/json` + +const ResourceWorker = ({ params, ...props }) => { + 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 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 = { headers: { "Content-Type": "application/json", @@ -90,7 +91,7 @@ const ResourceWorker = ({ params }) => { } const result = await axios - .post(ROLE_SEARCH, formData, config) + .post(ROLE_SEARCH, formData, HEADER) .then(res => res) .catch((error) => error.response); @@ -106,7 +107,7 @@ const ResourceWorker = ({ params }) => { } const result = await axios - .post(DIVISI_SEARCH, formData, config) + .post(DIVISI_SEARCH, formData, HEADER) .then(res => res) .catch((error) => error.response); @@ -215,7 +216,7 @@ const ResourceWorker = ({ params }) => { } const result = await axios - .post(USER_SEARCH, payload, config) + .post(USER_SEARCH, payload, HEADER) .then(res => res) .catch((error) => error.response); @@ -468,7 +469,7 @@ const ResourceWorker = ({ params }) => { const onConfirmDelete = async () => { let url = USER_DELETE(idDelete); - const result = await axios.delete(url, config) + const result = await axios.delete(url, HEADER) .then(res => res) .catch((error) => error.response); diff --git a/src/views/SimproV2/Satuan/index.js b/src/views/SimproV2/Satuan/index.js index 6db7072..f849360 100644 --- a/src/views/SimproV2/Satuan/index.js +++ b/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 { 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 token = localStorage.getItem("token") - const company_id = localStorage.getItem("company_id") +const Satuan = ({ params, ...props }) => { + 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 = { headers: { "Content-Type": "application/json", @@ -101,7 +105,7 @@ const Satuan = ({ params }) => { const result = await axios - .post(SATUAN_SEARCH, payload, config) + .post(SATUAN_SEARCH, payload, HEADER) .then(res => res) .catch((error) => error.response); if (result && result.data && result.data.code == 200) { @@ -132,7 +136,7 @@ const Satuan = ({ params }) => { "orders": { "columns": ["id"], "ascending": false } } const result = await axios - .post(SATUAN_SEARCH, payload, config) + .post(SATUAN_SEARCH, payload, HEADER) .then(res => res) .catch((error) => error.response); if (result && result.data && result.data.code == 200) { @@ -218,7 +222,7 @@ const Satuan = ({ params }) => { const onConfirmDelete = async () => { let url = SATUAN_DELETE(idDelete); - const result = await axios.delete(url, config) + const result = await axios.delete(url, HEADER) .then(res => res) .catch((error) => error.response); From eebe4834448ee0823a3ec32221dfa368692d4d36 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 22 Nov 2023 16:31:32 +0700 Subject: [PATCH 3/3] update Url --- src/views/Dashboard/DashboardProjectCarousell.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/Dashboard/DashboardProjectCarousell.js b/src/views/Dashboard/DashboardProjectCarousell.js index 64e9f94..4378a39 100644 --- a/src/views/Dashboard/DashboardProjectCarousell.js +++ b/src/views/Dashboard/DashboardProjectCarousell.js @@ -272,7 +272,7 @@ const DashboardProject = (args) => { let URL_GANTT = ""; let version_gantt = ""; item.project.gantt.map((itemGantt, index) => { - URL_GANTT = `http://localhost:8444/adw-gantt/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${itemGantt.gantt_id}&proyek_id=${itemGantt.proyek_id}&token=${token}&ro=1`; + URL_GANTT = `https://konstruksi-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${itemGantt.gantt_id}&proyek_id=${itemGantt.proyek_id}&token=${token}&ro=1`; version_gantt = itemGantt.name_version }); const today = moment();