From 6956594de79e5ad1f3046b1ac9ec53924428deca Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Fri, 19 Aug 2022 14:27:02 +0700 Subject: [PATCH] update --- src/const/ApiConst.js | 3 +- src/views/DashboardPMOV1/tableDashboardv1.js | 134 +++++++++++++------ 2 files changed, 92 insertions(+), 45 deletions(-) diff --git a/src/const/ApiConst.js b/src/const/ApiConst.js index c976f9e..6d05478 100644 --- a/src/const/ApiConst.js +++ b/src/const/ApiConst.js @@ -126,8 +126,7 @@ switch (APP_MODE) { break; case 'ADW': - // BASE_OSPRO = "https://ospro-api.ospro.id" - BASE_OSPRO = "https://api-staging-adw.ospro.id" + BASE_OSPRO = "https://adw-api.ospro.id" BASE_SIMPRO_LUMEN = `${BASE_OSPRO}/api`; BASE_SIMPRO_LUMEN_IMAGE = `${BASE_OSPRO}/assets/image`; diff --git a/src/views/DashboardPMOV1/tableDashboardv1.js b/src/views/DashboardPMOV1/tableDashboardv1.js index dd53fd2..914549a 100644 --- a/src/views/DashboardPMOV1/tableDashboardv1.js +++ b/src/views/DashboardPMOV1/tableDashboardv1.js @@ -29,12 +29,13 @@ const TableDashboardV1 = () => { } const [MANPOWERS, SET_MANPOWERS] = useState(0) + const [MAXPLANNEDCOST, SET_MAXPLANNEDCOST] = useState(0) + const [MAXACTUALCOST, SET_MAXACTUALCOST] = useState(0) + const [MAXCOSTVARIANCE, SET_MAXCOSTVARIANCE] = useState(0) const [dataTable, setDataTable] = useState([]) const [searchText, setSearchText] = useState('') const [searchedColumn, setSearchedColumn] = useState('') const searchInput = useRef(null) - const [maxSlider, setMaxSlider] = useState(MANPOWERS) - //const [sliderValue, setSliderValue] = useState([]); const handleSearch = (selectedKeys, confirm, dataIndex) => { confirm() @@ -46,12 +47,8 @@ const TableDashboardV1 = () => { confirm({ closeDropdown: false }); }; - const slider = (dataIndex) => ({ + const slider = (dataIndex, maxSlider) => ({ filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => { - if(dataIndex == 'manpower'){ - setMaxSlider(MANPOWERS) - } - return (
{ range={true} min={0} max={maxSlider} + defaultValue={[0, maxSlider]} onAfterChange={(value) => { setSelectedKeys([value]) handleSlide(dataIndex, value, confirm)} @@ -82,40 +80,10 @@ const TableDashboardV1 = () => {
Max:
-
{maxSlider}
+
{dataIndex == 'manpower' || dataIndex == 'progress' ? maxSlider : formatRibuanDecimal(maxSlider)}
- {/* - - { - setSelectedKeys([value]) - handleSlide(dataIndex, value, confirm)} - } - /> - - */} - {/* - - { - console.log(value) - setSelectedKeys([value]) - handleSlide(dataIndex, value, confirm)} - } - /> - - */} )}, onFilter: (value, record) => { @@ -203,7 +171,7 @@ const TableDashboardV1 = () => { setTimeout(() => searchInput.current?.select(), 100); } }, - render: (text) => + render: (text, record) => searchedColumn === dataIndex ? ( { textToHighlight={text ? text.toString() : ''} /> ) : ( - text + <> + + {record.kode_sortname}
{text} + + ), }); + + const filterDate = (dataIndex) => ({ + filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => { + return ( +
+ setSelectedKeys(e.target.value ? [e.target.value] : [])} + onChange={(e) => console.log(e)} + style={{ + marginBottom: 8, + display: 'block', + }} + /> + + + + + +
+ )}, + onFilter: (value, record) => { + return record[dataIndex].toString().toLowerCase().includes(value.toLowerCase()) + }, + onFilterDropdownVisibleChange: (visible) => { + if (visible) { + setTimeout(() => searchInput.current?.select(), 100); + } + } + }); + const getProjects = async () => { const URL = `${BASE_OSPRO}/api/project/list` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) @@ -226,6 +266,9 @@ const TableDashboardV1 = () => { if (result.data.code == 200) { setDataTable(result.data.data); result.data.manpowers != undefined ? SET_MANPOWERS(result.data.manpowers) : SET_MANPOWERS(0) + SET_MAXPLANNEDCOST(Math.max(...result.data.data.map(o => o.plannedCost))) + SET_MAXACTUALCOST(Math.max(...result.data.data.map(o => o.actualCost))) + SET_MAXCOSTVARIANCE(Math.max(...result.data.data.map(o => o.costVariance))) } } @@ -251,6 +294,7 @@ const TableDashboardV1 = () => { title: 'Planned Interval', dataIndex: 'plannedInterval', key: 'plannedInterval', + ...filterDate('plannedInterval'), }, { title: 'Manpower', @@ -259,26 +303,29 @@ const TableDashboardV1 = () => { render: (text) => { return `${text}/${MANPOWERS}` }, - ...slider('manpower') + ...slider('manpower', MANPOWERS) }, { title: 'Budget Project', dataIndex: 'plannedCost', key: 'plannedCost', render: (text) => {formatRibuanDecimal(text)}, - filterDropdown: slider + ...slider('plannedCost', MAXPLANNEDCOST) }, { title: 'Actual Cost', dataIndex: 'actualCost', key: 'actualCost', render: (text) => {formatRibuanDecimal(text)}, + ...slider('actualCost', MAXACTUALCOST) + }, { title: 'Cost Variance', dataIndex: 'costVariance', key: 'costVariance', render: (text) => {formatRibuanDecimal(text)}, + ...slider('costVariance', MAXCOSTVARIANCE) }, { title: 'Cost Health', @@ -302,7 +349,8 @@ const TableDashboardV1 = () => { key: 'progress', render: (text) => { return 74 ? 'success' : text > 49 ? 'warning' : 'danger'}>{text}% - } + }, + ...slider('progress', 100) }, ];