FPSMS-frontend
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

92 lines
2.2 KiB

  1. "use client";
  2. import dayjs from "dayjs";
  3. import arraySupport from "dayjs/plugin/arraySupport";
  4. import StyledDataGrid from "../StyledDataGrid";
  5. import {
  6. Dispatch,
  7. SetStateAction,
  8. useCallback,
  9. useEffect,
  10. useMemo,
  11. useState,
  12. } from "react";
  13. import { GridColDef } from "@mui/x-data-grid";
  14. import { CircularProgress, Grid, Typography } from "@mui/material";
  15. import { ByItemsSummary } from "@/app/api/pickorder";
  16. import { useTranslation } from "react-i18next";
  17. dayjs.extend(arraySupport);
  18. interface Props {
  19. rows: ByItemsSummary[] | undefined;
  20. setRows: Dispatch<SetStateAction<ByItemsSummary[] | undefined>>;
  21. }
  22. const ConsolidatePickOrderItemSum: React.FC<Props> = ({ rows, setRows }) => {
  23. console.log(rows);
  24. const { t } = useTranslation("pickOrder");
  25. const columns = useMemo<GridColDef[]>(
  26. () => [
  27. {
  28. field: "name",
  29. headerName: "name",
  30. flex: 1,
  31. renderCell: (params) => {
  32. console.log(params.row.name);
  33. return params.row.name;
  34. },
  35. },
  36. {
  37. field: "requiredQty",
  38. headerName: "requiredQty",
  39. flex: 1,
  40. renderCell: (params) => {
  41. console.log(params.row.requiredQty);
  42. const requiredQty = params.row.requiredQty ?? 0;
  43. return `${requiredQty} ${params.row.uomDesc}`;
  44. },
  45. },
  46. {
  47. field: "availableQty",
  48. headerName: "availableQty",
  49. flex: 1,
  50. renderCell: (params) => {
  51. console.log(params.row.availableQty);
  52. const availableQty = params.row.availableQty ?? 0;
  53. return `${availableQty} ${params.row.uomDesc}`;
  54. },
  55. },
  56. ],
  57. []
  58. );
  59. return (
  60. <Grid
  61. container
  62. rowGap={1}
  63. // direction="column"
  64. alignItems="center"
  65. justifyContent="center"
  66. >
  67. <Grid item xs={12}>
  68. <Typography variant="h5" marginInlineEnd={2}>
  69. {t("Items Included")}
  70. </Typography>
  71. </Grid>
  72. <Grid item xs={12}>
  73. {!rows ? (
  74. <CircularProgress size={40} />
  75. ) : (
  76. <StyledDataGrid
  77. sx={{ maxHeight: 450 }}
  78. rows={rows}
  79. columns={columns}
  80. />
  81. )}
  82. </Grid>
  83. </Grid>
  84. );
  85. };
  86. export default ConsolidatePickOrderItemSum;