| @@ -36,6 +36,7 @@ export interface Props { | |||
| timesheetRecords: RecordTimesheetInput; | |||
| isFullTime: boolean; | |||
| joinDate: Dayjs; | |||
| isSaturdayWorker: boolean | |||
| } | |||
| interface EventClickArg { | |||
| @@ -57,6 +58,7 @@ const LeaveCalendar: React.FC<Props> = ({ | |||
| leaveRecords, | |||
| isFullTime, | |||
| joinDate, | |||
| isSaturdayWorker | |||
| }) => { | |||
| const { | |||
| t, | |||
| @@ -190,7 +192,8 @@ const LeaveCalendar: React.FC<Props> = ({ | |||
| ({ event }: EventClickArg) => { | |||
| const dayJsObj = dayjs(event.startStr); | |||
| const holiday = getHolidayForDate(event.startStr, companyHolidays); | |||
| const isHoliday = holiday || dayJsObj.day() === 0 || dayJsObj.day() === 6; | |||
| const isWeekend = !isSaturdayWorker ? dayJsObj.day() === 0 || dayJsObj.day() === 6 : dayJsObj.day() === 0; | |||
| const isHoliday = holiday || isWeekend; | |||
| if ( | |||
| event.extendedProps.calendar === "leaveEntry" && | |||
| @@ -210,7 +213,8 @@ const LeaveCalendar: React.FC<Props> = ({ | |||
| (e: { dateStr: string; dayEl: HTMLElement }) => { | |||
| const dayJsObj = dayjs(e.dateStr); | |||
| const holiday = getHolidayForDate(e.dateStr, companyHolidays); | |||
| const isHoliday = holiday || dayJsObj.day() === 0 || dayJsObj.day() === 6; | |||
| const isWeekend = !isSaturdayWorker ? dayJsObj.day() === 0 || dayJsObj.day() === 6 : dayJsObj.day() === 0; | |||
| const isHoliday = holiday || isWeekend; | |||
| openLeaveEditModal(undefined, e.dateStr, Boolean(isHoliday)); | |||
| }, | |||
| @@ -224,7 +228,8 @@ const LeaveCalendar: React.FC<Props> = ({ | |||
| } | |||
| const dayJsObj = dayjs(date); | |||
| const holiday = getHolidayForDate(date, companyHolidays); | |||
| const isHoliday = holiday || dayJsObj.day() === 0 || dayJsObj.day() === 6; | |||
| const isWeekend = !isSaturdayWorker ? dayJsObj.day() === 0 || dayJsObj.day() === 6 : dayJsObj.day() === 0; | |||
| const isHoliday = holiday || isWeekend; | |||
| const leaves = localLeaveRecords[date] || []; | |||
| const timesheets = timesheetRecords[date] || []; | |||
| @@ -25,6 +25,7 @@ const modalSx: SxProps = { | |||
| interface Props extends LeaveCalendarProps { | |||
| open: boolean; | |||
| onClose: () => void; | |||
| isSaturdayWorker: boolean | |||
| } | |||
| const LeaveModal: React.FC<Props> = ({ | |||
| @@ -37,6 +38,7 @@ const LeaveModal: React.FC<Props> = ({ | |||
| timesheetRecords, | |||
| isFullTime, | |||
| joinDate, | |||
| isSaturdayWorker | |||
| }) => { | |||
| const { t } = useTranslation("home"); | |||
| const isMobile = useIsMobile(); | |||
| @@ -51,6 +53,7 @@ const LeaveModal: React.FC<Props> = ({ | |||
| allProjects={allProjects} | |||
| leaveRecords={leaveRecords} | |||
| timesheetRecords={timesheetRecords} | |||
| isSaturdayWorker={isSaturdayWorker} | |||
| /> | |||
| ); | |||
| @@ -51,6 +51,7 @@ export interface Props { | |||
| companyHolidays: HolidaysResult[]; | |||
| allProjects: ProjectWithTasks[]; | |||
| miscTasks: Task[]; | |||
| isSaturdayWorker: boolean | |||
| } | |||
| type MemberOption = TeamTimeSheets[0] & TeamLeaves[0] & { id: string }; | |||
| @@ -79,6 +80,7 @@ const TimesheetAmendment: React.FC<Props> = ({ | |||
| allProjects, | |||
| leaveTypes, | |||
| miscTasks, | |||
| isSaturdayWorker | |||
| }) => { | |||
| const { t, i18n:{language}} = useTranslation(["home", "common"]); | |||
| const locale = language === "zh" ? "zh-tw" : "en"; | |||
| @@ -306,7 +308,8 @@ const TimesheetAmendment: React.FC<Props> = ({ | |||
| ({ event }: EventClickArg) => { | |||
| const dayJsObj = dayjs(event.startStr); | |||
| const holiday = getHolidayForDate(event.startStr, companyHolidays); | |||
| const isHoliday = holiday || dayJsObj.day() === 0 || dayJsObj.day() === 6; | |||
| const isWeekend = !isSaturdayWorker ? dayJsObj.day() === 0 || dayJsObj.day() === 6 : dayJsObj.day() === 0; | |||
| const isHoliday = holiday || isWeekend; | |||
| if ( | |||
| event.extendedProps.calendar === "timeEntry" && | |||
| @@ -335,7 +338,8 @@ const TimesheetAmendment: React.FC<Props> = ({ | |||
| (e: { dateStr: string; dayEl: HTMLElement }) => { | |||
| const dayJsObj = dayjs(e.dateStr); | |||
| const holiday = getHolidayForDate(e.dateStr, companyHolidays); | |||
| const isHoliday = holiday || dayJsObj.day() === 0 || dayJsObj.day() === 6; | |||
| const isWeekend = !isSaturdayWorker ? dayJsObj.day() === 0 || dayJsObj.day() === 6 : dayJsObj.day() === 0; | |||
| const isHoliday = holiday || isWeekend; | |||
| setSelectedDateInfo({ | |||
| dateStr: e.dateStr, | |||
| isHoliday: Boolean(isHoliday), | |||
| @@ -352,7 +356,8 @@ const TimesheetAmendment: React.FC<Props> = ({ | |||
| } | |||
| const dayJsObj = dayjs(date); | |||
| const holiday = getHolidayForDate(date, companyHolidays); | |||
| const isHoliday = holiday || dayJsObj.day() === 0 || dayJsObj.day() === 6; | |||
| const isWeekend = !isSaturdayWorker ? dayJsObj.day() === 0 || dayJsObj.day() === 6 : dayJsObj.day() === 0; | |||
| const isHoliday = holiday || isWeekend; | |||
| const intStaffId = parseInt(selectedStaff.id); | |||
| const leaves = localTeamLeaves[intStaffId].leaveEntries[date] || []; | |||
| @@ -27,6 +27,7 @@ const modalSx: SxProps = { | |||
| interface Props extends TimesheetAmendmentProps { | |||
| open: boolean; | |||
| onClose: () => void; | |||
| isSaturdayWorker: boolean | |||
| } | |||
| export const TimesheetAmendmentModal: React.FC<Props> = ({ | |||
| @@ -38,6 +39,7 @@ export const TimesheetAmendmentModal: React.FC<Props> = ({ | |||
| companyHolidays, | |||
| allProjects, | |||
| miscTasks, | |||
| isSaturdayWorker | |||
| }) => { | |||
| const { t } = useTranslation("home"); | |||
| const isMobile = useIsMobile(); | |||
| @@ -51,6 +53,7 @@ export const TimesheetAmendmentModal: React.FC<Props> = ({ | |||
| teamTimesheets={teamTimesheets} | |||
| allProjects={allProjects} | |||
| miscTasks={miscTasks} | |||
| isSaturdayWorker={isSaturdayWorker} | |||
| /> | |||
| ); | |||
| @@ -185,7 +185,6 @@ const UserWorkspacePage: React.FC<Props> = ({ | |||
| allProjects={allProjects} | |||
| leaveTypes={leaveTypes} | |||
| companyHolidays={holidays} | |||
| isSaturdayWorker={isSaturdayWorker} | |||
| /> | |||
| <TimeLeaveModal | |||
| fastEntryEnabled={fastEntryEnabled} | |||
| @@ -212,6 +211,7 @@ const UserWorkspacePage: React.FC<Props> = ({ | |||
| timesheetRecords={defaultTimesheets} | |||
| isFullTime={isFullTime} | |||
| joinDate={dayjs(joinDate)} | |||
| isSaturdayWorker={isSaturdayWorker} | |||
| /> | |||
| {assignedProjects.length > 0 ? ( | |||
| <AssignedProjects | |||
| @@ -238,6 +238,7 @@ const UserWorkspacePage: React.FC<Props> = ({ | |||
| open={isTimesheetAmendmentVisible} | |||
| onClose={handleAmendmentClose} | |||
| miscTasks={miscTasks} | |||
| isSaturdayWorker={isSaturdayWorker} | |||
| /> | |||
| )} | |||
| </> | |||