Browse Source

Small fixes

tags/Baseline_30082024_FRONTEND_UAT
Wayne 1 year ago
parent
commit
ab876f35f6
4 changed files with 16 additions and 8 deletions
  1. +1
    -1
      src/app/utils/formatUtil.ts
  2. +8
    -3
      src/components/CreateProject/CreateProject.tsx
  3. +4
    -4
      src/components/CreateProject/MilestoneSection.tsx
  4. +3
    -0
      src/components/TimesheetTable/EntryInputTable.tsx

+ 1
- 1
src/app/utils/formatUtil.ts View File

@@ -39,7 +39,7 @@ export const shortDateFormatter = (locale?: string) => {
} }
}; };


export function convertLocaleStringToNumber(numberString: String): number {
export function convertLocaleStringToNumber(numberString: string): number {
const numberWithoutCommas = numberString.replace(/,/g, ""); const numberWithoutCommas = numberString.replace(/,/g, "");
return parseFloat(numberWithoutCommas); return parseFloat(numberWithoutCommas);
} }

+ 8
- 3
src/components/CreateProject/CreateProject.tsx View File

@@ -61,7 +61,9 @@ const hasErrorsInTab = (
) => { ) => {
switch (tabIndex) { switch (tabIndex) {
case 0: case 0:
return errors.projectName;
return (
errors.projectName || errors.projectCode || errors.projectDescription
);
default: default:
false; false;
} }
@@ -101,7 +103,6 @@ const CreateProject: React.FC<Props> = ({
const onSubmit = useCallback<SubmitHandler<CreateProjectInputs>>( const onSubmit = useCallback<SubmitHandler<CreateProjectInputs>>(
async (data) => { async (data) => {
try { try {
console.log(data);
setServerError(""); setServerError("");
await saveProject(data); await saveProject(data);
router.replace("/projects"); router.replace("/projects");
@@ -115,7 +116,11 @@ const CreateProject: React.FC<Props> = ({
const onSubmitError = useCallback<SubmitErrorHandler<CreateProjectInputs>>( const onSubmitError = useCallback<SubmitErrorHandler<CreateProjectInputs>>(
(errors) => { (errors) => {
// Set the tab so that the focus will go there // Set the tab so that the focus will go there
if (errors.projectName) {
if (
errors.projectName ||
errors.projectDescription ||
errors.projectCode
) {
setTabIndex(0); setTabIndex(0);
} }
}, },


+ 4
- 4
src/components/CreateProject/MilestoneSection.tsx View File

@@ -29,7 +29,7 @@ import React, { useCallback, useEffect, useMemo, useState } from "react";
import { useFormContext } from "react-hook-form"; import { useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import StyledDataGrid from "../StyledDataGrid"; import StyledDataGrid from "../StyledDataGrid";
import { moneyFormatter } from "@/app/utils/formatUtil";
import { INPUT_DATE_FORMAT, moneyFormatter } from "@/app/utils/formatUtil";
import isDate from "lodash/isDate"; import isDate from "lodash/isDate";


interface Props { interface Props {
@@ -206,7 +206,7 @@ const MilestoneSection: React.FC<Props> = ({ taskGroupId }) => {
description: p.description!, description: p.description!,
id: p.id!, id: p.id!,
amount: p.amount!, amount: p.amount!,
date: dayjs(p.date!).toISOString(),
date: dayjs(p.date!).format(INPUT_DATE_FORMAT),
})), })),
}, },
}); });
@@ -245,7 +245,7 @@ const MilestoneSection: React.FC<Props> = ({ taskGroupId }) => {
...milestones, ...milestones,
[taskGroupId]: { [taskGroupId]: {
...milestones[taskGroupId], ...milestones[taskGroupId],
startDate: date.toISOString(),
startDate: date.format(INPUT_DATE_FORMAT),
}, },
}); });
}} }}
@@ -264,7 +264,7 @@ const MilestoneSection: React.FC<Props> = ({ taskGroupId }) => {
...milestones, ...milestones,
[taskGroupId]: { [taskGroupId]: {
...milestones[taskGroupId], ...milestones[taskGroupId],
endDate: date.toISOString(),
endDate: date.format(INPUT_DATE_FORMAT),
}, },
}); });
}} }}


+ 3
- 0
src/components/TimesheetTable/EntryInputTable.tsx View File

@@ -22,6 +22,9 @@ import { AssignedProject } from "@/app/api/projects";
import uniqBy from "lodash/uniqBy"; import uniqBy from "lodash/uniqBy";
import { TaskGroup } from "@/app/api/tasks"; import { TaskGroup } from "@/app/api/tasks";
import dayjs from "dayjs"; import dayjs from "dayjs";
import isBetween from "dayjs/plugin/isBetween";

dayjs.extend(isBetween);


const mockProjects: AssignedProject[] = [ const mockProjects: AssignedProject[] = [
{ {


Loading…
Cancel
Save