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.
 
 

132 lines
3.6 KiB

  1. "use client";
  2. import {
  3. Box,
  4. Card,
  5. CardContent,
  6. Grid,
  7. Stack,
  8. TextField,
  9. Tooltip,
  10. Typography,
  11. } from "@mui/material";
  12. import { useFormContext } from "react-hook-form";
  13. import { useTranslation } from "react-i18next";
  14. import StyledDataGrid from "../StyledDataGrid";
  15. import { useCallback, useEffect, useMemo } from "react";
  16. import {
  17. GridColDef,
  18. GridRowIdGetter,
  19. GridRowModel,
  20. useGridApiContext,
  21. GridRenderCellParams,
  22. GridRenderEditCellParams,
  23. useGridApiRef,
  24. } from "@mui/x-data-grid";
  25. import InputDataGrid from "../InputDataGrid";
  26. import { TableRow } from "../InputDataGrid/InputDataGrid";
  27. import { QcItemWithChecks } from "@/app/api/qc";
  28. import { GridEditInputCell } from "@mui/x-data-grid";
  29. import { StockInLine } from "@/app/api/po";
  30. import { stockInLineStatusMap } from "@/app/utils/formatUtil";
  31. import { PickOrderApprovalInput } from "@/app/api/pickOrder/actions";
  32. import { StockOutLine } from "@/app/api/pickOrder";
  33. interface Props {
  34. // approvalDefaultValues: StockInLine;
  35. // qc: QcItemWithChecks[];
  36. approvalDefaultValues: StockOutLine & PickOrderApprovalInput;
  37. disabled: boolean;
  38. }
  39. const ApprovalContent: React.FC<Props> = ({
  40. // qc,
  41. approvalDefaultValues,
  42. disabled,
  43. }) => {
  44. const { t } = useTranslation("purchaseOrder");
  45. const apiRef = useGridApiRef();
  46. const {
  47. register,
  48. formState: { errors, defaultValues, touchedFields },
  49. watch,
  50. control,
  51. setValue,
  52. getValues,
  53. reset,
  54. resetField,
  55. setError,
  56. clearErrors,
  57. } = useFormContext<PickOrderApprovalInput>();
  58. console.log(approvalDefaultValues);
  59. // const status = "rejected"
  60. const totalQty = approvalDefaultValues.qty;
  61. const allowQty = watch("allowQty");
  62. const rejectQty = watch("rejectQty");
  63. return (
  64. <Grid container justifyContent="flex-start" alignItems="flex-start">
  65. <Grid item xs={12}>
  66. <Typography variant="h6" display="block" marginBlockEnd={1}>
  67. {t(`Lot Change Approval`)}
  68. </Typography>
  69. </Grid>
  70. {/* <Grid item xs={12}>
  71. <Typography variant="h6" display="block" marginBlockEnd={1}>
  72. {t(`to be processed`)}: {approvalDefaultValues.rejectQty - rejectQty}
  73. </Typography>
  74. </Grid> */}
  75. <Grid
  76. container
  77. justifyContent="flex-start"
  78. alignItems="flex-start"
  79. spacing={2}
  80. sx={{ mt: 0.5 }}
  81. >
  82. <Grid item xs={6}>
  83. <TextField
  84. label={t("allowQty")}
  85. fullWidth
  86. {...register("allowQty", {
  87. required: "allowQty required!",
  88. min: 0,
  89. valueAsNumber: true,
  90. max: approvalDefaultValues.allowQty,
  91. })}
  92. disabled={disabled}
  93. defaultValue={approvalDefaultValues.allowQty}
  94. error={Boolean(errors.allowQty)}
  95. helperText={errors.allowQty?.message}
  96. />
  97. </Grid>
  98. <Grid item xs={6}>
  99. <TextField
  100. label={t("rejectQty")}
  101. fullWidth
  102. {...register("rejectQty", {
  103. required: "rejectQty required!",
  104. min: 0,
  105. valueAsNumber: true,
  106. max: approvalDefaultValues.rejectQty,
  107. })}
  108. disabled={disabled}
  109. defaultValue={approvalDefaultValues.rejectQty}
  110. error={Boolean(errors.rejectQty)}
  111. helperText={errors.rejectQty?.message}
  112. />
  113. </Grid>
  114. </Grid>
  115. <Grid
  116. container
  117. justifyContent="flex-start"
  118. alignItems="flex-start"
  119. spacing={2}
  120. sx={{ mt: 0.5 }}
  121. ></Grid>
  122. </Grid>
  123. );
  124. };
  125. export default ApprovalContent;