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.
 
 

38 lines
975 B

  1. import {
  2. RecordLeaveInput,
  3. RecordTimesheetInput,
  4. } from "@/app/api/timesheets/actions";
  5. import React from "react";
  6. import { useFormContext } from "react-hook-form";
  7. import EntryInputTable from "./EntryInputTable";
  8. import { AssignedProject, ProjectWithTasks } from "@/app/api/projects";
  9. import DateHoursTable from "../DateHoursTable";
  10. interface Props {
  11. allProjects: ProjectWithTasks[];
  12. assignedProjects: AssignedProject[];
  13. leaveRecords: RecordLeaveInput;
  14. }
  15. const TimesheetTable: React.FC<Props> = ({
  16. allProjects,
  17. assignedProjects,
  18. leaveRecords,
  19. }) => {
  20. const { watch } = useFormContext<RecordTimesheetInput>();
  21. const currentInput = watch();
  22. const days = Object.keys(currentInput);
  23. return (
  24. <DateHoursTable
  25. days={days}
  26. leaveEntries={leaveRecords}
  27. timesheetEntries={currentInput}
  28. EntryTableComponent={EntryInputTable}
  29. entryTableProps={{ assignedProjects, allProjects }}
  30. />
  31. );
  32. };
  33. export default TimesheetTable;