diff --git a/src/views/SimproV2/CreatedProyek/DIalogHierarchy.js b/src/views/SimproV2/CreatedProyek/DIalogHierarchy.js index 4709a87..1099d83 100644 --- a/src/views/SimproV2/CreatedProyek/DIalogHierarchy.js +++ b/src/views/SimproV2/CreatedProyek/DIalogHierarchy.js @@ -9,7 +9,7 @@ import { HIERARCHY_FTTH_DELETE, HIERARCHY_FTTH_TREE, VERSION_GANTT_SEARCH, HIERA import axios from "../../../const/interceptorApi" import { NotificationContainer, NotificationManager } from 'react-notifications'; import DialogUserGantt from './DialogUserGantt'; -import DialogForm from './DIalogFormHierarchy' +import DialogForm from './DialogFormHierarchy' import DialogFormGantt from './DialogFormGantt'; import DialogGantt from './DialogGantt'; import { useTranslation } from 'react-i18next'; @@ -104,8 +104,8 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek } const closeDialogGantt = () => { - setOpenDialogGantt(false); - }; + setOpenDialogGantt(false); + }; const toggleDialogFormGantt = () => { setOpenDialogFormGantt(!openDialogFormGantt) @@ -195,9 +195,9 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek {" "} - {text.dataGantt && ( - - )} + {text.dataGantt && (<> + + {" "})} , }, @@ -308,7 +308,7 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek diff --git a/src/views/SimproV2/CreatedProyek/DialogFormGantt.js b/src/views/SimproV2/CreatedProyek/DialogFormGantt.js index d999b92..4161422 100644 --- a/src/views/SimproV2/CreatedProyek/DialogFormGantt.js +++ b/src/views/SimproV2/CreatedProyek/DialogFormGantt.js @@ -18,7 +18,6 @@ const DialogFormGantt = ({ openDialog, closeDialog, toggleDialog, idTask, parent const [name, setName] = useState("") const [description, setDesctription] = useState("") const [calculationType, setCalculationType] = useState("detail") - console.log('parentId', parentId); const handleCLearData = () => { setId(0) setName("") @@ -44,8 +43,6 @@ const DialogFormGantt = ({ openDialog, closeDialog, toggleDialog, idTask, parent hierarchy_ftth_id: parentId } - - console.log('formData', formData); const result = await axios .post(VERSION_GANTT_ADD, formData, HEADER) .then(res => res) diff --git a/src/views/SimproV2/CreatedProyek/index.js b/src/views/SimproV2/CreatedProyek/index.js index 21d8fd4..13deced 100644 --- a/src/views/SimproV2/CreatedProyek/index.js +++ b/src/views/SimproV2/CreatedProyek/index.js @@ -41,6 +41,7 @@ import { MATERIAL_RESOURCE_SEARCH, USER_SEARCH, PROJECT_CHARTER_SEARCH, + HIERARCHY_FTTH_SEARCH, TOOLS_RESOURCE_LIST, MATERIAL_RESOURCE_LIST, PROYEK_GET_ID, @@ -65,7 +66,7 @@ import DialogTableTools from "./DialogTableTools"; import DialogDocument from "./DialogDocument"; import DialogInitDocument from "./DialogInitDocument"; import DialogGantt from "./DialogGantt"; -import DialogHierarchy from "./DIalogHierarchy"; +import DialogHierarchy from "./DialogHierarchy"; // import DialogAsignHr from './AsignHrProject'; import AssignHrProject from "./AsignHrProject"; import AssignK3Project from "./AssignK3Project"; @@ -306,12 +307,12 @@ const CreatedProyek = ({ params, ...props }) => { } }; - const getdataHierarchy = async (idTask) => { + const getdataHierarchy = async (idTask) => { setLoadHierarchy(true); const payload = { columns: [ { - name: "proyek_id", + name: "project_id", logic_operator: "=", value: idTask, operator: "AND", @@ -319,10 +320,9 @@ const CreatedProyek = ({ params, ...props }) => { ], }; const result = await axios - .post(VERSION_GANTT_SEARCH, payload, HEADER) + .post(HIERARCHY_FTTH_SEARCH, payload, HEADER) .then((res) => res) .catch((error) => error.response); - if (result && result.status == 200) { setDataHierarchy(result.data.data); setLoadHierarchy(false); @@ -386,8 +386,8 @@ const CreatedProyek = ({ params, ...props }) => { setProyekName(data.nama); setOpenDialogGantt(true); }; - - const handleOpenDialogHierarchy = (data) => { + + const handleOpenDialogHierarchy = (data) => { setidTask(data.id); setProyekName(data.nama); setOpenDialogHierarchy(true); @@ -400,8 +400,8 @@ const CreatedProyek = ({ params, ...props }) => { const closeDialogGantt = () => { setOpenDialogGantt(false); }; - - const toggleDialogHierarchy = () => { + + const toggleDialogHierarchy = () => { setOpenDialogHierarchy(!openDialogHierarchy); }; @@ -1002,13 +1002,13 @@ const CreatedProyek = ({ params, ...props }) => { const popupMenuGantt = (text, record) => { return (
- {loadVersionGantt && ( + {text.type_proyek_id !== 9 && loadVersionGantt && (
)} - {!loadVersionGantt && ( + {(!loadVersionGantt && text.type_proyek_id !== 9) && ( <> {dataVersionGantt.slice(0, 8).map((res) => ( @@ -1032,27 +1032,27 @@ const CreatedProyek = ({ params, ...props }) => { }} >
)} - {text.type_proyek_id == 9 ? -
handleOpenDialogHierarchy(text)} - > - - - - More Hierarchy Menu ... -
: -
handleOpenDialogGantt(text)} - > - - - - More Gantt Menu ... -
} )} + {text.type_proyek_id == 9 ? +
handleOpenDialogHierarchy(text)} + > + + + + More Hierarchy Menu ... +
: +
handleOpenDialogGantt(text)} + > + + + + More Gantt Menu ... +
} ); }; @@ -1081,26 +1081,26 @@ const CreatedProyek = ({ params, ...props }) => { content={popupMenuGantt(text, record)} trigger="click" > - { - text.type_proyek_id == 9 ? - : - - } - + { + text.type_proyek_id == 9 ? + : + + } + ), }, @@ -1320,8 +1320,8 @@ const CreatedProyek = ({ params, ...props }) => { ), [openDialogGantt] ); - - const renderDialogHierarchy = useMemo( + + const renderDialogHierarchy = useMemo( () => ( { + const token = window.localStorage.getItem('token'); + const [typeDialog, setTypeDialog] = useState(typeDialogProp) + const [userName, setUserName] = useState(userNameProp) + const [name, setName] = useState(nameProp) + const [noHp, setNohp] = useState(noHpProp) + const [gender, setGender] = useState(genderProp) + const [address, setAddres] = useState(addressProp) + const [birthdayPlace, setBirthdayplace] = useState(birthdayPlaceProp) + const [birthdayDate, setBirthdaydate] = useState(birthdayDateProp) + const [idNumber, setIdnumber] = useState(idNumberProp) + const [email, setEmail] = useState(emailProp) + const [password, setPassword] = useState('') + const [oldPassword, setOldPassword] = useState('') + const [newPassword, setNewPassword] = useState('') + const [newPasswordConfirm, setNewPasswordConfirm] = useState('') + const [activeTab, setActiveTab] = useState('tab1') + + useEffect(() => { + setUserName(userNameProp); + setName(nameProp); + setNohp(noHpProp); + setGender(genderProp); + setAddres(addressProp); + setBirthdayplace(birthdayPlaceProp); + setIdnumber(idNumberProp); + setEmail(emailProp); + }, [userNameProp, nameProp, noHpProp, genderProp, addressProp, birthdayPlaceProp, idNumberProp, emailProp]); + + const handleSave = () => { + let data = ''; + if (typeDialog === "Personal") { + data = { + name: name, + phone_number: noHp, + gender: gender, + ktp_number: idNumber, + birth_place: birthdayPlace, + address: address, + }; + if (birthdayDate) { + data.birth_date = birthdayDate; + } + closeDialog('profile', data) + } else if (typeDialog === "Account") { + data = { + username: userName, + email: email, + }; + if (newPassword) { + data.password = newPassword; + } + console.log(data); + closeDialog('profile', data) + } + } + + const handleCancel = () => { + closeDialog('cancel', 'none') + } + + const setupSelectRole = () => { + return ( + <> + {roleList.map((val, index) => { + return ( + + ) + })} + + ) + } + + + const renderForm = () => { + return ( +
+ + + + + setName(e.target.value)} /> + + + + + setIdnumber(e.target.value)} /> + + + + + setAddres(e.target.value)} /> + + + + + + + setNohp(e.target.value)} /> + + + + + setGender(e.target.value)}> + + + + + + + + + setBirthdayplace(e.target.value)} /> + + + + + setBirthdaydate(date)} /> + + + + +
+ ) + } + + const renderFormAccount = () => { + return ( +
+ + + + + setUserName(e.target.value)} /> + + + + + + setEmail(e.target.value)} /> + + + + + + setOldPassword(e.target.value)} /> + + + + + setNewPassword(e.target.value)} /> + + + + + setNewPasswordConfirm(e.target.value)} /> + + + +
+ ) + } + + return ( + <> + + + Update {typeDialog == "Personal" ? `Personal` : "Account"} Data + + + + + + {renderForm()} + + + {renderFormAccount()} + + + + + {' '} + + + + + ) + + + +} + +export default DialogForm; diff --git a/src/views/SimproV2/Profile/index.js b/src/views/SimproV2/Profile/index.js new file mode 100644 index 0000000..04dfa44 --- /dev/null +++ b/src/views/SimproV2/Profile/index.js @@ -0,0 +1,260 @@ +import * as XLSX from 'xlsx'; +import React, { useState, useEffect, useMemo } from 'react'; +import SweetAlert from 'react-bootstrap-sweetalert'; +import axios from "../../../const/interceptorApi" +import { Card, CardBody, CardHeader, Col, Row, Input, Table, Button } from 'reactstrap'; +import { NotificationContainer, NotificationManager } from 'react-notifications'; +import { Pagination, Tooltip } from 'antd'; +import { USER_EDIT, SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE, SATUAN_SEARCH } from '../../../const/ApiConst'; +import profile from '../../../assets/img/profile.png' +import DialogForm from './DialogForm' +import { ROLE_SEARCH, BASE_OSPRO } from '../../../const/ApiConst' + + + + +const Profile = ({ params }) => { + const token = localStorage.getItem("token") + const config = { + headers: { + "Content-Type": "application/json", + "Authorization": `Bearer ${token}` + } + } + + const pageName = params.name; + + + + + const [openDialog, setOpenDialog] = useState(false) + const [typeDialog, setTypeDialog] = useState('Personal') + const [id, setId] = useState(0) + const [roleList, setRoleList] = useState([]) + const [userProfile, setUserprofile] = useState(null) + const [userName, setUserName] = useState("") + const [name, setName] = useState('') + const [noHp, setNohp] = useState("") + const [gender, setGender] = useState("") + const [address, setAddres] = useState("") + const [birthdayPlace, setBirthdayplace] = useState("") + const [birthdayDate, setBirthdaydate] = useState("") + const [idNumber, setIdnumber] = useState("") + const [divisi, setDivisi] = useState("") + const [role, setRole] = useState("") + const [email, setEmail] = useState("") + const [employeeType, setEmployeeType] = useState("") + + useEffect(() => { + getDataProfileUser(); + getRoleList() + }, []) + + useEffect(() => { + if (userProfile && userProfile != {}) { + setId(userProfile?.id) + setUserName(userProfile?.username); + setName(userProfile?.name); + setEmail(userProfile?.email); + setNohp(userProfile?.phone_number); + setAddres(userProfile?.address); + setIdnumber(userProfile?.ktp_number); + setGender(userProfile?.gender); + setDivisi(userProfile?.divisi_id); + setRole(userProfile?.role_id); + setBirthdayplace(userProfile?.birth_place); + setBirthdaydate(userProfile?.birth_date); + setEmployeeType(userProfile?.employee_type); + + } + }, [userProfile]) + + const handleOpenDialog = (type) => { + setOpenDialog(true) + setTypeDialog(type) + } + + const handleCloseDialog = (type, data) => { + if (type === "profile") { + saveProfile(data); + } + setOpenDialog(false) + } + + const saveProfile = async (data) => { + + let urlEdit = USER_EDIT(id) + const formData = data + + const result = await axios.put(urlEdit, formData, config) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code === 200) { + getDataProfileUser(); + NotificationManager.success(`Data resource berhasil diedit`, 'Success!!'); + } else { + NotificationManager.error(`Data resource gagal di edit`, `Failed!!`); + } + } + + const toggleAddDialog = () => { + setOpenDialog(!openDialog) + } + + const getRoleList = async () => { + const formData = { + "paging": { "start": 0, "length": -1 }, + "orders": { "columns": ["id"], "ascending": false } + } + + const result = await axios + .post(ROLE_SEARCH, formData, config) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code == 200) { + setRoleList(result.data.data); + } + } + + const getDataProfileUser = async () => { + const id = localStorage.getItem("user_id") + + const url = `${BASE_OSPRO}/api/human-resource/edit/${id}` + // const payload = { + // columns: [ + // { + // name: "name", + // logic_operator: "ilike", + // value: 'admin', + // operator: "AND", + // }, + // ], + // joins: [ + // { + // name: "m_divisi", + // column_join: "id", + // column_results: ["name"], + // }, + // ] + // }; + + const result = await axios + .get(url, config) + .then((res) => res) + .catch((error) => error.response); + console.log(result); + if (result && result.data && result.data.code == 200) { + let dataRes = result.data.data; + setUserprofile(dataRes); + } else { + NotificationManager.error("Gagal Mengambil Data!!", "Failed"); + } + }; + + + + return ( +
+ + toggleAddDialog} + typeDialogProp={typeDialog} + roleList={roleList} + nameProp={name} + noHpProp={noHp} + idNumberProp={idNumber} + genderProp={gender} + divisiProp={divisi} + birthdayPlaceProp={birthdayPlace} + birthdayDateProp={birthdayDate} + addressProp={address} + emailProp={email} + userNameProp={userName} + /> + + + + + + + + + + + + + + + + Profile Setting + + + + + + Nama   + :  {name} + + + Username   + :  {userName} + + + Email   + :  {email} + + + + Password     + :  ********** + + + + Nomor Handphone   + :   {noHp} + + + Alamat   + :   {address} + + + ID Number   + :   {idNumber} + + + Gender   + :   {gender} + + + Divisi   + :   {divisi} + + + Employee Type   + :   {employeeType} + + + Role   + :   {role} + + + Tempat Lahir   + :   {birthdayPlace} + + + Tanggal Lahir   + :   {birthdayDate} + + +
+ +
+
+ ) +} + +export default Profile;