From 49d46d394edba4c3155612e745193f8a0e0f6b99 Mon Sep 17 00:00:00 2001 From: farhantock Date: Tue, 5 Dec 2023 13:58:56 +0700 Subject: [PATCH] filter by company_id --- src/views/SimproV2/ChecklistK3/index.js | 1 + .../CreatedProyek/AsignCustProject.js | 65 +- .../SimproV2/CreatedProyek/AsignHrProject.js | 73 +- .../CreatedProyek/DialogAssignCust.js | 87 +- .../CreatedProyek/DialogFormProyek.js | 1391 +++++++++-------- src/views/SimproV2/CreatedProyek/index.js | 86 +- 6 files changed, 873 insertions(+), 830 deletions(-) diff --git a/src/views/SimproV2/ChecklistK3/index.js b/src/views/SimproV2/ChecklistK3/index.js index 1b65b7f..0ba72c1 100644 --- a/src/views/SimproV2/ChecklistK3/index.js +++ b/src/views/SimproV2/ChecklistK3/index.js @@ -285,6 +285,7 @@ const ChecklistK3 = ({ params }) => { dataEdit={dataEdit} clickOpenModal={clickOpenModal} dataParent={allDataMenu} + company_id={company_id} /> diff --git a/src/views/SimproV2/CreatedProyek/AsignCustProject.js b/src/views/SimproV2/CreatedProyek/AsignCustProject.js index 55c1dd6..902c0f8 100644 --- a/src/views/SimproV2/CreatedProyek/AsignCustProject.js +++ b/src/views/SimproV2/CreatedProyek/AsignCustProject.js @@ -5,15 +5,15 @@ import { Table, Tooltip, Spin } from 'antd'; import 'antd/dist/antd.css'; import moment from 'moment'; import { - ASSIGN_HR_PROJECT_SEARCH, - ASSIGN_HR_PROJECT_DELETE + ASSIGN_HR_PROJECT_SEARCH, + ASSIGN_HR_PROJECT_DELETE } from '../../../const/ApiConst'; import axios from "../../../const/interceptorApi" import { NotificationContainer, NotificationManager } from 'react-notifications'; import SweetAlert from 'react-bootstrap-sweetalert'; import FormAsignCust from './DialogAssignCust'; -const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName }) => { +const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, company_id }) => { const token = localStorage.getItem("token") const HEADER = { headers: { @@ -25,11 +25,11 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy const [alertDelete, setAlertDelete] = useState(false) const [idDelete, setIdDelete] = useState(0) const [openDialogFormTools, setOpenDialogFormTools] = useState(false) - const [loading, setLoading] = useState(true); + const [loading, setLoading] = useState(true); useEffect(() => { - if (idTask > 0) { - setLoading(true); + if (idTask > 0) { + setLoading(true); getDataAssignHr(); } }, [openDialog]); @@ -64,11 +64,11 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy if (result && result.data && result.data.code == 200) { let dataRes = result.data.data || [] - const filteredData = dataRes.filter(item => item.is_customer === true); - setdataUserToProject(filteredData); - setLoading(false); + const filteredData = dataRes.filter(item => item.is_customer === true); + setdataUserToProject(filteredData); + setLoading(false); } else { - setLoading(false); + setLoading(false); NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); } } @@ -119,7 +119,7 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy key: 'x', className: "nowrap", render: (text, record) => <> - + {" "}, }, { title: 'Name Human Resource', dataIndex: 'join_first_name', key: 'join_first_name', className: "nowrap" } @@ -137,28 +137,28 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy const renderForm = () => { return ( -
+
{RenderTable}
) } - const handleCloseDialogFormTools = (type, data) => { - if (type === "add") { - getDataAssignHr() - } - if (type === "success") { - NotificationManager.success( - `Assign Customer Project berhasil disimpan!`, - "Success!!" - ); - } else if (type === "failed") { - NotificationManager.error( - `Assign Customer Project gagal disimpan!`, - "Failed!!" - ); - } - setOpenDialogFormTools(false) + const handleCloseDialogFormTools = (type, data) => { + if (type === "add") { + getDataAssignHr() + } + if (type === "success") { + NotificationManager.success( + `Assign Customer Project berhasil disimpan!`, + "Success!!" + ); + } else if (type === "failed") { + NotificationManager.error( + `Assign Customer Project gagal disimpan!`, + "Failed!!" + ); + } + setOpenDialogFormTools(false) } const toogleDialogFormTools = () => { @@ -189,10 +189,10 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy
Assign Customer - {proyekName}
- - - {renderForm()} - + + + {renderForm()} + ) diff --git a/src/views/SimproV2/CreatedProyek/AsignHrProject.js b/src/views/SimproV2/CreatedProyek/AsignHrProject.js index d65c399..9812fa4 100644 --- a/src/views/SimproV2/CreatedProyek/AsignHrProject.js +++ b/src/views/SimproV2/CreatedProyek/AsignHrProject.js @@ -4,14 +4,14 @@ import { Button, Form } from 'reactstrap'; import { Table, Tooltip, Spin } from 'antd'; import 'antd/dist/antd.css'; import moment from 'moment'; -import { API_ADW, TOKEN_ADW, ASSIGN_HR_PROJECT_SEARCH, ASSIGN_HR_PROJECT_DELETE, USER_LIST, PROJECT_ROLE_SEARCH, ASSIGN_HR_PROJECT_ADD, ASSIGN_HR_PROJECT_EDIT } from '../../../const/ApiConst'; +import { USER_SEARCH, ASSIGN_HR_PROJECT_SEARCH, ASSIGN_HR_PROJECT_DELETE, PROJECT_ROLE_SEARCH, ASSIGN_HR_PROJECT_ADD, ASSIGN_HR_PROJECT_EDIT } from '../../../const/ApiConst'; import axios from "../../../const/interceptorApi" import { NotificationContainer, NotificationManager } from 'react-notifications'; import SweetAlert from 'react-bootstrap-sweetalert'; import FormAsignHr from './FormAsignHr'; import { formatThousand } from '../../../const/CustomFunc'; -const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsResource, proyekName }) => { +const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, company_id, proyekName }) => { const token = localStorage.getItem("token") const HEADER = { headers: { @@ -25,18 +25,18 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR const [openDialogFormTools, setOpenDialogFormTools] = useState(false) const [dataEdit, setDataEdit] = useState(null) const [listUser, setListUser] = useState([]) - const [listRole, setListRole] = useState([]) - const [loading, setLoading] = useState(true); + const [listRole, setListRole] = useState([]) + const [loading, setLoading] = useState(true); useEffect(() => { if (idTask > 0) { - setLoading(true); + setLoading(true); getDataAssignHr(); } }, [openDialog]); useEffect(() => { - if (openDialog) { + if (openDialog) { getDataProjectRole(); getDataUser(); } @@ -50,8 +50,8 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR }, "columns": [ { "name": "name", "logic_operator": "ilike", "value": "", "table_name": "m_users" }, - { "name": "proyek_id", "logic_operator": "=", "value": idTask }, - { "name": "is_customer", "logic_operator": "=", "value": "false" } + { "name": "proyek_id", "logic_operator": "=", "value": idTask }, + { "name": "is_customer", "logic_operator": "=", "value": "false" } ], "joins": [ { "name": "m_users", "column_join": "user_id", "column_results": ["name"] }, @@ -72,23 +72,38 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR if (result && result.data && result.data.code == 200) { let dataRes = result.data.data || [] - setdataUserToProject(dataRes); - setLoading(false); + setdataUserToProject(dataRes); + setLoading(false); } else { - setLoading(false); + setLoading(false); NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); } } const getDataUser = async () => { - const HEADER_ADW = { - headers: { - "Authorization": `${TOKEN_ADW}` + + const payload = { + "select": [ + "id", + "name", + "role_id" + ], + "paging": { + "start": 0, + "length": -1 + }, + "columns": [ + { "name": "company_id", "logic_operator": "=", "value": company_id }, + ], + "orders": { + "columns": [ + "id" + ], + "ascending": false } } const result = await axios - // .get(`${API_ADW}employees`, HEADER_ADW) - .get(USER_LIST, HEADER) + .post(USER_SEARCH, payload, HEADER) .then(res => res) .catch((error) => error.response); if (result && result.data && result.data.data.length != 0) { @@ -161,7 +176,7 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR } const handleOpenDialogFormTools = () => { - setOpenDialogFormTools(true) + setOpenDialogFormTools(true) } const handleCancel = () => { @@ -177,10 +192,10 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR key: 'x', className: "nowrap", render: (text, record) => <> - + {" "} - - , + + , }, { title: 'Name Human Resource', dataIndex: 'join_first_name', key: 'join_first_name', className: "nowrap" }, { title: 'Role Human Resource', dataIndex: 'join_second_name', key: 'join_second_name', className: "nowrap" }, @@ -204,18 +219,18 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR const renderForm = () => { return ( -
+
{RenderTable}
) } const handleCloseDialogFormTools = (type, data) => { - if(type=="add"){ + if (type == "add") { addDataAssignHr(data); - }else if(type=="edit"){ + } else if (type == "edit") { editDataAssignHr(data); - }else{ + } else { setDataEdit(null) setOpenDialogFormTools(false) } @@ -237,7 +252,7 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR } } - const editDataAssignHr = async (payload) => { + const editDataAssignHr = async (payload) => { let url = ASSIGN_HR_PROJECT_EDIT(payload.id) const result = await axios .put(url, payload, HEADER) @@ -283,10 +298,10 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR
Assign Human Resource - {proyekName}
- - - {renderForm()} - + + + {renderForm()} + {/* diff --git a/src/views/SimproV2/CreatedProyek/DialogAssignCust.js b/src/views/SimproV2/CreatedProyek/DialogAssignCust.js index c680615..8467f9b 100644 --- a/src/views/SimproV2/CreatedProyek/DialogAssignCust.js +++ b/src/views/SimproV2/CreatedProyek/DialogAssignCust.js @@ -12,7 +12,7 @@ import 'antd/dist/antd.css'; import { NotificationManager } from 'react-notifications'; const role_id = localStorage.getItem('role_id'); -const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask }) => { +const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask, company_id }) => { const token = localStorage.getItem("token") const HEADER = { headers: { @@ -46,19 +46,20 @@ const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask }) => "name", "role_id" ], - "paging": { - "start": 0, - "length": -1 - }, - "columns": [ - { "name": "role_id", "logic_operator": "=", "value": 44 } - ], - "orders": { - "columns": [ - "id" - ], - "ascending": false - } + "paging": { + "start": 0, + "length": -1 + }, + "columns": [ + { "name": "role_id", "logic_operator": "=", "value": 44 }, + { "name": "company_id", "logic_operator": "=", "value": company_id }, + ], + "orders": { + "columns": [ + "id" + ], + "ascending": false + } } const URL = USER_SEARCH; const result = await axios @@ -90,7 +91,7 @@ const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask }) => handleCLearData() } - const saveCustProject= async () => { + const saveCustProject = async () => { const formData = { user_id: targetKeys, @@ -102,9 +103,9 @@ const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask }) => .then(res => res) .catch((error) => error.response); - if(result && result.status==200){ + if (result && result.status == 200) { closeDialog('success') - }else{ + } else { closeDialog('failed') } } @@ -120,32 +121,32 @@ const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask }) => const getCustProject = async () => { const payload = { - "select": [ + "select": [ "id", "user_id", "proyek_id", "is_customer" - ], - "columns": [ + ], + "columns": [ { "name": "proyek_id", "logic_operator": "=", "value": idTask }, - {"name": "is_customer", "logic_operator": "=", "value": "true"} - ] + { "name": "is_customer", "logic_operator": "=", "value": "true" } + ] } const result = await axios .post(ASSIGN_HR_PROJECT_SEARCH, payload, HEADER) .then(res => res) .catch((error) => error.response); - if(result && result.status==200){ - console.log("cek get assign HR is custumer",result.data.data) - let data = result.data.data || [] - let newTargetKeys = [] - if (data.length > 0) { - data.map((val,index)=> { - newTargetKeys.push(val.user_id) - }); - } - setTargetKeys(newTargetKeys) + if (result && result.status == 200) { + console.log("cek get assign HR is custumer", result.data.data) + let data = result.data.data || [] + let newTargetKeys = [] + if (data.length > 0) { + data.map((val, index) => { + newTargetKeys.push(val.user_id) + }); + } + setTargetKeys(newTargetKeys) } } const renderForm = () => { @@ -158,16 +159,16 @@ const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask }) => overflow: "auto" }}> item.title} - listStyle={{ - width: 250, - height: 300, - }} + showSearch + titles={['Available Customer', 'Granted to']} + dataSource={assignCustomer} + targetKeys={targetKeys} + onChange={handleChange} + render={item => item.title} + listStyle={{ + width: 250, + height: 300, + }} />
) @@ -176,7 +177,7 @@ const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask }) => return ( <> - + Add Customer {renderForm()} diff --git a/src/views/SimproV2/CreatedProyek/DialogFormProyek.js b/src/views/SimproV2/CreatedProyek/DialogFormProyek.js index 3f4d89b..053bb14 100644 --- a/src/views/SimproV2/CreatedProyek/DialogFormProyek.js +++ b/src/views/SimproV2/CreatedProyek/DialogFormProyek.js @@ -1,7 +1,7 @@ import React, { useEffect, useState, useMemo } from "react"; import { Modal, ModalHeader, ModalBody, ModalFooter } from "reactstrap"; import { Button, Form, FormGroup, Label, Input, Col, Row } from "reactstrap"; -import { DatePicker, Tooltip, Select, Divider } from "antd"; +import { DatePicker, Tooltip, Select, Divider, Spin } from "antd"; import axios from "../../../const/interceptorApi"; import moment from "moment"; import { CKEditor } from '@ckeditor/ckeditor5-react'; @@ -18,7 +18,7 @@ import { PROJECT_PARTICIPANT_WHERE_CUSTOM, PROJECT_CHECKLIST_WHERE_CUSTOM, PROJECT_ISSUE_WHERE_CUSTOM, - PROJECT_RISK_WHERE_CUSTOM, + PROJECT_RISK_WHERE_CUSTOM, PROJECT_APPROVAL_WHERE_CUSTOM, CURRENCY_LIST, } from "../../../const/ApiConst"; @@ -34,12 +34,12 @@ const DialogFormProyek = ({ dataPhaseProject, dataDivisions, dataPM, - projectImage + projectImage }) => { const token = localStorage.getItem("token"); const HEADER = { headers: { - "Content-Type": "application/json", + "Content-Type": "application/json", Authorization: `Bearer ${token}`, }, }; @@ -75,7 +75,7 @@ const DialogFormProyek = ({ const [participants, setParticipants] = useState([]); const [checklist, setChecklist] = useState([]); const [issue, setIssue] = useState([]); - const [image, setImage] = useState("") + const [image, setImage] = useState("") const [availableResources, setAvailableResources] = useState(""); const [milestones, setMilestones] = useState([]); const [potentialRisks, setPotentialRisks] = useState([]); @@ -88,8 +88,9 @@ const DialogFormProyek = ({ const [lastIdxRisks, setLastIdxRisks] = useState(0); const [lastIdxMilestones, setLastIdxMilestones] = useState(0); const [lastIdxApproval, setLastIdxApproval] = useState(0); - + const [loading, setLoading] = useState(true); const handleGetdataIdproyek = async (id) => { + setLoading(true) const result = await axios .get(`${PROYEK_GET_ID(id)}`, HEADER) .then((res) => res) @@ -122,6 +123,7 @@ const DialogFormProyek = ({ setCurrencyCode(val.currency_code); setCurrencySymbol(val.currency_symbol); setCurrencyName(val.currency_name); + setLoading(false) } else { NotificationManager.error(`Data proyek gagal di edit`, `Failed!!`); } @@ -148,31 +150,31 @@ const DialogFormProyek = ({ .get(`${PROJECT_PARTICIPANT_WHERE_CUSTOM("proyek_id", id)}`, HEADER) .then((res) => res) .catch((err) => err.response); - setParticipants(result.data.data); - }; + setParticipants(result.data.data); + }; const handleGetDataChecklist = async (id) => { const result = await axios .get(`${PROJECT_CHECKLIST_WHERE_CUSTOM("proyek_id", id)}`, HEADER) .then((res) => res) .catch((err) => err.response); - setChecklist(result.data.data); - }; + setChecklist(result.data.data); + }; const handleGetDataIssue = async (id) => { const result = await axios .get(`${PROJECT_ISSUE_WHERE_CUSTOM("proyek_id", id)}`, HEADER) .then((res) => res) .catch((err) => err.response); - setIssue(result.data.data); - }; + setIssue(result.data.data); + }; const handleGetDataRisk = async (id) => { const result = await axios .get(`${PROJECT_RISK_WHERE_CUSTOM("proyek_id", id)}`, HEADER) .then((res) => res) .catch((err) => err.response); - setPotentialRisks(result.data.data); + setPotentialRisks(result.data.data); }; const handleGetDataCurrency = async () => { @@ -243,7 +245,7 @@ const DialogFormProyek = ({ } }, [openDialog]); - const handleSave = () => { + const handleSave = () => { let data = ""; if (idTask) { data = { @@ -274,7 +276,7 @@ const DialogFormProyek = ({ currency_name: currencyName, }; data.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval }; - data.imageStructureOrg = organization ? organization : null; + data.imageStructureOrg = organization ? organization : null; closeDialog("edit", data); } else { data = { @@ -292,8 +294,8 @@ const DialogFormProyek = ({ finance, company, area_kerja: workArea, - durasi_proyek: parseInt(duration), - late_consequence: late, + durasi_proyek: parseInt(duration), + late_consequence: late, assumtion: assumtion, keterangan: description, project_objectives: objectives, @@ -303,10 +305,10 @@ const DialogFormProyek = ({ currency_code: currencyCode, currency_name: currencyName, }; - data.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval }; - data.imageStructureOrg = organization ? organization : null; + data.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval }; + data.imageStructureOrg = organization ? organization : null; - closeDialog("add", data); + closeDialog("add", data); } handleClearData(); }; @@ -332,35 +334,35 @@ const DialogFormProyek = ({ setHealthBudget(val); }; - const onChangePm = (val) => { - const item = dataPM.find((item) => item.id === val); - const existingParticipant = participants.find((participant) => participant.tittle === "PM"); - if (existingParticipant) { - setParticipants((prevParticipants) => { - return prevParticipants.map((participant) => { - if (participant.tittle === "PM") { - return { - ...participant, - name: item.name, - }; - } - return participant; - }); - }); - } else { - setParticipants((prevParticipants) => [ - ...prevParticipants, - { - id: item.id, - tittle: "PM", - name: item.name, - }, - ]); - setLastIdxParticipants(lastIdxParticipants + 1); - } + const onChangePm = (val) => { + const item = dataPM.find((item) => item.id === val); + const existingParticipant = participants.find((participant) => participant.tittle === "PM"); + if (existingParticipant) { + setParticipants((prevParticipants) => { + return prevParticipants.map((participant) => { + if (participant.tittle === "PM") { + return { + ...participant, + name: item.name, + }; + } + return participant; + }); + }); + } else { + setParticipants((prevParticipants) => [ + ...prevParticipants, + { + id: item.id, + tittle: "PM", + name: item.name, + }, + ]); + setLastIdxParticipants(lastIdxParticipants + 1); + } - setPic(val); - }; + setPic(val); + }; const onChangeCurrency = (val) => { let curr = val.split("|"); // code|symbol|name @@ -431,7 +433,7 @@ const DialogFormProyek = ({ }); setChecklist(checklist); setLastIdxChecklists(lastIdxChecklists + 1); - }; + }; const addIssue = () => { issue.push({ @@ -441,7 +443,7 @@ const DialogFormProyek = ({ }); setIssue(issue); setLastIdxIssues(lastIdxIssues + 1); - }; + }; const addRisk = () => { potentialRisks.push({ @@ -455,72 +457,71 @@ const DialogFormProyek = ({ }; const handleInputChangeParticipants = (e, index) => { - const { name, value } = e.target; - const existingParticipant = participants.find((participant) => participant.tittle === "PM"); - if(value.toLowerCase() === "pm" && name === "tittle" && existingParticipant) - { - alert('PM is already exist!'); - setParticipants((prevParticipants) => - prevParticipants.map((participant, i) => { - if (i === index) { - return { - ...participant, - tittle: "", - }; - } - return participant; - }) - ); - return false; - } + const { name, value } = e.target; + const existingParticipant = participants.find((participant) => participant.tittle === "PM"); + if (value.toLowerCase() === "pm" && name === "tittle" && existingParticipant) { + alert('PM is already exist!'); + setParticipants((prevParticipants) => + prevParticipants.map((participant, i) => { + if (i === index) { + return { + ...participant, + tittle: "", + }; + } + return participant; + }) + ); + return false; + } const newParticipants = [...participants]; newParticipants[index][name] = value; setParticipants(newParticipants); - }; + }; - const handleInputChangeChecklists = (e, index) => { - if (e === true || e === false) { - const value = e; - const name = "status_exist"; - const newChecklists = [...checklist]; - newChecklists[index][name] = value; - setChecklist(newChecklists); - } else { - const { name, value } = e.target; - const newChecklists = [...checklist]; - newChecklists[index][name] = value; - setChecklist(newChecklists); - } - }; + const handleInputChangeChecklists = (e, index) => { + if (e === true || e === false) { + const value = e; + const name = "status_exist"; + const newChecklists = [...checklist]; + newChecklists[index][name] = value; + setChecklist(newChecklists); + } else { + const { name, value } = e.target; + const newChecklists = [...checklist]; + newChecklists[index][name] = value; + setChecklist(newChecklists); + } + }; - const handleInputChangeIssues = (e, index) => { - if (e === 1 || e === 2|| e === 3|| e === 4|| e === 5|| e === 6|| e === 7) { - const value = e; - const name = "level_issue"; - const newIssues = [...issue]; - newIssues[index][name] = value; - setIssue(newIssues); - } else { - const { name, value } = e.target; - const newIssues = [...issue]; - newIssues[index][name] = value; - setIssue(newIssues); - } - }; + const handleInputChangeIssues = (e, index) => { + if (e === 1 || e === 2 || e === 3 || e === 4 || e === 5 || e === 6 || e === 7) { + const value = e; + const name = "level_issue"; + const newIssues = [...issue]; + newIssues[index][name] = value; + setIssue(newIssues); + } else { + const { name, value } = e.target; + const newIssues = [...issue]; + newIssues[index][name] = value; + setIssue(newIssues); + } + }; - const handleInputChangeRisks = (e, index) => { - if (e === 1 || e === 2 || e === 3 || e === 4 || e === 5 || e === 6 || e === 7) { - const value = e; - const name = "level_risk"; - const newRisks = [...potentialRisks]; - newRisks[index][name] = value; - setPotentialRisks(newRisks); - } else { - const { name, value } = e.target; - const newRisks = [...potentialRisks]; - newRisks[index][name] = value; - setPotentialRisks(newRisks); - } + const handleInputChangeRisks = (e, index) => { + if (e === 1 || e === 2 || e === 3 || e === 4 || e === 5 || e === 6 || e === 7) { + const value = e; + const name = "level_risk"; + const newRisks = [...potentialRisks]; + newRisks[index][name] = value; + setPotentialRisks(newRisks); + } else { + const { name, value } = e.target; + const newRisks = [...potentialRisks]; + newRisks[index][name] = value; + setPotentialRisks(newRisks); + } }; const deleteParticipant = (id) => { @@ -531,7 +532,7 @@ const DialogFormProyek = ({ setParticipants(participants.filter((_, i2) => i2 !== id)); } } - }; + }; const deleteChecklists = (id) => { if (checklist && checklist.length > 0) { @@ -541,7 +542,7 @@ const DialogFormProyek = ({ setChecklist(checklist.filter((_, i2) => i2 !== id)); } } - }; + }; const deleteIssues = (id) => { if (issue && issue.length > 0) { @@ -551,7 +552,7 @@ const DialogFormProyek = ({ setIssue(issue.filter((_, i2) => i2 !== id)); } } - }; + }; const deleteRisks = (id) => { if (potentialRisks && potentialRisks.length > 0) { @@ -630,544 +631,544 @@ const DialogFormProyek = ({ } } }; - const editorConfig = { - height: '900px' - }; - - const RenderFormProject = () => { - return ( - <> -
- - - * Wajib diisi. - - - - - - - setName(e.target.value)} - /> - - - - - - setShortName(e.target.value)} - /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - { - let currentDate = moment(current).format("YYYY-MM-DD"); - let customDate = moment(startDate) - .add(1, "days") - .format("YYYY-MM-DD"); - return current && currentDate < customDate; - }} - format={"DD-MM-YYYY"} - style={{ width: "100%" }} - value={endDate} - onChange={handleDatePickerEnd} - /> - - - - - - - - setWorkArea(e.target.value)} - /> - - - - - - setCompany(e.target.value)} - /> - - - - - - - - - - - - - setBiaya(formatNumber(e.target.value))} - /> - - - - - - - - - - - - - - - - setProjectDuration(e.target.value)} - /> - - - - - - - - setProjectStructureOrg(e.target.files[0])} - /> - {projectImage ? projectImage.image :

Not found image

}
-
- - - - - setDescription(e.target.value)} - /> - - -
- - - - { - const data = editor.getData(); - setLateConsequence(data); - } } - /> - - - - - - { - const data = editor.getData(); - setAssumtion(data); - } } - /> - - - - - - - -

Item

- - -

Availability

- - -

Action

- - - - - - -
-
{RenderChecklist()}
- -
- - - - - - -

Issue Level

- - -

Description

- - -

Action

- - - - - - -
-
{RenderIssue()}
- -
- - Info Dashboard - - - - - - - - - - - - - - - -
+ const editorConfig = { + height: '900px' + }; -
- - - Project Objectives - - - { - const data = editor.getData(); - setObjectives(data); - } } - /> - - - - - Project is considered successful when - - - { - const data = editor.getData(); - setProjectIsConsideredSuccessful(data); - } } - /> - - - - - Project Participants - - + const RenderFormProject = () => { + return ( + <> + - -

Title

+ + * Wajib diisi. - -

Name

+
+ + + + + setName(e.target.value)} + /> + - -

Action

+ + + + setShortName(e.target.value)} + /> + - - - - -
-
{RenderParticipants()}
- -
- - - Testing Environment - - - { - const data = editor.getData(); - setTestingEnv(data); - } } - /> - - - - - Milestones - - - -

Status

+ + + + + - -

Deadline

+ + + + + - -

Action

+
+ + + + + + - - - - + + + + { + let currentDate = moment(current).format("YYYY-MM-DD"); + let customDate = moment(startDate) + .add(1, "days") + .format("YYYY-MM-DD"); + return current && currentDate < customDate; + }} + format={"DD-MM-YYYY"} + style={{ width: "100%" }} + value={endDate} + onChange={handleDatePickerEnd} + /> + + + + + + + + setWorkArea(e.target.value)} + /> + + + + + + setCompany(e.target.value)} + /> + + + + + + + + + + + + + setBiaya(formatNumber(e.target.value))} + /> + + + + + + + + + + + + + + + + setProjectDuration(e.target.value)} + /> + -
{RenderMilestones()}
- -
- - - Potential Risk - - - - -

Risk Level

- - -

Description

- - -

Prevention

- - -

Action

- - - - - - -
-
{RenderRisk()}
- -
- - - Approval - - + + + + setProjectStructureOrg(e.target.files[0])} + /> + {projectImage ? projectImage.image :

Not found image

}
+
+ + + + + setDescription(e.target.value)} + /> + + +
+ + + + { + const data = editor.getData(); + setLateConsequence(data); + }} + /> + + + + + + { + const data = editor.getData(); + setAssumtion(data); + }} + /> + + + + + + + +

Item

+ + +

Availability

+ + +

Action

+ + + + + + +
+
{RenderChecklist()}
+ +
+ + + + + + +

Issue Level

+ + +

Description

+ + +

Action

+ + + + + + +
+
{RenderIssue()}
+ +
+ + Info Dashboard + + + + + + + + + + + + + + + + + +
+ + + Project Objectives + + + { + const data = editor.getData(); + setObjectives(data); + }} + /> + + + + + Project is considered successful when + + + { + const data = editor.getData(); + setProjectIsConsideredSuccessful(data); + }} + /> + + + + + Project Participants + + + + +

Title

+ + +

Name

+ + +

Action

+ + + + + + +
+
{RenderParticipants()}
+ +
+ + + Testing Environment + + + { + const data = editor.getData(); + setTestingEnv(data); + }} + /> + + + -

Title

+ Milestones + + + +

Status

+ + +

Deadline

+ + +

Action

+ + + + + + +
+
{RenderMilestones()}
+ +
+ -

Name

+ Potential Risk + + + +

Risk Level

+ + +

Description

+ + +

Prevention

+ + +

Action

+ + + + + + +
+
{RenderRisk()}
+ +
+ -

Date

+ Approval + + + + +

Title

+ + +

Name

+ + +

Date

+ + +

Action

+ + + + + + +
+
{RenderApproval()}
- -

Action

- - - - - -
-
{RenderApproval()}
- - -
- - ) - } + + + ) + } const RenderChecklist = () => { - if (checklist.length > 0) { - return checklist.map((item, index) => { + if (checklist?.length > 0) { + return checklist.map((item, index) => { return ( @@ -1179,18 +1180,18 @@ const DialogFormProyek = ({ /> - - - - + + + +
); } - }; + }; const RenderRisk = () => { - if (potentialRisks.length > 0) { - return potentialRisks.map((item, index) => { + if (potentialRisks?.length > 0) { + return potentialRisks.map((item, index) => { return ( - - - - - - + + + + + + handleInputChangeRisks(e, index)} + onChange={(e) => handleInputChangeRisks(e, index)} /> @@ -1316,7 +1317,7 @@ const DialogFormProyek = ({ type="textarea" value={item.preventive_risk ? item.preventive_risk : ""} name="preventive_risk" - onChange={(e) => handleInputChangeRisks(e, index)} + onChange={(e) => handleInputChangeRisks(e, index)} /> @@ -1345,10 +1346,10 @@ const DialogFormProyek = ({ ); } - }; + }; const RenderParticipants = () => { - if (participants.length > 0) { + if (participants?.length > 0) { return participants.map((item, index) => { return ( @@ -1415,7 +1416,7 @@ const DialogFormProyek = ({ value={moment(item.deadline)} name="deadline" onChange={(date, dateString) => - handleInputChangeMilestonesDate(date, "deadline", index) + handleInputChangeMilestonesDate(date, "deadline", index) } /> @@ -1474,7 +1475,7 @@ const DialogFormProyek = ({ value={moment(item.date)} name="date" onChange={(date, dateString) => - handleInputChangeApprovalDate(date, "date", index) + handleInputChangeApprovalDate(date, "date", index) } /> @@ -1514,9 +1515,13 @@ const DialogFormProyek = ({ ? idTask ? "Update Project" : "Add Project" - : "Project Charter"} + : "Project Charter"} - { RenderFormProject() } + + + {RenderFormProject()} + + {step === 1 ? ( <> diff --git a/src/views/SimproV2/CreatedProyek/index.js b/src/views/SimproV2/CreatedProyek/index.js index fb1a538..1827630 100644 --- a/src/views/SimproV2/CreatedProyek/index.js +++ b/src/views/SimproV2/CreatedProyek/index.js @@ -23,31 +23,23 @@ import { } from "antd"; import { PROJECT_APPROVAL_ADD, - PROJECT_APPROVAL_EDIT, PROJECT_PARTICIPANT_ADD, PROJECT_CHECKLIST_ADD, PROJECT_ISSUE_ADD, PROJECT_RISK_ADD, - PROJECT_PARTICIPANT_EDIT, PROJECT_MILESTONE_ADD, - PROJECT_MILESTONE_EDIT, PROJECT_PARTICIPANT_DELETE_BY_PROYEK, PROJECT_MILESTONE_DELETE_BY_PROYEK, PROJECT_APPROVAL_DELETE_BY_PROYEK, - USER_LIST, - TYPE_PROYEK, + USER_SEARCH, + + PROJECT_TYPE_SEARCH, PROYEK_ADD, PROYEK_SEARCH, - PROYEK_SEARCH_BY_USER, PROYEK_EDIT, ASSIGN_HR_PROJECT_SEARCH, PROJECT_CHECKLIST_SEARCH, PROYEK_DELETE, - TOOLS_RESOURCE_SEARCH, - MATERIAL_RESOURCE_SEARCH, - USER_SEARCH, - PROJECT_CHARTER_SEARCH, - HIERARCHY_FTTH_SEARCH, PROJECT_ISSUE_SEARCH, PROJECT_RISK_SEARCH, PROJECT_CHECKLIST_DELETE_BY_PROYEK, @@ -61,18 +53,15 @@ import { PROJECT_APPROVAL_SEARCH, CHECKLIST_K3_LIST, VERSION_GANTT_SEARCH, - PHASE_PROYEK, - DIVISI_LIST, + PROJECT_PHASE_SEARCH, + DIVISI_SEARCH, BASE_OSPRO, IMAGE_UPLOAD, IMAGE_GET_BY_ID, IMAGE_DELETE, } from "../../../const/ApiConst"; import { - formatNumber, - formatRupiah, - formatThousand, - renderFormatRupiah, + formatThousand } from "../../../const/CustomFunc"; import moment from "moment"; // import DialogFormResource from './DialogFormResource'; @@ -96,7 +85,7 @@ const url = ""; const format = "DD-MM-YYYY"; const CreatedProyek = ({ params, ...props }) => { - let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = ''; + let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0; 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; @@ -109,6 +98,7 @@ const CreatedProyek = ({ params, ...props }) => { user_id = localStorage.getItem("user_id"); token = localStorage.getItem("token"); isLogin = localStorage.getItem("isLogin"); + company_id = localStorage.getItem('company_id'); } const history = useHistory(); const HEADER = { @@ -234,8 +224,17 @@ const CreatedProyek = ({ params, ...props }) => { }; const handleGetTipeProject = async () => { + const payload = { + "paging": { "start": 0, "length": -1 }, + "columns": [ + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ], + "joins": [], + "orders": { "columns": ["id"], "ascending": false } + } + const result = await axios - .get(TYPE_PROYEK, HEADER) + .post(PROJECT_TYPE_SEARCH, payload, HEADER) .then((res) => res) .catch((err) => err.response); if (result && result.data && result.data.code === 200) { @@ -245,8 +244,17 @@ const CreatedProyek = ({ params, ...props }) => { }; const handleGetPhaseProject = async () => { + const payload = { + "paging": { "start": 0, "length": -1 }, + "columns": [ + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ], + "joins": [], + "orders": { "columns": ["id"], "ascending": false } + } + const result = await axios - .get(PHASE_PROYEK, HEADER) + .post(PROJECT_PHASE_SEARCH, payload, HEADER) .then((res) => res) .catch((err) => err.response); if (result && result.data && result.data.code === 200) { @@ -255,8 +263,17 @@ const CreatedProyek = ({ params, ...props }) => { }; const handleGetDivisions = async () => { + const payload = { + "paging": { "start": 0, "length": -1 }, + "columns": [ + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ], + "joins": [], + "orders": { "columns": ["id"], "ascending": false } + } + const result = await axios - .get(DIVISI_LIST, HEADER) + .post(DIVISI_SEARCH, payload, HEADER) .then((res) => res) .catch((err) => err.response); if (result && result.data && result.data.code === 200) { @@ -266,9 +283,18 @@ const CreatedProyek = ({ params, ...props }) => { } }; - const handleGetDataPm = async (text) => { + const handleGetDataPm = async () => { + const payload = { + "paging": { "start": 0, "length": -1 }, + "columns": [ + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ], + "joins": [], + "orders": { "columns": ["id"], "ascending": false } + } + const result = await axios - .get(USER_LIST, HEADER) + .post(USER_SEARCH, payload, HEADER) .then((res) => res) .catch((err) => err.response); if (result && result.data && result.data.code === 200) { @@ -304,6 +330,7 @@ const CreatedProyek = ({ params, ...props }) => { }; const getDataProyek = async () => { + setLoading(true); let start = 0; let hierarchy = []; hierarchy.push(JSON.parse(localStorage.getItem("hierarchy"))); @@ -468,10 +495,6 @@ const CreatedProyek = ({ params, ...props }) => { } }; - const handleOpenDialog = (id) => { - setOpenDialog(true); - setidTask(id); - }; const handleOpenDialogProyek = async (id) => { setOpenDialogProyek(true); @@ -531,12 +554,6 @@ const CreatedProyek = ({ params, ...props }) => { setOpenDialogAssignK3(true); }; - const handleOpenDialogTools = (data) => { - setOpenDialogTools(true); - setidTask(data.id); - setProyekName(data.nama); - setUserProyek(data.user_proyeks); - }; const handleOpenDialogViewDetail = async (data) => { setLoading(true); @@ -1132,6 +1149,7 @@ const CreatedProyek = ({ params, ...props }) => { }; const editProyek = async (data) => { + setLoading(true) const { checklist, issue, potentialRisks, participants, milestones, approval } = data.projectCharter; const imageObject = data.imageStructureOrg; @@ -1852,6 +1870,7 @@ const CreatedProyek = ({ params, ...props }) => { handleClose={handleCloseDialogAsignHr} idTask={idTask} proyekName={proyekName} + company_id={company_id} /> ), [openDialogAsignHR] @@ -1867,6 +1886,7 @@ const CreatedProyek = ({ params, ...props }) => { handleClose={handleCloseDialogAsignCust} idTask={idTask} proyekName={proyekName} + company_id={company_id} /> ), [openDialogAsignCust]