FPSMS-frontend
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

DetailInfoCard.tsx 3.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. "use client";
  2. import {
  3. Box,
  4. Card,
  5. CardContent,
  6. FormControl,
  7. Grid,
  8. Stack,
  9. TextField,
  10. Typography,
  11. } from "@mui/material";
  12. import { Controller, useFormContext } from "react-hook-form";
  13. import { useTranslation } from "react-i18next";
  14. import InputDataGrid from "../InputDataGrid";
  15. import { useCallback, useEffect, useMemo, useState } from "react";
  16. import { GridColDef, GridRowModel } from "@mui/x-data-grid";
  17. import { InputDataGridProps, TableRow } from "../InputDataGrid/InputDataGrid";
  18. import { TypeEnum } from "@/app/utils/typeEnum";
  19. import { NumberInputProps } from "@/components/CreateItem/NumberInputProps";
  20. import { arrayToDateString, integerFormatter } from "@/app/utils/formatUtil";
  21. import { RoughProdScheduleResult } from "@/app/api/scheduling";
  22. import { DatePicker, LocalizationProvider } from "@mui/x-date-pickers";
  23. import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
  24. type Props = {
  25. isEditing: boolean;
  26. };
  27. const DetailInfoCard: React.FC<Props> = ({ isEditing }) => {
  28. const {
  29. t,
  30. i18n: { language },
  31. } = useTranslation();
  32. const {
  33. control,
  34. register,
  35. getValues,
  36. watch,
  37. formState: { errors, defaultValues, touchedFields },
  38. } = useFormContext<RoughProdScheduleResult>();
  39. // const [details, setDetails] = useState(null);
  40. useEffect(() => {
  41. console.log("[debug] record details", getValues());
  42. // setDetails(recordDetails);
  43. }, [getValues]);
  44. useEffect(() => {
  45. console.log("[debug] isEdit", isEditing);
  46. }, [isEditing]);
  47. return (
  48. <Card sx={{ display: "block" }}>
  49. <CardContent component={Stack} spacing={4}>
  50. <Box>
  51. {/* <Typography variant="overline" display="block" marginBlockEnd={1}>
  52. {t("Schedule Detail")}
  53. </Typography> */}
  54. <Grid container spacing={2} columns={{ xs: 6, sm: 12 }}>
  55. <Grid item xs={6}>
  56. <TextField
  57. label={t("Date")}
  58. fullWidth
  59. // {...register("scheduledPeriod", {
  60. // required: "name required!",
  61. // })}
  62. defaultValue={`${arrayToDateString(
  63. getValues("schedulePeriod"),
  64. )} - ${arrayToDateString(getValues("schedulePeriodTo"))}`}
  65. disabled={!isEditing}
  66. // error={Boolean(errors.name)}
  67. // helperText={errors.name?.message}
  68. />
  69. </Grid>
  70. <Grid item xs={6}>
  71. <TextField
  72. label={t("Total FG Item")}
  73. fullWidth
  74. // {...register("totalFGType", {
  75. // required: "Total FG Item required!",
  76. // })}
  77. defaultValue={
  78. typeof getValues("totalFGType") == "number"
  79. ? integerFormatter.format(getValues("totalFGType"))
  80. : getValues("totalFGType")
  81. }
  82. disabled={!isEditing}
  83. // error={Boolean(errors.code)}
  84. // helperText={errors.code?.message}
  85. />
  86. </Grid>
  87. <Grid item xs={6}>
  88. <TextField
  89. label={t("Total Estimated Demand Qty")}
  90. fullWidth
  91. // {...register("totalEstProdCount", {
  92. // required: "Qty required!",
  93. // })}
  94. disabled={!isEditing}
  95. defaultValue={
  96. typeof getValues("totalFGType") == "number"
  97. ? integerFormatter.format(getValues("totalEstProdCount"))
  98. : getValues("totalEstProdCount")
  99. }
  100. // error={Boolean(errors.type)}
  101. // helperText={errors.type?.message}
  102. />
  103. </Grid>
  104. </Grid>
  105. </Box>
  106. </CardContent>
  107. </Card>
  108. );
  109. };
  110. export default DetailInfoCard;