|
- import { LeaveEntry, TimeEntry } from "./actions";
-
- /**
- * @param entry - the time entry
- * @returns the field where there is an error, or an empty string if there is none
- */
- export const isValidTimeEntry = (entry: Partial<TimeEntry>): string => {
- // Test for errors
- let error: keyof TimeEntry | "" = "";
-
- // Either normal or other hours need to be inputted
- if (!entry.inputHours && !entry.otHours) {
- error = "inputHours";
- } else if (entry.inputHours && entry.inputHours <= 0) {
- error = "inputHours";
- } else if (entry.otHours && entry.otHours <= 0) {
- error = "otHours";
- }
-
- // If there is a project id, there should also be taskGroupId, taskId, inputHours
- if (entry.projectId) {
- if (!entry.taskGroupId) {
- error = "taskGroupId";
- } else if (!entry.taskId) {
- error = "taskId";
- }
- } else {
- if (!entry.remark) {
- error = "remark";
- }
- }
-
- return error;
- };
-
- export const isValidLeaveEntry = (entry: Partial<LeaveEntry>): string => {
- // Test for errrors
- let error: keyof LeaveEntry | "" = "";
- if (!entry.leaveTypeId) {
- error = "leaveTypeId";
- } else if (!entry.inputHours || !(entry.inputHours >= 0)) {
- error = "inputHours";
- }
-
- return error;
- };
-
- export const LEAVE_DAILY_MAX_HOURS = 8;
- export const TIMESHEET_DAILY_MAX_HOURS = 20;
|