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