diff --git a/src/views/Dashboard/DashboardProject.js b/src/views/Dashboard/DashboardProject.js index ac105d5..cabac62 100644 --- a/src/views/Dashboard/DashboardProject.js +++ b/src/views/Dashboard/DashboardProject.js @@ -268,7 +268,13 @@ const DashboardProject = () => { const getProjectDetail = async () => { setIsReadyProjectDetail(false); - const URL = `${BASE_OSPRO}/api/project/detail/${PROJECT_ID}`; + let URL = `${BASE_OSPRO}/api/project/detail/${PROJECT_ID}`; + if (GANTT_ID) { + URL = `${BASE_OSPRO}/api/project/detail/${PROJECT_ID}/${GANTT_ID}`; + } + if (SCURVE) { + URL = `${BASE_OSPRO}/api/project/detail/${PROJECT_ID}/${GANTT_ID}/${SCURVE}`; + } const result = await axios .get(URL, HEADER) .then((res) => res) @@ -298,10 +304,22 @@ const DashboardProject = () => { result.data.data.company ? result.data.data.company : "-" ); setPlannedStart( - result.data.data?.mulai_proyek ? result.data.data.mulai_proyek : null + SCURVE + ? result.data.data.mulai_proyek + ? result.data.data.mulai_proyek + : null + : result.data.data.header?.planned_start + ? result.data.data.header?.planned_start + : null ); setPlannedFinish( - result.data.data?.akhir_proyek ? result.data.data.akhir_proyek : null + SCURVE + ? result.data.data.akhir_proyek + ? result.data.data.akhir_proyek + : null + : result.data.data.header?.planned_end + ? result.data.data.header?.planned_end + : null ); setActualStart( result.data.data.header?.start_date diff --git a/src/views/Master/ConfigAlert/DialogForm.js b/src/views/Master/ConfigAlert/DialogForm.js index dfbd43b..d5d6081 100644 --- a/src/views/Master/ConfigAlert/DialogForm.js +++ b/src/views/Master/ConfigAlert/DialogForm.js @@ -1,99 +1,99 @@ -import React, { useEffect, useState } from 'react' -import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; -import { Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap'; -import { Select } from 'antd'; -import moment from 'moment'; -import 'antd/dist/antd.css'; - -const { Option } = Select - -const DialogForm = ({openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataMenu}) => { - const [id, setId] = useState(0) - const [name, setName] = useState('') - const [descripton, setDescription] = useState('') - const [status, setStatus] = useState('') - - - useEffect(()=> { - if(typeDialog==="Edit"){ - console.log("data edit", dataEdit) - setId(dataEdit.id) - setName(dataEdit.nama) - setDescription(dataEdit.keterangan) - setStatus(dataEdit.status) - }else{ - setId(0) - setName('') - setDescription('') - setStatus('') - } - },[dataEdit,openDialog]) - - const handleSave = () => { - let data = ''; - if(typeDialog==="Save"){ - data = { - nama:name, - keterangan:descripton, - status - } - - closeDialog('save', data); - }else{ - data = { - id, - nama:name, - keterangan:descripton, - status - } - - - closeDialog('edit', data); - } - } - - const handleCancel = () => { - closeDialog('cancel', 'none') - setId(0) - setName('') - setDescription('') - setStatus('') - } - - - const renderForm = () => { - return( -
- - - setName(e.target.value)} placeholder={`Waspang tidak sesuai target..`}/> - - - - setDescription(e.target.value)} placeholder={`Rencana vs actual tidak sesuai..`} /> - - - - setStatus(e.target.value)} placeholder={`Warning..`} /> - -
- ) - } - - - return ( - - {typeDialog=="Save" ? `Tambah` : "Edit"} Config Alert - - {renderForm()} - - - {' '} - - - - ) - -} - -export default DialogForm; \ No newline at end of file +import React, { useEffect, useState } from 'react' +import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; +import { Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap'; +import { Select } from 'antd'; +import moment from 'moment'; +import 'antd/dist/antd.css'; + +const { Option } = Select + +const DialogForm = ({openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataMenu}) => { + const [id, setId] = useState(0) + const [name, setName] = useState('') + const [descripton, setDescription] = useState('') + const [status, setStatus] = useState('') + + + useEffect(()=> { + if(typeDialog==="Edit"){ + console.log("data edit", dataEdit) + setId(dataEdit.id) + setName(dataEdit.nama) + setDescription(dataEdit.keterangan) + setStatus(dataEdit.status) + }else{ + setId(0) + setName('') + setDescription('') + setStatus('') + } + },[dataEdit,openDialog]) + + const handleSave = () => { + let data = ''; + if(typeDialog==="Save"){ + data = { + nama:name, + keterangan:descripton, + status + } + + closeDialog('save', data); + }else{ + data = { + id, + nama:name, + keterangan:descripton, + status + } + + + closeDialog('edit', data); + } + } + + const handleCancel = () => { + closeDialog('cancel', 'none') + setId(0) + setName('') + setDescription('') + setStatus('') + } + + + const renderForm = () => { + return( +
+ + + setName(e.target.value)} placeholder={`Waspang tidak sesuai target..`}/> + + + + setDescription(e.target.value)} placeholder={`Rencana vs actual tidak sesuai..`} /> + + + + setStatus(e.target.value)} placeholder={`Warning..`} /> + +
+ ) + } + + + return ( + + {typeDialog=="Save" ? `Tambah` : "Edit"} Config Alert + + {renderForm()} + + + {' '} + + + + ) + +} + +export default DialogForm; diff --git a/src/views/Master/ConfigAlert/index.js b/src/views/Master/ConfigAlert/index.js index 10a4505..02e13b8 100644 --- a/src/views/Master/ConfigAlert/index.js +++ b/src/views/Master/ConfigAlert/index.js @@ -1,172 +1,172 @@ -import Bell from '@iconify/icons-ion/notifications-outline'; -import BellOff from '@iconify/icons-ion/notifications-off-outline'; -import React, { useState, useEffect } from 'react'; -import axios from 'axios'; -import { CALERTUSER_SEARCH,CONFIGALERT_SEARCH,CALERTUSER_DELETE, CALERTUSER_ADD } from '../../../const/ApiConst.js'; -import { Card as ACard,Row, Col, Switch } from 'antd'; -import { Card, CardBody, CardHeader, Input } from 'reactstrap'; -import { Icon } from '@iconify/react'; -import { NotificationContainer, NotificationManager } from 'react-notifications'; - -const token = window.localStorage.getItem('token'); -const userID = window.localStorage.getItem('user_id'); - -const Index = ({params}) => { - - const [alertUser, setAlertUser] = useState([]) - const [checked, setChecked] = useState({}) - const [dataTable, setDatatable] = useState([]) - const [onSetSwitch, setOnSetSwitch] = useState(false) - const pageName = params.name; - - const config = { - headers: - { - Authorization : `Bearer ${token}`, - "Content-type" : `application/json` - } - }; - - useEffect(()=> { - getDataConfigAlert(); - },[]) - - useEffect(() => { - getDataConfigAlertUser(); - },[dataTable]) - - const getDataConfigAlert = async () => { - const payload = { - "paging": {"start": 0, "length": -1}, - "columns": [ - {"name": "nama", "logic_operator": "ilike", "value": "", "operator": "AND"} - ], - "joins": [], - "orders": {"columns": ["id"], "ascending": false} - } - - const result = await axios - .post(CONFIGALERT_SEARCH, payload, config) - .then(res => res) - .catch((error) => error.response); - - if(result && result.data && result.data.code == 200){ - let resData = result.data.data - let checkedAlert = {} - resData.map((val, index) => { - checkedAlert[val.id] = false - }); - setChecked(checkedAlert); - setDatatable(resData); - }else{ - NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); - } - } - - const getDataConfigAlertUser = async () => { - const payload = { - "paging": {"start": 0, "length": -1}, - "columns": [ - {"name": "user_id", "logic_operator": "=", "value": localStorage.getItem('user_id'), "operator": "AND"} - ], - "joins": [], - "orders": {"columns": ["id"], "ascending": false} - } - - const result = await axios - .post(CALERTUSER_SEARCH, payload, config) - .then(res => res) - .catch((error) => error.response); - - if(result && result.data && result.data.code == 200){ - let resData = result.data.data - let configAlert = []; - resData.map((val, index) => { - configAlert.push(val.config_alert_id); - let indexRes = dataTable.findIndex(x => x.id === val.config_alert_id); - if(indexRes >= 0){ - let id = dataTable[indexRes].id; - let tempChecked = checked; - tempChecked[id] = true; - setChecked(tempChecked); - } - }); - window.localStorage.setItem('userConfigAlert', configAlert.join()); - setOnSetSwitch(false) - setAlertUser(result.data.data); - }else{ - NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); - } - } - - const onChange = (checked, id) => { - setOnSetSwitch(true) - if(checked){ - addConfigAlertUser(id); - }else{ - setDeleteConfigAlertUser(id) - } - } - - const addConfigAlertUser = async (id) => { - const formData = { - "user_id":parseInt(localStorage.getItem('user_id')), - "config_alert_id":id - } - - const result = await axios.post(CALERTUSER_ADD, formData, config) - .then(res => res) - .catch((error) => error.response); - - if(result && result.data && result.data.code===200){ - getDataConfigAlertUser(); - } - } - - const setDeleteConfigAlertUser = async (id) => { - let indexCek = alertUser.findIndex(x => x.user_id === parseInt(localStorage.getItem('user_id')) && x.config_alert_id === id); - if(indexCek >= 0){ - let idAlert = alertUser[indexCek].id - deleteConfigAlertUser(idAlert) - } - } - - const deleteConfigAlertUser = async (id) => { - const url = CALERTUSER_DELETE(id) - const result = await axios.delete(url, config) - .then(res => res) - .catch((error) => error.response); - if (result && result.data && result.data.code === 200) { - getDataConfigAlert(); - } - } - - return ( -
- - - -

{pageName}

-
- - - {dataTable.map((val, index) => ( - - onChange(checked, val.id)} disabled={onSetSwitch} />, - ]}> -
- -

{val.nama}

-
-
- - ))} -
-
-
-
- ) -} - -export default Index; +import Bell from '@iconify/icons-ion/notifications-outline'; +import BellOff from '@iconify/icons-ion/notifications-off-outline'; +import React, { useState, useEffect } from 'react'; +import axios from 'axios'; +import { CALERTUSER_SEARCH,CONFIGALERT_SEARCH,CALERTUSER_DELETE, CALERTUSER_ADD } from '../../../const/ApiConst.js'; +import { Card as ACard,Row, Col, Switch } from 'antd'; +import { Card, CardBody, CardHeader, Input } from 'reactstrap'; +import { Icon } from '@iconify/react'; +import { NotificationContainer, NotificationManager } from 'react-notifications'; + +const token = window.localStorage.getItem('token'); +const userID = window.localStorage.getItem('user_id'); + +const Index = ({params}) => { + + const [alertUser, setAlertUser] = useState([]) + const [checked, setChecked] = useState({}) + const [dataTable, setDatatable] = useState([]) + const [onSetSwitch, setOnSetSwitch] = useState(false) + const pageName = params.name; + + const config = { + headers: + { + Authorization : `Bearer ${token}`, + "Content-type" : `application/json` + } + }; + + useEffect(()=> { + getDataConfigAlert(); + },[]) + + useEffect(() => { + getDataConfigAlertUser(); + },[dataTable]) + + const getDataConfigAlert = async () => { + const payload = { + "paging": {"start": 0, "length": -1}, + "columns": [ + {"name": "nama", "logic_operator": "ilike", "value": "", "operator": "AND"} + ], + "joins": [], + "orders": {"columns": ["id"], "ascending": false} + } + + const result = await axios + .post(CONFIGALERT_SEARCH, payload, config) + .then(res => res) + .catch((error) => error.response); + + if(result && result.data && result.data.code == 200){ + let resData = result.data.data + let checkedAlert = {} + resData.map((val, index) => { + checkedAlert[val.id] = false + }); + setChecked(checkedAlert); + setDatatable(resData); + }else{ + NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); + } + } + + const getDataConfigAlertUser = async () => { + const payload = { + "paging": {"start": 0, "length": -1}, + "columns": [ + {"name": "user_id", "logic_operator": "=", "value": localStorage.getItem('user_id'), "operator": "AND"} + ], + "joins": [], + "orders": {"columns": ["id"], "ascending": false} + } + + const result = await axios + .post(CALERTUSER_SEARCH, payload, config) + .then(res => res) + .catch((error) => error.response); + + if(result && result.data && result.data.code == 200){ + let resData = result.data.data + let configAlert = []; + resData.map((val, index) => { + configAlert.push(val.config_alert_id); + let indexRes = dataTable.findIndex(x => x.id === val.config_alert_id); + if(indexRes >= 0){ + let id = dataTable[indexRes].id; + let tempChecked = checked; + tempChecked[id] = true; + setChecked(tempChecked); + } + }); + window.localStorage.setItem('userConfigAlert', configAlert.join()); + setOnSetSwitch(false) + setAlertUser(result.data.data); + }else{ + NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); + } + } + + const onChange = (checked, id) => { + setOnSetSwitch(true) + if(checked){ + addConfigAlertUser(id); + }else{ + setDeleteConfigAlertUser(id) + } + } + + const addConfigAlertUser = async (id) => { + const formData = { + "user_id":parseInt(localStorage.getItem('user_id')), + "config_alert_id":id + } + + const result = await axios.post(CALERTUSER_ADD, formData, config) + .then(res => res) + .catch((error) => error.response); + + if(result && result.data && result.data.code===200){ + getDataConfigAlertUser(); + } + } + + const setDeleteConfigAlertUser = async (id) => { + let indexCek = alertUser.findIndex(x => x.user_id === parseInt(localStorage.getItem('user_id')) && x.config_alert_id === id); + if(indexCek >= 0){ + let idAlert = alertUser[indexCek].id + deleteConfigAlertUser(idAlert) + } + } + + const deleteConfigAlertUser = async (id) => { + const url = CALERTUSER_DELETE(id) + const result = await axios.delete(url, config) + .then(res => res) + .catch((error) => error.response); + if (result && result.data && result.data.code === 200) { + getDataConfigAlert(); + } + } + + return ( +
+ + + +

{pageName}

+
+ + + {dataTable.map((val, index) => ( + + onChange(checked, val.id)} disabled={onSetSwitch} />, + ]}> +
+ +

{val.nama}

+
+
+ + ))} +
+
+
+
+ ) +} + +export default Index; diff --git a/src/views/SimproV2/CreatedProyek/index.js b/src/views/SimproV2/CreatedProyek/index.js index 13f0adf..aa85b54 100644 --- a/src/views/SimproV2/CreatedProyek/index.js +++ b/src/views/SimproV2/CreatedProyek/index.js @@ -282,7 +282,7 @@ const CreatedProyek = ({ params, ...props }) => { return; } else if (result.status == 200 && result.data.data) { history.push( - `dashboard-customer/${text.id}/${result.data.gantt.last_gantt_id}/1` + `dashboard-customer/${text.id}/${result.data.gantt}/1` ); } }; @@ -558,7 +558,7 @@ const CreatedProyek = ({ params, ...props }) => { return; } else if (result.status == 200 && result.data.data) { history.push( - `/dashboard-project/${id}/${result.data.gantt.last_gantt_id}/1` + `/dashboard-project/${id}/${result.data.gantt}/1` ); } }; @@ -1490,12 +1490,16 @@ const CreatedProyek = ({ params, ...props }) => { Request Tools */} {/* */} + { + /*text.type_proyek_id != 9 ?*/
handleOpenDialogGantt(text)}> Gantt
+ /*: null*/ + }
handleSCurve(text)}>