Просмотр исходного кода

Do not check daily time limit for today and expand timesheet to 10 days

tags/Baseline_30082024_FRONTEND_UAT
Wayne 1 год назад
Родитель
Сommit
3241541533
6 измененных файлов: 14 добавлений и 7 удалений
  1. +4
    -1
      src/app/api/timesheets/utils.ts
  2. +1
    -1
      src/components/LeaveModal/LeaveCalendar.tsx
  3. +4
    -2
      src/components/TimeLeaveModal/TimeLeaveModal.tsx
  4. +3
    -1
      src/components/TimesheetAmendment/TimesheetAmendment.tsx
  5. +1
    -1
      src/components/TimesheetTable/FastTimeEntryModal.tsx
  6. +1
    -1
      src/components/UserWorkspacePage/UserWorkspacePage.tsx

+ 4
- 1
src/app/api/timesheets/utils.ts Просмотреть файл

@@ -3,7 +3,7 @@ import { HolidaysResult } from "../holidays";
import { LeaveEntry, RecordTimeLeaveInput, TimeEntry } from "./actions";
import { convertDateArrayToString } from "@/app/utils/formatUtil";
import compact from "lodash/compact";
import dayjs from "dayjs";
import dayjs, { Dayjs } from "dayjs";

export type TimeEntryError = {
[field in keyof TimeEntry]?: string;
@@ -117,6 +117,7 @@ export const validateTimeLeaveRecord = (

// Check total hours
const totalHourError = checkTotalHours(
dayJsObj,
entries.filter((e) => e.type === "timeEntry") as TimeEntry[],
entries.filter((e) => e.type === "leaveEntry") as LeaveEntry[],
isHoliday,
@@ -132,6 +133,7 @@ export const validateTimeLeaveRecord = (
};

export const checkTotalHours = (
dayJsObj: Dayjs,
timeEntries: TimeEntry[],
leaves: LeaveEntry[],
isHoliday?: boolean,
@@ -152,6 +154,7 @@ export const checkTotalHours = (
} else if (
isFullTime &&
!isHoliday &&
!dayJsObj.isSame(dayjs(), "day") &&
totalInputHours + leaveHours !== DAILY_NORMAL_MAX_HOURS
) {
return "The daily normal hours (timesheet hours + leave hours) for full-time staffs should be {{DAILY_NORMAL_MAX_HOURS}}.";


+ 1
- 1
src/components/LeaveModal/LeaveCalendar.tsx Просмотреть файл

@@ -27,7 +27,6 @@ import LeaveEditModal from "../LeaveTable/LeaveEditModal";
import dayjs from "dayjs";
import { checkTotalHours } from "@/app/api/timesheets/utils";
import unionBy from "lodash/unionBy";
import { ConnectingAirportsOutlined } from "@mui/icons-material";

export interface Props {
leaveTypes: LeaveType[];
@@ -232,6 +231,7 @@ const LeaveCalendar: React.FC<Props> = ({
);

const totalHourError = checkTotalHours(
dayJsObj,
timesheets,
leavesWithNewEntry,
Boolean(isHoliday),


+ 4
- 2
src/components/TimeLeaveModal/TimeLeaveModal.tsx Просмотреть файл

@@ -64,6 +64,8 @@ const modalSx: SxProps = {
maxWidth: 1400,
};

const DAYS_TO_SHOW = 10;

const TimeLeaveModal: React.FC<Props> = ({
isOpen,
onClose,
@@ -81,7 +83,7 @@ const TimeLeaveModal: React.FC<Props> = ({

const defaultValues = useMemo(() => {
const today = dayjs();
return Array(7)
return Array(DAYS_TO_SHOW)
.fill(undefined)
.reduce<RecordTimeLeaveInput>((acc, _, index) => {
const date = today.subtract(index, "day").format(INPUT_DATE_FORMAT);
@@ -123,7 +125,7 @@ const TimeLeaveModal: React.FC<Props> = ({
const savedRecords = await saveTimeLeave(data);

const today = dayjs();
const newFormValues = Array(7)
const newFormValues = Array(DAYS_TO_SHOW)
.fill(undefined)
.reduce<RecordTimeLeaveInput>((acc, _, index) => {
const date = today.subtract(index, "day").format(INPUT_DATE_FORMAT);


+ 3
- 1
src/components/TimesheetAmendment/TimesheetAmendment.tsx Просмотреть файл

@@ -41,7 +41,7 @@ import LeaveEditModal from "../LeaveTable/LeaveEditModal";
import dayjs from "dayjs";
import { checkTotalHours } from "@/app/api/timesheets/utils";
import unionBy from "lodash/unionBy";
import { Language, Luggage, MoreTime } from "@mui/icons-material";
import { Luggage, MoreTime } from "@mui/icons-material";
import { Task } from "@/app/api/tasks";

export interface Props {
@@ -368,6 +368,7 @@ const TimesheetAmendment: React.FC<Props> = ({
"id",
);
totalHourError = checkTotalHours(
dayJsObj,
timesheets,
leavesWithNewEntry,
Boolean(isHoliday),
@@ -380,6 +381,7 @@ const TimesheetAmendment: React.FC<Props> = ({
"id",
);
totalHourError = checkTotalHours(
dayJsObj,
timesheetsWithNewEntry,
leaves,
Boolean(isHoliday),


+ 1
- 1
src/components/TimesheetTable/FastTimeEntryModal.tsx Просмотреть файл

@@ -68,7 +68,7 @@ const getID = () => {
};

const MISC_TASK_GROUP_ID = 5;
const FAST_ENTRY_TASK_ID = 43;
const FAST_ENTRY_TASK_ID = 42;

const FastTimeEntryModal: React.FC<Props> = ({
onSave,


+ 1
- 1
src/components/UserWorkspacePage/UserWorkspacePage.tsx Просмотреть файл

@@ -61,7 +61,7 @@ const UserWorkspacePage: React.FC<Props> = ({
maintainNormalStaffWorkspaceAbility,
maintainManagementStaffWorkspaceAbility,
isFullTime,
miscTasks
miscTasks,
}) => {
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);



Загрузка…
Отмена
Сохранить