Add Dummy Notification Data

This commit is contained in:
R
2023-02-24 10:45:03 +07:00
parent 1c4f03ea83
commit 8902718523
3 changed files with 31 additions and 9 deletions

View File

@@ -13,17 +13,18 @@ import { Stack } from '@mui/system';
import { Input } from '@mui/material'; import { Input } from '@mui/material';
//sections //sections
import TableList from '@/sections/dashboard/TableList'; import TableList from '@/sections/dashboard/TableList';
import { fDate } from '@/utils/formatTime';
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// const [notifications, setNotifications] = useState([]) // const [notifications, setNotifications] = useState([])
const itemList = [ // const itemList = [
// { info: 'Mohon lengkapi dokumen Mahen sadarsa', date: 'Selasa, 20 April 22', time: '08:00 WIB' }, // // { info: 'Mohon lengkapi dokumen Mahen sadarsa', date: 'Selasa, 20 April 22', time: '08:00 WIB' },
// { info: 'Mohon lengkapi dokumen Mahen sadarsa', date: 'Selasa, 20 April 22', time: '09:00 WIB' }, // // { info: 'Mohon lengkapi dokumen Mahen sadarsa', date: 'Selasa, 20 April 22', time: '09:00 WIB' },
// { info: 'Mohon lengkapi dokumen Mahen sadarsa', date: 'Selasa, 20 April 22', time: '10:00 WIB' }, // // { info: 'Mohon lengkapi dokumen Mahen sadarsa', date: 'Selasa, 20 April 22', time: '10:00 WIB' },
// { info: 'Mohon lengkapi dokumen Mahen sadarsa', date: 'Selasa, 20 April 22', time: '11:00 WIB' }, // // { info: 'Mohon lengkapi dokumen Mahen sadarsa', date: 'Selasa, 20 April 22', time: '11:00 WIB' },
]; // ];
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@@ -63,6 +64,23 @@ export default function Dashboard() {
// const [tableData, setTableData] = useState([]); // const [tableData, setTableData] = useState([]);
const [policyData, setPolicyData] = useState<PolicyProps>(defaultPolicyData); const [policyData, setPolicyData] = useState<PolicyProps>(defaultPolicyData);
// TODO Remove This
const [itemList, setItemList] = useState([]);
function handleDataLoaded(dataTable) {
let dummyData = [];
dataTable.map(function(data) {
if (data.status == 'approved') {
dummyData.push({
info: `LOG Approved for member ${data.member.full_name}`,
date: fDate(data.created_at, "dd MMMM"),
time: fDate(data.created_at, "HH:mm")
})
}
})
setItemList(dummyData);
}
return ( return (
<Page title="Dashboard"> <Page title="Dashboard">
<Container maxWidth={themeStretch ? false : 'xl'}> <Container maxWidth={themeStretch ? false : 'xl'}>
@@ -74,7 +92,7 @@ export default function Dashboard() {
<CardNotification data={itemList} /> <CardNotification data={itemList} />
</Grid> </Grid>
<Grid item xs={12} lg={12} md={12}> <Grid item xs={12} lg={12} md={12}>
<TableList /> <TableList dataLoaded={handleDataLoaded}/>
</Grid> </Grid>
</Grid> </Grid>
</Container> </Container>

View File

@@ -28,7 +28,7 @@ const RootNotificationStyle = styled(Card)(({ theme }) => ({
padding: '1rem 0.5rem', padding: '1rem 0.5rem',
color: 'black', color: 'black',
backgroundColor: theme.palette.grey[200], backgroundColor: theme.palette.grey[200],
maxHeight: '240px', // maxHeight: '240px',
})); }));
const ItemNotificationStyle = styled(Card)(({ theme }) => ({ const ItemNotificationStyle = styled(Card)(({ theme }) => ({
@@ -94,7 +94,7 @@ export default function CardNotification({ data }: NotificationProps) {
</Button> </Button>
</Stack> </Stack>
<ItemNotificationStyle sx={{ marginTop: 2, overflowY: 'auto', maxHeight: '154px' }}> <ItemNotificationStyle sx={{ marginTop: 2, overflowY: 'auto', maxHeight: '180px' }}>
{(data && data.length) {(data && data.length)
? data.map(({ info, date, time }, key) => ( ? data.map(({ info, date, time }, key) => (
<div key={key}> <div key={key}>

View File

@@ -176,6 +176,7 @@ function EnhancedTableHead({ order, orderBy, onRequestSort }: EnhancedTableProps
} }
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
// TODO Don't use emit
export default function TableList(props: any) { export default function TableList(props: any) {
const [dataTable, setDataTable] = useState([]); const [dataTable, setDataTable] = useState([]);
const [paginationTable, setPaginationTable] = useState<PaginationTableProps>({ const [paginationTable, setPaginationTable] = useState<PaginationTableProps>({
@@ -306,6 +307,9 @@ export default function TableList(props: any) {
setPaginationTable(response.data.data); setPaginationTable(response.data.data);
setRowsPerPage(response.data.data.per_page); setRowsPerPage(response.data.data.per_page);
setIsLoading(false); setIsLoading(false);
// TODO Remove This
props.dataLoaded(response.data.data.data);
})(); })();
}, [appliedParams, searchParams, order, orderBy, setSearchParams]); }, [appliedParams, searchParams, order, orderBy, setSearchParams]);