FPSMS-frontend
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1 тиждень тому
20 години тому
1 тиждень тому
1 тиждень тому
1 тиждень тому
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import GeneralLoading from "@/components/General/GeneralLoading";
  2. import DetailedScheduleDetailView from "@/components/DetailedScheduleDetail/DetailedScheduleDetailView";
  3. import { ScheduleType, fetchDetailedProdScheduleDetail } from "@/app/api/scheduling";
  4. interface SubComponents {
  5. Loading: typeof GeneralLoading;
  6. }
  7. type EditDetailedScheduleDetailProps = {
  8. id?: number;
  9. type: ScheduleType;
  10. };
  11. type Props = EditDetailedScheduleDetailProps;
  12. const DetailedScheduleDetailWrapper: React.FC<Props> & SubComponents = async ({
  13. id,
  14. type,
  15. }) => {
  16. const prodSchedule = id ? await fetchDetailedProdScheduleDetail(id) : undefined;
  17. console.log("RAW API DATA:", prodSchedule?.prodScheduleLines[0]); // Check the actual keys here
  18. if (prodSchedule && prodSchedule.prodScheduleLines) {
  19. // 1. Map the lines to ensure the new fields are explicitly handled
  20. prodSchedule.prodScheduleLines = prodSchedule.prodScheduleLines.map(line => ({
  21. ...line,
  22. // If the API uses different names (e.g., 'stockQty'), map them here:
  23. // avgQtyLastMonth: line.avgQtyLastMonth ?? 0,
  24. // Ensure these keys match the 'field' property in your ViewByFGDetails.tsx columns
  25. avgQtyLastMonth: line.avgQtyLastMonth || 0,
  26. stockQty: line.stockQty || 0,
  27. daysLeft: line.daysLeft || 0,
  28. needNoOfJobOrder: line.needNoOfJobOrder || 0,
  29. outputQty: line.outputQty || 0,
  30. })).sort((a, b) => b.priority - a.priority);
  31. }
  32. return (
  33. <DetailedScheduleDetailView
  34. isEditMode={Boolean(id)}
  35. defaultValues={prodSchedule}
  36. type={type}
  37. />
  38. );
  39. };
  40. DetailedScheduleDetailWrapper.Loading = GeneralLoading;
  41. export default DetailedScheduleDetailWrapper;