diff --git a/frontend/client-portal/src/pages/Dashboard/Dashboard.tsx b/frontend/client-portal/src/pages/Dashboard/Dashboard.tsx index 17937595..abbfdfe7 100755 --- a/frontend/client-portal/src/pages/Dashboard/Dashboard.tsx +++ b/frontend/client-portal/src/pages/Dashboard/Dashboard.tsx @@ -23,23 +23,6 @@ const itemList = [ export default function Dashboard() { const { themeStretch } = useSettings(); - // const [corporate, setCorporate] = useState({}); - - // const loadSomething = () => { - // axios - // .get('dashboard') - // .then((res) => { - // setCorporate(res.data.corporate); - // }) - // .catch((err) => { - // alert('Opps, Something Went Wrong when collecting dashboard data'); - // }); - // }; - - // useEffect(() => { - // loadSomething(); - // }, []); - return ( @@ -48,10 +31,10 @@ export default function Dashboard() { - + - + diff --git a/frontend/client-portal/src/pages/Dashboard/List.tsx b/frontend/client-portal/src/pages/Dashboard/List.tsx deleted file mode 100644 index dabb387b..00000000 --- a/frontend/client-portal/src/pages/Dashboard/List.tsx +++ /dev/null @@ -1,373 +0,0 @@ -// @mui -import { - Box, - Button, - Card, - Collapse, - IconButton, - InputLabel, - MenuItem, - OutlinedInput, - Paper, - Select, - SelectChangeEvent, - Table, - TableBody, - TableCell, - TableContainer, - TableHead, - TableRow, - TextField, - Typography, - Badge, - Tab, - Tabs, - CardHeader, - Stack, - Menu, - ButtonGroup, - Pagination, - Grid, - Autocomplete, -} from '@mui/material'; -import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; -import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight'; -import AddIcon from '@mui/icons-material/Add'; -import UploadIcon from '@mui/icons-material/Upload'; -import CancelIcon from '@mui/icons-material/Cancel'; -// hooks -import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react'; -import useSettings from '../../hooks/useSettings'; -import { useNavigate, useParams, useSearchParams } from 'react-router-dom'; -// components -import axios from '../../utils/axios'; -import { LaravelPaginatedData } from '../../@types/paginated-data'; -import { Icd } from '../../@types/diagnosis'; -import BasePagination from '../../components/BasePagination'; -import { Member } from '../../@types/member'; -import Iconify from '../../components/Iconify'; - -const options = [ - { label: 'The Shawshank Redemption', value: 1994 }, - { label: 'The Godfather', year: 1972 }, - { label: 'The Godfather: Part II', year: 1974 }, - { label: 'The Dark Knight', year: 2008 }, - { label: '12 Angry Men', year: 1957 }, - { label: "Schindler's List", year: 1993 }, - { label: 'Pulp Fiction', year: 1994 }, -]; - -export default function List() { - const navigate = useNavigate(); - const { themeStretch } = useSettings(); - const { corporate_id } = useParams(); - const [searchParams, setSearchParams] = useSearchParams(); - const [importResult, setImportResult] = useState(null); - - function SearchInput(props: any) { - // SEARCH - const searchInput = useRef(null); - const [searchText, setSearchText] = useState(''); - - const [value, setValue] = useState(options[0]); - const [inputValue, setInputValue] = useState(''); - - const handleSearchChange = (event: any) => { - const newSearchText = event.target.value ?? ''; - setSearchText(newSearchText); - }; - - const handleSearchSubmit = (event: any) => { - event.preventDefault(); - props.onSearch(searchText); // Trigger to Parent - }; - - useEffect(() => { - // Trigger First Search - setSearchText(searchParams.get('search') ?? ''); - console.log(value, inputValue); - }, [searchParams, value, inputValue]); - - return ( -
- - { - setValue(newValue); - }} - inputValue={inputValue} - onInputChange={(event, newInputValue) => { - setInputValue(newInputValue); - }} - id="controllable-states-demo" - options={options} - sx={{ width: 300 }} - renderInput={(params) => } - /> - - -
- ); - } - - function ImportForm(props: any) { - // IMPORT - // Create Button Menu - const [anchorEl, setAnchorEl] = React.useState(null); - const createMenu = Boolean(anchorEl); - const importForm = useRef(null); - const [currentImportFileName, setCurrentImportFileName] = useState(null); - - const handleClick = (event: React.MouseEvent) => { - setAnchorEl(event.currentTarget); - }; - - const handleClose = () => { - setAnchorEl(null); - }; - - const handleImportButton = () => { - if (importForm?.current) { - handleClose(); - importForm.current ? importForm.current.click() : console.log('No File selected'); - } else { - alert('No file selected'); - } - }; - - const handleCancelImportButton = () => { - importForm.current.value = ''; - importForm.current.dispatchEvent(new Event('change', { bubbles: true })); - }; - - const handleImportChange = (event: any) => { - if (event.target.files[0]) { - setCurrentImportFileName(event.target.files[0].name); - } else { - setCurrentImportFileName(null); - } - }; - - const handleUpload = () => { - if (importForm.current?.files.length) { - const formData = new FormData(); - formData.append('file', importForm.current?.files[0]); - axios - .post(`master/formularium/import`, formData) - .then((response) => { - handleCancelImportButton(); - loadDataTableData(); - setImportResult(response.data); - // alert('Succesfully read '+ response.data.total_successed_row + ' with ' + response.data.total_failed_row + ' failed rows'); - }) - .catch((response) => { - alert( - 'Looks like something went wrong. Please check your data and try again. ' + - response.message - ); - }); - } else { - alert('No File Selected'); - } - }; - - return ( - - - - - - ); - } - - // Called on every row to map the data to the columns - function createData(member: Member): Member { - return { - ...member, - }; - } - - // Generate the every row of the table - function Row(props: { row: ReturnType }) { - const { row } = props; - const [open, setOpen] = React.useState(true); - - return ( - - *': { borderBottom: 'unset' } }}> - - setOpen(!open)}> - {open ? : } - - - {row.member_id} - {row.payor_id} - {row.name} - {row.nik} - {row.nric} - - - - - {/* */} - - {/* COLLAPSIBLE ROW */} - - - - - - - - - - - - - ); - } - - // Dummy Default Data - const [dataTableIsLoading, setDataTableLoading] = useState(true); - const [dataTableLastRequest, setDataTableLastRequest] = useState(0); - const [dataTableResponseState, setDataTableResponseState] = useState('idle'); - const [dataTableData, setDataTableData] = useState({ - current_page: 1, - data: [], - path: '', - first_page_url: '', - last_page: 1, - last_page_url: '', - next_page_url: '', - prev_page_url: '', - per_page: 10, - from: 0, - to: 0, - total: 0, - }); - const [dataTablePage, setDataTablePage] = useState(5); - - const loadDataTableData = async (appliedFilter: any | null = null) => { - setDataTableLoading(true); - const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]); - const response = await axios.get('/members', { params: filter }); - - setDataTableData(response.data.members); - setDataTableLoading(false); - }; - - const headStyle = { - fontWeight: 'bold', - }; - - const applyFilter = async (searchFilter: string) => { - await loadDataTableData({ search: searchFilter }); - setSearchParams({ search: searchFilter }); - }; - - const handlePageChange = (event: ChangeEvent, value: number) => { - const filter = Object.fromEntries([...searchParams.entries(), ['page', value]]); - loadDataTableData(filter); - setSearchParams(filter); - }; - - useEffect(() => { - loadDataTableData(); - }, []); - - return ( - - - - - {/* The Main Table */} - - - - - - Member ID - - - Name - - - Divisi - - - Limit - - - Status - - - {' '} - - - - {dataTableIsLoading ? ( - - - - Loading - - - - ) : dataTableData.data.length === 0 ? ( - - - - No Data - - - - ) : ( - - {dataTableData.data.map((row) => ( - - ))} - - )} -
-
- - -
-
- ); -} diff --git a/frontend/client-portal/src/sections/dashboard/TableList.tsx b/frontend/client-portal/src/sections/dashboard/TableList.tsx index c1100464..6364a6b1 100755 --- a/frontend/client-portal/src/sections/dashboard/TableList.tsx +++ b/frontend/client-portal/src/sections/dashboard/TableList.tsx @@ -14,12 +14,14 @@ import { IconButton, Card, Grid, + Autocomplete, } from '@mui/material'; import { visuallyHidden } from '@mui/utils'; +import { Add as AddIcon } from '@mui/icons-material'; /* ---------------------------------- axios --------------------------------- */ import axios from 'axios'; /* ---------------------------------- react --------------------------------- */ -import { useEffect, useState } from 'react'; +import { useEffect, useRef, useState } from 'react'; /* -------------------------------- component ------------------------------- */ import Iconify from '../../components/Iconify'; import BaseTablePagination from '../../components/BaseTablePagination'; @@ -177,6 +179,14 @@ export default function TableList() { }; /* -------------------------------------------------------------------------- */ + /* ----------------------------- Field Container ---------------------------- */ + + /* ----------------------------- division field ----------------------------- */ + const optionDivisions = ['All']; + + const [value, setValue] = useState(optionDivisions[0]); + /* -------------------------------------------------------------------------- */ + /* ------------------------------ Search field ------------------------------ */ const [searchText, setSearchText] = useState(''); @@ -194,6 +204,89 @@ export default function TableList() { }; /* -------------------------------------------------------------------------- */ + /* ------------------------------ import button ----------------------------- */ + const [currentImportFileName, setCurrentImportFileName] = useState(null); + const importForm = useRef(null); + + const handleImportChange = (event: any) => { + if (event.target.files[0]) { + setCurrentImportFileName(event.target.files[0].name); + } else { + setCurrentImportFileName(null); + } + }; + /* -------------------------------------------------------------------------- */ + + /* ------------------------------ create button ----------------------------- */ + const [anchorEl, setAnchorEl] = useState(null); + const handleClick = (event: React.MouseEvent) => { + setAnchorEl(event.currentTarget); + }; + /* -------------------------------------------------------------------------- */ + + const FieldContainer = () => ( + + + { + console.log(newValue); + setValue(newValue); + }} + renderInput={(params) => } + /> + + +
+ + +
+ + + + + + +
+ ); + + /* -------------------------------------------------------------------------- */ + /* ---------------------------- table pagination ---------------------------- */ /* ------------------------ button change pagination ------------------------ */ @@ -261,16 +354,7 @@ export default function TableList() { {/* Field 1 */} -
- - +
{/* End Field 1 */} {/* Field 2 */}