|
|
|
@@ -0,0 +1,98 @@ |
|
|
|
import { |
|
|
|
Box, |
|
|
|
Table, |
|
|
|
TableBody, |
|
|
|
TableCell, |
|
|
|
TableContainer, |
|
|
|
TablePagination, |
|
|
|
TableRow, |
|
|
|
} from "@mui/material"; |
|
|
|
import { 顧客ログインユーザ } from "api/login-user"; |
|
|
|
import { デポジット異動履歴 } from "api/shop"; |
|
|
|
import TableHeadCustom, { |
|
|
|
HeadLabelProps, |
|
|
|
} from "components/table/TableHeadCustom"; |
|
|
|
import useAuth from "hooks/useAuth"; |
|
|
|
import useSnackbarCustom from "hooks/useSnackbarCustom"; |
|
|
|
import { UseTableReturn } from "hooks/useTable"; |
|
|
|
import { formatDateTimeStr } from "utils/datetime"; |
|
|
|
import { numberFormat } from "utils/string"; |
|
|
|
|
|
|
|
type CommonProps = { |
|
|
|
table: UseTableReturn<デポジット異動履歴>; |
|
|
|
}; |
|
|
|
export default function TableBox({ table }: CommonProps) { |
|
|
|
const TABLE_HEAD: HeadLabelProps[] = [ |
|
|
|
{ id: "datetime", label: "日時", align: "left", needSort: false }, |
|
|
|
{ id: "name", label: "名称", align: "left", needSort: false }, |
|
|
|
{ id: "amount", label: "金額", align: "left", needSort: false }, |
|
|
|
{ id: "deposit", label: "残高", align: "left", needSort: false }, |
|
|
|
]; |
|
|
|
const { |
|
|
|
order, |
|
|
|
page, |
|
|
|
sort, |
|
|
|
rowsPerPage, |
|
|
|
fetched, |
|
|
|
fillteredRow, |
|
|
|
isNotFound, |
|
|
|
dataLength, |
|
|
|
// |
|
|
|
onSort, |
|
|
|
onChangePage, |
|
|
|
onChangeRowsPerPage, |
|
|
|
// |
|
|
|
setRowData, |
|
|
|
// |
|
|
|
ROWS_PER_PAGES, |
|
|
|
} = table; |
|
|
|
|
|
|
|
return ( |
|
|
|
<> |
|
|
|
<TableContainer> |
|
|
|
<Table sx={{ minWidth: 800 }} size="small"> |
|
|
|
<TableHeadCustom |
|
|
|
order={order} |
|
|
|
orderBy={sort} |
|
|
|
headLabel={TABLE_HEAD} |
|
|
|
rowCount={1} |
|
|
|
numSelected={0} |
|
|
|
onSort={onSort} |
|
|
|
/> |
|
|
|
|
|
|
|
<TableBody> |
|
|
|
{fillteredRow.map((row, index) => ( |
|
|
|
<Row data={row} key={index} /> |
|
|
|
))} |
|
|
|
</TableBody> |
|
|
|
</Table> |
|
|
|
</TableContainer> |
|
|
|
|
|
|
|
<Box sx={{ position: "relative" }}> |
|
|
|
<TablePagination |
|
|
|
rowsPerPageOptions={ROWS_PER_PAGES} |
|
|
|
component="div" |
|
|
|
count={dataLength} |
|
|
|
rowsPerPage={rowsPerPage} |
|
|
|
page={page} |
|
|
|
onPageChange={onChangePage} |
|
|
|
onRowsPerPageChange={onChangeRowsPerPage} |
|
|
|
/> |
|
|
|
</Box> |
|
|
|
</> |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
type RowProps = { |
|
|
|
data: デポジット異動履歴; |
|
|
|
}; |
|
|
|
function Row({ data }: RowProps) { |
|
|
|
return ( |
|
|
|
<TableRow> |
|
|
|
<TableCell>{formatDateTimeStr(data.transfer_datetime)}</TableCell> |
|
|
|
<TableCell>{data.transfer_reason ?? "-"}</TableCell> |
|
|
|
<TableCell>{numberFormat(data.transfer_amount)}円</TableCell> |
|
|
|
<TableCell>{numberFormat(data.after_amount)}円</TableCell> |
|
|
|
</TableRow> |
|
|
|
); |
|
|
|
} |