FPSMS-frontend
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

117 linhas
2.9 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, GridInputRowSelectionModel } from "@mui/x-data-grid";
  14. import { Box, CircularProgress, Grid, Typography } from "@mui/material";
  15. import { PickOrderResult } from "@/app/api/pickOrder";
  16. import { useTranslation } from "react-i18next";
  17. dayjs.extend(arraySupport);
  18. interface Props {
  19. consoCode: string;
  20. rows: Omit<PickOrderResult, "items">[] | undefined;
  21. setRows: Dispatch<
  22. SetStateAction<Omit<PickOrderResult, "items">[] | undefined>
  23. >;
  24. revertIds: GridInputRowSelectionModel;
  25. setRevertIds: Dispatch<SetStateAction<GridInputRowSelectionModel>>;
  26. }
  27. const ConsolidatePickOrderSum: React.FC<Props> = ({
  28. consoCode,
  29. rows,
  30. setRows,
  31. revertIds,
  32. setRevertIds,
  33. }) => {
  34. const { t } = useTranslation("pickOrder");
  35. const columns = useMemo<GridColDef[]>(
  36. () => [
  37. {
  38. field: "code",
  39. headerName: "code",
  40. flex: 0.6,
  41. },
  42. {
  43. field: "pickOrderLines",
  44. headerName: "items",
  45. flex: 1,
  46. renderCell: (params) => {
  47. console.log(params);
  48. const pickOrderLine = params.row.pickOrderLines as any[];
  49. return (
  50. <Box
  51. sx={{
  52. display: "flex",
  53. flexDirection: "column",
  54. maxHeight: 100,
  55. overflowY: "scroll",
  56. scrollbarWidth: "none", // For Firefox
  57. "&::-webkit-scrollbar": {
  58. display: "none", // For Chrome, Safari, and Opera
  59. },
  60. }}
  61. >
  62. {pickOrderLine.map((item, index) => (
  63. <Grid
  64. sx={{ mt: 1 }}
  65. key={index}
  66. >{`${item.itemName} x ${item.requiredQty} ${item.uomDesc}`}</Grid> // Render each name in a span
  67. ))}
  68. </Box>
  69. );
  70. },
  71. },
  72. ],
  73. [],
  74. );
  75. return (
  76. <Grid
  77. container
  78. rowGap={1}
  79. // direction="column"
  80. alignItems="center"
  81. justifyContent="center"
  82. >
  83. <Grid item xs={12}>
  84. <Typography variant="h5" marginInlineEnd={2}>
  85. {t("Pick Order Included")}
  86. </Typography>
  87. </Grid>
  88. <Grid item xs={12}>
  89. {!rows ? (
  90. <CircularProgress size={40} />
  91. ) : (
  92. <StyledDataGrid
  93. sx={{ maxHeight: 450 }}
  94. checkboxSelection
  95. rowSelectionModel={revertIds}
  96. onRowSelectionModelChange={(newRowSelectionModel) => {
  97. setRevertIds(newRowSelectionModel);
  98. }}
  99. getRowHeight={(params) => {
  100. return 100;
  101. }}
  102. rows={rows}
  103. columns={columns}
  104. />
  105. )}
  106. </Grid>
  107. </Grid>
  108. );
  109. };
  110. export default ConsolidatePickOrderSum;