diff --git a/src/views/DashboardPMOV1/tableDashboardv1.js b/src/views/DashboardPMOV1/tableDashboardv1.js index 4f0e641..dd53fd2 100644 --- a/src/views/DashboardPMOV1/tableDashboardv1.js +++ b/src/views/DashboardPMOV1/tableDashboardv1.js @@ -4,13 +4,15 @@ import './../DashboardPMO/Dashboard.css'; import { BASE_OSPRO } from '../../const/ApiConst'; import React, { useEffect, useState, useRef } from 'react'; import axios from 'axios' -import { Table, Row, Col, Button, Input, Space } from 'antd'; +import { Table, Row, Col, Button, Input, InputNumber, Space } from 'antd'; import { formatRibuanDecimal } from '../../const/CustomFunc.js'; import { Badge } from 'reactstrap'; import { Link } from "react-router-dom"; import { SearchOutlined } from '@ant-design/icons'; import Highlighter from 'react-highlight-words'; import _ from "lodash"; +import Slider from "antd/lib/slider"; +import numeral from "numeral"; const filterData = data => formatter => data.map(item => ({ text: formatter(item), @@ -28,23 +30,112 @@ const TableDashboardV1 = () => { const [MANPOWERS, SET_MANPOWERS] = useState(0) const [dataTable, setDataTable] = useState([]) - const [searchText, setSearchText] = useState(''); - const [searchedColumn, setSearchedColumn] = useState(''); - const searchInput = useRef(null); + 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(); - setSearchText(selectedKeys[0]); - setSearchedColumn(dataIndex); + confirm() + setSearchText(selectedKeys[0]) + setSearchedColumn(dataIndex) }; + const handleSlide = (dataIndex, value, confirm) => { + confirm({ closeDropdown: false }); + }; + + const slider = (dataIndex) => ({ + filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => { + if(dataIndex == 'manpower'){ + setMaxSlider(MANPOWERS) + } + + return ( +
+ + +
+
+ Min: +
+
0
+
+ + + { + setSelectedKeys([value]) + handleSlide(dataIndex, value, confirm)} + } + /> + + +
+
+ Max: +
+
{maxSlider}
+
+ +
+ {/* + + { + setSelectedKeys([value]) + handleSlide(dataIndex, value, confirm)} + } + /> + + */} + {/* + + { + console.log(value) + setSelectedKeys([value]) + handleSlide(dataIndex, value, confirm)} + } + /> + + */} +
+ )}, + onFilter: (value, record) => { + return (record[dataIndex] >= value[0] && record[dataIndex] <= value[1]) + }, + onFilterDropdownVisibleChange: (visible) => { + if (visible) { + setTimeout(() => searchInput.current?.select(), 100); + } + }, + }); + const handleReset = (clearFilters) => { clearFilters(); setSearchText(''); }; const getColumnSearchProps = (dataIndex) => ({ - filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => ( + filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => { + return (
{
- ), + )}, filterIcon: (filtered) => ( { }} /> ), - onFilter: (value, record) => - record[dataIndex].toString().toLowerCase().includes(value.toLowerCase()), + onFilter: (value, record) => { + return record[dataIndex].toString().toLowerCase().includes(value.toLowerCase()) + }, onFilterDropdownVisibleChange: (visible) => { if (visible) { setTimeout(() => searchInput.current?.select(), 100); @@ -163,15 +255,18 @@ const TableDashboardV1 = () => { { title: 'Manpower', dataIndex: 'manpower', + key: 'manpower', render: (text) => { return `${text}/${MANPOWERS}` - } + }, + ...slider('manpower') }, { title: 'Budget Project', dataIndex: 'plannedCost', key: 'plannedCost', render: (text) => {formatRibuanDecimal(text)}, + filterDropdown: slider }, { title: 'Actual Cost', @@ -220,7 +315,10 @@ const TableDashboardV1 = () => { <> - +