Bläddra i källkod

[Timesheet Amendment] Quick fix for 208

main
cyril.tsui 1 månad sedan
förälder
incheckning
d4dc80663a
3 ändrade filer med 48 tillägg och 4 borttagningar
  1. +24
    -1
      src/components/TimesheetAmendment/TimesheetAmendment.tsx
  2. +8
    -1
      src/components/TimesheetAmendment/TimesheetAmendmentModal.tsx
  3. +16
    -2
      src/components/UserWorkspacePage/UserWorkspacePage.tsx

+ 24
- 1
src/components/TimesheetAmendment/TimesheetAmendment.tsx Visa fil

@@ -53,6 +53,8 @@ export interface Props {
miscTasks: Task[];
isSaturdayWorker: boolean;
userId: number;
handleTeamTimesheetsUpdate: (ts: TeamTimeSheets) => void;
handleTeamLeavesUpdate: (le: TeamLeaves) => void;
}

type MemberOption = TeamTimeSheets[0] & TeamLeaves[0] & { id: string };
@@ -82,7 +84,9 @@ const TimesheetAmendment: React.FC<Props> = ({
leaveTypes,
miscTasks,
isSaturdayWorker,
userId
userId,
handleTeamTimesheetsUpdate,
handleTeamLeavesUpdate,
}) => {
const { t, i18n:{language}} = useTranslation(["home", "common"]);
const locale = language === "zh" ? "zh-tw" : "en";
@@ -412,6 +416,7 @@ const TimesheetAmendment: React.FC<Props> = ({
entry: timeEntry,
recordDate,
});

setLocalTeamTimesheets((timesheets) => ({
...timesheets,
[intStaffId]: {
@@ -419,6 +424,15 @@ const TimesheetAmendment: React.FC<Props> = ({
timeEntries: newMemberTimesheets,
},
}));

handleTeamTimesheetsUpdate({
...localTeamTimesheets,
[intStaffId]: {
...localTeamTimesheets[intStaffId],
timeEntries: newMemberTimesheets,
},
});

setEditModalOpen(false);
},
[checkTotalHoursForDate, selectedStaff.id],
@@ -440,6 +454,15 @@ const TimesheetAmendment: React.FC<Props> = ({
leaveEntries: newMemberLeaves,
},
}));

handleTeamLeavesUpdate({
...localTeamLeaves,
[intStaffId]: {
...localTeamLeaves[intStaffId],
leaveEntries: newMemberLeaves,
},
});

setLeaveEditModalOpen(false);
},
[checkTotalHoursForDate, selectedStaff.id],


+ 8
- 1
src/components/TimesheetAmendment/TimesheetAmendmentModal.tsx Visa fil

@@ -13,6 +13,7 @@ import { useTranslation } from "react-i18next";
import TimesheetAmendment, {
Props as TimesheetAmendmentProps,
} from "./TimesheetAmendment";
// import { TeamLeaves, TeamTimeSheets } from "@/app/api/timesheets";

const modalSx: SxProps = {
position: "absolute",
@@ -28,6 +29,8 @@ interface Props extends TimesheetAmendmentProps {
open: boolean;
onClose: () => void;
isSaturdayWorker: boolean;
handleTeamLeavesUpdate: (le: any) => void;
handleTeamTimesheetsUpdate: (ts: any) => void;
}

export const TimesheetAmendmentModal: React.FC<Props> = ({
@@ -40,7 +43,9 @@ export const TimesheetAmendmentModal: React.FC<Props> = ({
allProjects,
miscTasks,
isSaturdayWorker,
userId
userId,
handleTeamLeavesUpdate,
handleTeamTimesheetsUpdate
}) => {
const { t } = useTranslation("home");
const isMobile = useIsMobile();
@@ -56,6 +61,8 @@ export const TimesheetAmendmentModal: React.FC<Props> = ({
miscTasks={miscTasks}
isSaturdayWorker={isSaturdayWorker}
userId={userId}
handleTeamLeavesUpdate={handleTeamLeavesUpdate}
handleTeamTimesheetsUpdate={handleTeamTimesheetsUpdate}
/>
);



+ 16
- 2
src/components/UserWorkspacePage/UserWorkspacePage.tsx Visa fil

@@ -70,6 +70,9 @@ const UserWorkspacePage: React.FC<Props> = ({
isSaturdayWorker,
userId
}) => {
const [latestTeamTimesheets, setLatestTeamTimesheets] = useState(teamTimesheets)
const [latestTeamLeaves, setLatestTeamLeaves] = useState(teamLeaves)

const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);

const [isTimeLeaveModalVisible, setTimeLeaveModalVisible] = useState(false);
@@ -128,6 +131,15 @@ const UserWorkspacePage: React.FC<Props> = ({
revalidateCacheAfterAmendment();
}, []);


const handleTeamTimesheetsUpdate = useCallback((ts: TeamTimeSheets) => {
setLatestTeamTimesheets(() => ts)
}, [])

const handleTeamLeavesUpdate = useCallback((le: TeamLeaves) => {
setLatestTeamLeaves(() => le)
}, [])

return (
<>
<Stack
@@ -235,8 +247,10 @@ const UserWorkspacePage: React.FC<Props> = ({
allProjects={allProjects}
leaveTypes={leaveTypes}
companyHolidays={holidays}
teamLeaves={teamLeaves}
teamTimesheets={teamTimesheets}
teamLeaves={latestTeamLeaves}
handleTeamLeavesUpdate={handleTeamLeavesUpdate}
teamTimesheets={latestTeamTimesheets}
handleTeamTimesheetsUpdate={handleTeamTimesheetsUpdate}
open={isTimesheetAmendmentVisible}
onClose={handleAmendmentClose}
miscTasks={miscTasks}


Laddar…
Avbryt
Spara