From a55b7f4148db9e6b656e277e8a0cad33de0fb8b0 Mon Sep 17 00:00:00 2001 From: Tb Fajri Date: Thu, 4 May 2023 08:43:28 +0700 Subject: [PATCH 1/6] update tarif rs awal bros --- database/seeders/TarifDokterRsAwalBros.php | 90 +++++++++++++++++++ .../files/Tarif Konsultasi AwalBros 2023.csv | 8 ++ 2 files changed, 98 insertions(+) create mode 100644 database/seeders/TarifDokterRsAwalBros.php create mode 100644 public/files/Tarif Konsultasi AwalBros 2023.csv diff --git a/database/seeders/TarifDokterRsAwalBros.php b/database/seeders/TarifDokterRsAwalBros.php new file mode 100644 index 00000000..68070931 --- /dev/null +++ b/database/seeders/TarifDokterRsAwalBros.php @@ -0,0 +1,90 @@ + 'PekanBaru', + 'B' => 'Batam', + 'G' => 'UjungBatu', + 'I' => 'Panam', + 'K' => 'AhmadYani', + 'L' => 'ChevronDuri', + ]; + + $file = fopen(public_path("files/Tarif Konsultasi AwalBros 2023.csv"), "r"); + $data = []; + + while ($row = fgetcsv($file)) { + for ($i = 0; $i < count($row); $i++) { + $data[$i][] = $row[$i]; + } + } + fclose($file); + // foreach ($healthcare_primaya as $healthcare) { + $jadwalDokter = JadwalDokter::get(); + foreach ($jadwalDokter as $jadwal) { + $id_healthcare_jadwal = $jadwal->nIDHealthCare; + $healthcare = Healthcare::where('nID', $id_healthcare_jadwal)->first() ?? null; + if ($healthcare == null) { + continue; + } + + $mapValue = $mapHealthcare[$healthcare->sKodeRS] ?? null; + if ($mapValue == null) { + continue; + } + + foreach ($data as $value) { + if ($value[0] == "") { + continue; + } + $codeValue = $value[0]; + $codeValue = $codeValue; + + if ($codeValue == $mapValue) { + if ($jadwal->nIDSpesialis == 1) { + //umum + $jadwal->nBiaya = (int)str_replace(",", "", $value[2]) + (int)str_replace(",", "", $value[1]); + $jadwal->nBiayaTC = (int)str_replace(",", "", $value[5]); + $jadwal->nBiayaATC = (int)str_replace(",", "", $value[5]); + + $jadwal->save(); + } else if ($jadwal->nIDSpesialis !== 1 && $jadwal->sIsSubSpesialis == 1) { + //sub spesialis + + $jadwal->nBiaya = (int)str_replace(",", "", $value[4]) + (int)str_replace(",", "", $value[1]); + $jadwal->nBiayaTC = (int)str_replace(",", "", $value[7]); + $jadwal->nBiayaATC = (int)str_replace(",", "", $value[7]); + + $jadwal->save(); + } else if ($jadwal->nIDSpesialis !== 1) { + //spesialis + $jadwal->nBiaya = (int)str_replace(",", "", $value[3]) + (int)str_replace(",", "", $value[1]); + $jadwal->nBiayaTC = (int)str_replace(",", "", $value[6]); + $jadwal->nBiayaATC = (int)str_replace(",", "", $value[6]); + + $jadwal->save(); + } + } else { + continue; + } + } + } + } +} diff --git a/public/files/Tarif Konsultasi AwalBros 2023.csv b/public/files/Tarif Konsultasi AwalBros 2023.csv new file mode 100644 index 00000000..28cdb787 --- /dev/null +++ b/public/files/Tarif Konsultasi AwalBros 2023.csv @@ -0,0 +1,8 @@ +,,PekanBaru,UjungBatu,Panam,AhmadYani,BaganBatu,Batam,BotaniaBatam +,Administrasi Rawat Jalan," 50,000 "," 50,000 "," 50,000 "," 50,000 "," 50,000 "," 25,000 "," 50,000 " +,Konsultasi Dokter Umum," 75,000 "," 75,000 "," 75,000 "," 75,000 "," 75,000 "," 150,000 "," 150,000 " +,Konsultasi Dokter Spesialis," 175,000 "," 175,000 "," 175,000 "," 175,000 "," 175,000 "," 300,000 "," 300,000 " +,Konsultasi Dokter Sub Spesialis / Konsultan," 265,000 "," 265,000 "," 265,000 "," 265,000 "," 265,000 "," 500,000 "," 500,000 " +,Telekonsultasi Dokter Umum," 75,000 "," 75,000 "," 75,000 "," 75,000 "," 75,000 "," 150,000 "," 150,000 " +,Telekonsultasi Dokter Spesialis," 175,000 "," 175,000 "," 175,000 "," 175,000 "," 175,000 "," 300,000 "," 300,000 " +,Telekonsultasi Dokter Sub Spesialis," 265,000 "," 265,000 "," 265,000 "," 265,000 "," 265,000 "," 500,000 "," 500,000 " From e455fbfbea618f6984c28aaf0530ea3f9f344963 Mon Sep 17 00:00:00 2001 From: Tb Fajri Date: Thu, 4 May 2023 09:14:37 +0700 Subject: [PATCH 2/6] update --- database/seeders/TarifDokterRsAwalBros.php | 12 ++++++------ public/files/Tarif Konsultasi AwalBros 2023.csv | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/database/seeders/TarifDokterRsAwalBros.php b/database/seeders/TarifDokterRsAwalBros.php index 68070931..62b1db50 100644 --- a/database/seeders/TarifDokterRsAwalBros.php +++ b/database/seeders/TarifDokterRsAwalBros.php @@ -60,23 +60,23 @@ class TarifDokterRsAwalBros extends Seeder if ($codeValue == $mapValue) { if ($jadwal->nIDSpesialis == 1) { //umum - $jadwal->nBiaya = (int)str_replace(",", "", $value[2]) + (int)str_replace(",", "", $value[1]); - $jadwal->nBiayaTC = (int)str_replace(",", "", $value[5]); + $jadwal->nBiaya =(int)str_replace(",", "", $value[1]); + $jadwal->nBiayaTC = (int)str_replace(",", "", $value[2]); $jadwal->nBiayaATC = (int)str_replace(",", "", $value[5]); $jadwal->save(); } else if ($jadwal->nIDSpesialis !== 1 && $jadwal->sIsSubSpesialis == 1) { //sub spesialis - $jadwal->nBiaya = (int)str_replace(",", "", $value[4]) + (int)str_replace(",", "", $value[1]); - $jadwal->nBiayaTC = (int)str_replace(",", "", $value[7]); + $jadwal->nBiaya = (int)str_replace(",", "", $value[1]); + $jadwal->nBiayaTC = (int)str_replace(",", "", $value[4]); $jadwal->nBiayaATC = (int)str_replace(",", "", $value[7]); $jadwal->save(); } else if ($jadwal->nIDSpesialis !== 1) { //spesialis - $jadwal->nBiaya = (int)str_replace(",", "", $value[3]) + (int)str_replace(",", "", $value[1]); - $jadwal->nBiayaTC = (int)str_replace(",", "", $value[6]); + $jadwal->nBiaya = (int)str_replace(",", "", $value[1]); + $jadwal->nBiayaTC = (int)str_replace(",", "", $value[3]); $jadwal->nBiayaATC = (int)str_replace(",", "", $value[6]); $jadwal->save(); diff --git a/public/files/Tarif Konsultasi AwalBros 2023.csv b/public/files/Tarif Konsultasi AwalBros 2023.csv index 28cdb787..024da189 100644 --- a/public/files/Tarif Konsultasi AwalBros 2023.csv +++ b/public/files/Tarif Konsultasi AwalBros 2023.csv @@ -1,5 +1,5 @@ ,,PekanBaru,UjungBatu,Panam,AhmadYani,BaganBatu,Batam,BotaniaBatam -,Administrasi Rawat Jalan," 50,000 "," 50,000 "," 50,000 "," 50,000 "," 50,000 "," 25,000 "," 50,000 " +,Administrasi Rawat Jalan," 50,000 "," 50,000 "," 50,000 "," 50,000 "," 50,000 "," 50,000 "," 50,000 " ,Konsultasi Dokter Umum," 75,000 "," 75,000 "," 75,000 "," 75,000 "," 75,000 "," 150,000 "," 150,000 " ,Konsultasi Dokter Spesialis," 175,000 "," 175,000 "," 175,000 "," 175,000 "," 175,000 "," 300,000 "," 300,000 " ,Konsultasi Dokter Sub Spesialis / Konsultan," 265,000 "," 265,000 "," 265,000 "," 265,000 "," 265,000 "," 500,000 "," 500,000 " From 12fbef2a128453da4ce2802dd142842b368f62b7 Mon Sep 17 00:00:00 2001 From: Tb Fajri Date: Thu, 4 May 2023 09:19:47 +0700 Subject: [PATCH 3/6] update biaya --- database/seeders/TarifDokterRsAwalBros.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/database/seeders/TarifDokterRsAwalBros.php b/database/seeders/TarifDokterRsAwalBros.php index 62b1db50..456cb7bd 100644 --- a/database/seeders/TarifDokterRsAwalBros.php +++ b/database/seeders/TarifDokterRsAwalBros.php @@ -60,7 +60,7 @@ class TarifDokterRsAwalBros extends Seeder if ($codeValue == $mapValue) { if ($jadwal->nIDSpesialis == 1) { //umum - $jadwal->nBiaya =(int)str_replace(",", "", $value[1]); + $jadwal->nBiaya =(int)str_replace(",", "", $value[1]) + (int)str_replace(",", "", $value[2]); $jadwal->nBiayaTC = (int)str_replace(",", "", $value[2]); $jadwal->nBiayaATC = (int)str_replace(",", "", $value[5]); @@ -68,14 +68,14 @@ class TarifDokterRsAwalBros extends Seeder } else if ($jadwal->nIDSpesialis !== 1 && $jadwal->sIsSubSpesialis == 1) { //sub spesialis - $jadwal->nBiaya = (int)str_replace(",", "", $value[1]); + $jadwal->nBiaya = (int)str_replace(",", "", $value[1]) + (int)str_replace(",", "", $value[4]); $jadwal->nBiayaTC = (int)str_replace(",", "", $value[4]); $jadwal->nBiayaATC = (int)str_replace(",", "", $value[7]); $jadwal->save(); } else if ($jadwal->nIDSpesialis !== 1) { //spesialis - $jadwal->nBiaya = (int)str_replace(",", "", $value[1]); + $jadwal->nBiaya = (int)str_replace(",", "", $value[1]) + (int)str_replace(",", "", $value[3]); $jadwal->nBiayaTC = (int)str_replace(",", "", $value[3]); $jadwal->nBiayaATC = (int)str_replace(",", "", $value[6]); From 49f3a8558d4f2db859db03cb006d838a43325f91 Mon Sep 17 00:00:00 2001 From: pajri Date: Thu, 4 May 2023 16:59:18 +0700 Subject: [PATCH 4/6] view table alarm-center --- .../src/pages/AlarmCenter/List.tsx | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/frontend/client-portal/src/pages/AlarmCenter/List.tsx b/frontend/client-portal/src/pages/AlarmCenter/List.tsx index 67b51419..025f8ae0 100644 --- a/frontend/client-portal/src/pages/AlarmCenter/List.tsx +++ b/frontend/client-portal/src/pages/AlarmCenter/List.tsx @@ -15,9 +15,10 @@ import { } from '@mui/material'; import { visuallyHidden } from '@mui/utils'; /* ---------------------------------- axios --------------------------------- */ -import axios from 'axios'; +// import axios from 'axios'; +import axios from '../../utils/axios'; /* ---------------------------------- react --------------------------------- */ -import { useEffect, useState } from 'react'; +import { useContext, useEffect, useState } from 'react'; /* -------------------------------- component ------------------------------- */ import Iconify from '../../components/Iconify'; import BaseTablePagination from '../../components/BaseTablePagination'; @@ -25,6 +26,7 @@ import BaseTablePagination from '../../components/BaseTablePagination'; import useMap from '../../hooks/useMap'; /* ---------------------------------- theme --------------------------------- */ import palette from '../../theme/palette'; +import { UserCurrentCorporateContext } from '../../contexts/UserCurrentCorporate'; /* ---------------------------------- types --------------------------------- */ @@ -40,12 +42,12 @@ type PaginationTableProps = { }; type DataTableProps = { - name: string; - member_id: string; + fullName: string; + memberId: string; service: string; start_date: string; end_date: string; - status: string; + status: boolean | number; }; /* -------------------------------------------------------------------------- */ @@ -130,8 +132,9 @@ function EnhancedTableHead(props: EnhancedTableProps) { /* -------------------------------------------------------------------------- */ export default function List() { + const { corporateValue } = useContext(UserCurrentCorporateContext); const [order, setOrder] = useState('asc'); - const [orderBy, setOrderBy] = useState('name'); + const [orderBy, setOrderBy] = useState(''); const [customSearchParams, setCustomSearchParams] = useMap(); const [isLoading, setIsLoading] = useState(true); const [dataTable, setDataTable] = useState([]); @@ -147,7 +150,6 @@ export default function List() { to: 0, total: 0, }); - /* ------------------------------- handle sort ------------------------------ */ const handleRequestSort = async (event: React.MouseEvent, property: string) => { const isAsc = orderBy === property && order === 'asc'; @@ -155,8 +157,8 @@ export default function List() { setOrderBy(property); const params = Object.fromEntries([ ...customSearchParams.entries(), - ['order', isAsc ? 'desc' : 'asc'], - ['orderBy', property], + // ['order', isAsc ? 'desc' : 'asc'], + // ['orderBy', property], ]); setIsLoading(true); await new Promise((resolve) => setTimeout(resolve, 500)); @@ -190,14 +192,15 @@ export default function List() { ? appliedParams : Object.fromEntries([ ...customSearchParams.entries(), - ['order', order], - ['orderBy', orderBy], + // ['order', order], + // ['orderBy', orderBy], ]); - const response = await axios.get('http://localhost:8001/api/alarm-center', { params: params }); - + const response = await axios.get(`/${corporateValue}/members?type=alarm-center`, { + params: params, + }); setDataTable(response.data.data); - setPaginationTable(response.data.meta); - setRowsPerPage(response.data.meta.per_page); + setPaginationTable(response.data); + setRowsPerPage(response.data.per_page); setIsLoading(false); }; /* -------------------------------------------------------------------------- */ @@ -264,13 +267,13 @@ export default function List() { dataTable.map((row: DataTableProps, index) => ( {paginationTable.from + index++} - {row.name} - {row.member_id} + {row.fullName} + {row.memberId} {row.service} {row.start_date} {row.end_date} - {row.status.toLowerCase() === 'done' ? ( + {row.status === 1 ? ( ) : ( )} From c8b06f67d125ff35cc9b37c62ccc6d6e5d415437 Mon Sep 17 00:00:00 2001 From: pajri Date: Fri, 5 May 2023 17:02:40 +0700 Subject: [PATCH 5/6] Table Component Alarm Center --- frontend/client-portal/.env.development | 4 +- .../src/pages/AlarmCenter/List.tsx | 519 +++++++++--------- 2 files changed, 268 insertions(+), 255 deletions(-) diff --git a/frontend/client-portal/.env.development b/frontend/client-portal/.env.development index b3f9d3bd..2badd03d 100644 --- a/frontend/client-portal/.env.development +++ b/frontend/client-portal/.env.development @@ -2,6 +2,6 @@ GENERATE_SOURCEMAP=false PORT=8083 -REACT_APP_HOST_API_URL="http://lms.test" +REACT_APP_HOST_API_URL="http://localhost:8001" -VITE_API_URL="http://lms.test/api/client" +VITE_API_URL="http://localhost:8001/api/client" diff --git a/frontend/client-portal/src/pages/AlarmCenter/List.tsx b/frontend/client-portal/src/pages/AlarmCenter/List.tsx index 025f8ae0..bcfcf455 100644 --- a/frontend/client-portal/src/pages/AlarmCenter/List.tsx +++ b/frontend/client-portal/src/pages/AlarmCenter/List.tsx @@ -19,127 +19,166 @@ import { visuallyHidden } from '@mui/utils'; import axios from '../../utils/axios'; /* ---------------------------------- react --------------------------------- */ import { useContext, useEffect, useState } from 'react'; + /* -------------------------------- component ------------------------------- */ import Iconify from '../../components/Iconify'; import BaseTablePagination from '../../components/BaseTablePagination'; +import TableComponent from '../../components/Table'; + /* ---------------------------------- hooks --------------------------------- */ import useMap from '../../hooks/useMap'; /* ---------------------------------- theme --------------------------------- */ import palette from '../../theme/palette'; import { UserCurrentCorporateContext } from '../../contexts/UserCurrentCorporate'; +import { HeadCell, Order, PaginationTableProps } from '../../@types/table'; +import { useSearchParams } from 'react-router-dom'; /* ---------------------------------- types --------------------------------- */ -type PaginationTableProps = { - current_page: number; - from: number; - last_page: number; - links: []; - path: string; - per_page: number; - to: number; - total: number; -}; +// type PaginationTableProps = { +// current_page: number; +// from: number; +// last_page: number; +// links: []; +// path: string; +// per_page: number; +// to: number; +// total: number; +// }; -type DataTableProps = { - fullName: string; - memberId: string; - service: string; - start_date: string; - end_date: string; - status: boolean | number; -}; +// type DataTableProps = { +// fullName: string; +// memberId: string; +// service: string; +// start_date: string; +// end_date: string; +// status: boolean | number; +// }; -/* -------------------------------------------------------------------------- */ +// /* -------------------------------------------------------------------------- */ -/* -------------------------- enchanced table head -------------------------- */ +// /* -------------------------- enchanced table head -------------------------- */ -type Order = 'asc' | 'desc'; +// type Order = 'asc' | 'desc'; -interface HeadCell { - id: string; - label: string; -} +// interface HeadCell { +// id: string; +// label: string; +// } -const headCells: readonly HeadCell[] = [ - { - id: 'name', - label: 'Name', - }, - { - id: 'member_id', - label: 'Member ID', - }, - { - id: 'service', - label: 'Service', - }, - { - id: 'start_date', - label: 'Start Date', - }, - { - id: 'end_date', - label: 'End Date', - }, - { - id: 'status', - label: 'Status', - }, -]; +// const headCells: readonly HeadCell[] = [ +// { +// id: 'name', +// label: 'Name', +// }, +// { +// id: 'member_id', +// label: 'Member ID', +// }, +// { +// id: 'service', +// label: 'Service', +// }, +// { +// id: 'start_date', +// label: 'Start Date', +// }, +// { +// id: 'end_date', +// label: 'End Date', +// }, +// { +// id: 'status', +// label: 'Status', +// }, +// ]; -interface EnhancedTableProps { - onRequestSort: (event: React.MouseEvent, property: string) => void; - order: Order; - orderBy: string; -} +// interface EnhancedTableProps { +// onRequestSort: (event: React.MouseEvent, property: string) => void; +// order: Order; +// orderBy: string; +// } -function EnhancedTableHead(props: EnhancedTableProps) { - const { order, orderBy, onRequestSort } = props; - const createSortHandler = (property: string) => (event: React.MouseEvent) => { - onRequestSort(event, property); - }; +// function EnhancedTableHead(props: EnhancedTableProps) { +// const { order, orderBy, onRequestSort } = props; +// const createSortHandler = (property: string) => (event: React.MouseEvent) => { +// onRequestSort(event, property); +// }; - return ( - - - No - {headCells.map((headCell) => ( - - - {headCell.label} - {orderBy === headCell.id ? ( - - {order === 'desc' ? 'sorted descending' : 'sorted ascending'} - - ) : null} - - - ))} - - - ); -} +// return ( +// +// +// No +// {headCells.map((headCell) => ( +// +// +// {headCell.label} +// {orderBy === headCell.id ? ( +// +// {order === 'desc' ? 'sorted descending' : 'sorted ascending'} +// +// ) : null} +// +// +// ))} +// +// +// ); +// } /* -------------------------------------------------------------------------- */ export default function List() { const { corporateValue } = useContext(UserCurrentCorporateContext); - const [order, setOrder] = useState('asc'); - const [orderBy, setOrderBy] = useState(''); - const [customSearchParams, setCustomSearchParams] = useMap(); + + const [data, setData] = useState([]); + + /* -------------------------------------------------------------------------- */ + /* setting up for the table */ + /* -------------------------------------------------------------------------- */ const [isLoading, setIsLoading] = useState(true); - const [dataTable, setDataTable] = useState([]); + + const loadings = { + isLoading: isLoading, + setIsLoading: setIsLoading, + }; + + /* ------------------------------ handle params ----------------------------- */ + const [searchParams, setSearchParams] = useSearchParams(); + const [appliedParams, setAppliedParams] = useState({}); + + const params = { + searchParams: searchParams, + setSearchParams: setSearchParams, + appliedParams: appliedParams, + setAppliedParams: setAppliedParams, + }; + /* -------------------------------------------------------------------------- */ + + /* ------------------------------ handle order ------------------------------ */ + const [order, setOrder] = useState('asc'); + const [orderBy, setOrderBy] = useState('fullName'); + + const orders = { + order: order, + setOrder: setOrder, + orderBy: orderBy, + setOrderBy: setOrderBy, + }; + /* -------------------------------------------------------------------------- */ + + /* ---------------------------- handle pagination --------------------------- */ const [page, setPage] = useState(0); const [rowsPerPage, setRowsPerPage] = useState(10); + const [paginationTable, setPaginationTable] = useState({ current_page: 0, from: 0, @@ -150,183 +189,157 @@ export default function List() { to: 0, total: 0, }); - /* ------------------------------- handle sort ------------------------------ */ - const handleRequestSort = async (event: React.MouseEvent, property: string) => { - const isAsc = orderBy === property && order === 'asc'; - setOrder(isAsc ? 'desc' : 'asc'); - setOrderBy(property); - const params = Object.fromEntries([ - ...customSearchParams.entries(), - // ['order', isAsc ? 'desc' : 'asc'], - // ['orderBy', property], - ]); - setIsLoading(true); - await new Promise((resolve) => setTimeout(resolve, 500)); - loadDataTable(params); - setIsLoading(false); + + const paginations = { + page: page, + setPage: setPage, + rowsPerPage: rowsPerPage, + setRowsPerPage: setRowsPerPage, + paginationTable: paginationTable, + setPaginationTable: setPaginationTable, }; /* -------------------------------------------------------------------------- */ - /* ------------------------------ Search field ------------------------------ */ + /* ------------------------------ handle search ----------------------------- */ const [searchText, setSearchText] = useState(''); - const handleSearch = (event: any) => { - setSearchText(event.target.value); - }; - - const handleSearchSubmit = async (event: any) => { + const handleSearchSubmit = async (event: React.FormEvent) => { event.preventDefault(); - const params = Object.fromEntries([...customSearchParams.entries(), ['search', searchText]]); - setIsLoading(true); - await new Promise((resolve) => setTimeout(resolve, 500)); - loadDataTable(params); - setIsLoading(false); - }; - /* -------------------------------------------------------------------------- */ - /* --------------------------- Load Data Table API -------------------------- */ - const loadDataTable = async (appliedParams: any | null = null) => { - setIsLoading(true); - - const params = appliedParams - ? appliedParams - : Object.fromEntries([ - ...customSearchParams.entries(), - // ['order', order], - // ['orderBy', orderBy], - ]); - const response = await axios.get(`/${corporateValue}/members?type=alarm-center`, { - params: params, - }); - setDataTable(response.data.data); - setPaginationTable(response.data); - setRowsPerPage(response.data.per_page); - setIsLoading(false); + if (searchText === '') { + searchParams.delete('search'); + const params = Object.fromEntries([...searchParams.entries()]); + setAppliedParams(params); + } else { + const params = Object.fromEntries([...searchParams.entries(), ['search', searchText]]); + setAppliedParams(params); + } }; - /* -------------------------------------------------------------------------- */ - /* ------------------------ button change pagination ------------------------ */ - const onPageChangeHandle = async (event: unknown, newPage: number) => { - const params = Object.fromEntries([...customSearchParams.entries(), ['page', newPage + 1]]); - setPage(newPage); - setIsLoading(true); - await new Promise((resolve) => setTimeout(resolve, 500)); - loadDataTable(params); - setIsLoading(false); - setCustomSearchParams.set('page', newPage + 1); + const searchs = { + searchText: searchText, + setSearchText: setSearchText, + handleSearchSubmit: handleSearchSubmit, }; - /* -------------------------------------------------------------------------- */ - /* ----------------------- row page per limit on click ---------------------- */ - const onRowsPerPageChangeHandle = async (event: React.ChangeEvent) => { - setPage(0); - const params = Object.fromEntries([ - ...customSearchParams.entries(), - ['page', 0], - ['per_page', parseInt(event.target.value, 10)], - ]); - setRowsPerPage(parseInt(event.target.value, 10)); - setIsLoading(true); - await new Promise((resolve) => setTimeout(resolve, 500)); - loadDataTable(params); - setIsLoading(false); - setCustomSearchParams.set('per_page', parseInt(event.target.value, 10)); - }; + /* -------------------------------- headCell -------------------------------- */ + const headCells: HeadCell[] = [ + { + id: 'fullName', + align: 'left', + label: 'Name', + isSort: true, + }, + { + id: 'memberId', + align: 'left', + label: 'Member ID', + isSort: true, + }, + { + id: 'start_date', + align: 'center', + label: 'Start Date', + isSort: true, + }, + { + id: 'end_date', + align: 'center', + label: 'End Date', + isSort: false, + }, + { + id: 'status', + align: 'center', + label: 'Status', + isSort: true, + }, + ]; /* -------------------------------------------------------------------------- */ useEffect(() => { - loadDataTable(); - }, []); + (async () => { + setIsLoading(true); + + await new Promise((resolve) => setTimeout(resolve, 250)); + + const parameters = + Object.keys(appliedParams).length !== 0 + ? appliedParams + : Object.fromEntries([...searchParams.entries(), ['order', order], ['orderBy', orderBy]]); + + const response = await axios.get(`/${corporateValue}/members?type=alarm-center`, { + params: parameters, + }); + + setData( + response.data.data.map((obj: any) => { + return { + ...obj, + status: + obj.status === 1 ? ( + + ) : ( + + ), + }; + }) + ); + + setPaginationTable(response.data); + setRowsPerPage(response.data.per_page); + + if (searchParams.get('page')) { + //@ts-ignore + const currentPage = parseInt(searchParams.get('page')) - 1; + + paginationTable.current_page = currentPage; + setPage(currentPage); + } + + setIsLoading(false); + })(); + }, [appliedParams, searchParams, order, orderBy, setSearchParams, corporateValue]); return ( - {/* Search */} -
- - - - {/* The Main Table */} - - - - - {isLoading ? ( - - - Loading . . . - - - ) : dataTable.length >= 1 ? ( - dataTable.map((row: DataTableProps, index) => ( - - {paginationTable.from + index++} - {row.fullName} - {row.memberId} - {row.service} - {row.start_date} - {row.end_date} - - {row.status === 1 ? ( - - ) : ( - - )} - - - )) - ) : ( - - - No Data Found - - - )} - -
-
- - {/* Pagination */} -
); From 5df1a85e7cff7447b885e5fd1607db25dacf15b7 Mon Sep 17 00:00:00 2001 From: Tb Fajri Date: Mon, 8 May 2023 08:47:36 +0700 Subject: [PATCH 6/6] add filter ketika klik all --- .../src/pages/Corporates/Member/sections/DialogLog.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/dashboard/src/pages/Corporates/Member/sections/DialogLog.tsx b/frontend/dashboard/src/pages/Corporates/Member/sections/DialogLog.tsx index 4c8004bc..03a4b8f2 100644 --- a/frontend/dashboard/src/pages/Corporates/Member/sections/DialogLog.tsx +++ b/frontend/dashboard/src/pages/Corporates/Member/sections/DialogLog.tsx @@ -61,7 +61,7 @@ const DialogLog = ({ title, openDialog, setOpenDialog, data }: MuiDialogProps) = const [loadingLog, setLoadingLog] = useState(false); useEffect(() => { - setBenefitIds(data.member.current_plan?.benefits.map((benefit) => benefit.id)) + setBenefitIds(data.member.current_plan?.benefits.filter((benefit) => benefit.pivot.active == 1).map((benefit) => benefit.id)) setCheckedBenefitIds(benefitIds) console.log('Check All', benefitIds, 'X', data.member.current_plan?.benefits.map((benefit) => benefit.id)) }, [])