|
@@ -59,7 +59,7 @@ import { |
|
|
} from "../Swal/CustomAlerts"; |
|
|
} from "../Swal/CustomAlerts"; |
|
|
import dayjs from "dayjs"; |
|
|
import dayjs from "dayjs"; |
|
|
import { DELETE_PROJECT } from "@/middleware"; |
|
|
import { DELETE_PROJECT } from "@/middleware"; |
|
|
import { OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; |
|
|
|
|
|
|
|
|
import { OUTPUT_DATE_FORMAT, sumMoney } from "@/app/utils/formatUtil"; |
|
|
import { deleteDraft, loadDraft, saveToLocalStorage } from "@/app/utils/draftUtils"; |
|
|
import { deleteDraft, loadDraft, saveToLocalStorage } from "@/app/utils/draftUtils"; |
|
|
|
|
|
|
|
|
export interface Props { |
|
|
export interface Props { |
|
@@ -272,7 +272,7 @@ const CreateProject: React.FC<Props> = ({ |
|
|
const onSubmit = useCallback<SubmitHandler<CreateProjectInputs>>( |
|
|
const onSubmit = useCallback<SubmitHandler<CreateProjectInputs>>( |
|
|
async (data, event) => { |
|
|
async (data, event) => { |
|
|
try { |
|
|
try { |
|
|
console.log(data); |
|
|
|
|
|
|
|
|
// console.log(data); |
|
|
|
|
|
|
|
|
// detect errors |
|
|
// detect errors |
|
|
let hasErrors = false; |
|
|
let hasErrors = false; |
|
@@ -373,26 +373,38 @@ const CreateProject: React.FC<Props> = ({ |
|
|
data.milestones[parseFloat(key)].startDate = null |
|
|
data.milestones[parseFloat(key)].startDate = null |
|
|
data.milestones[parseFloat(key)].endDate = null |
|
|
data.milestones[parseFloat(key)].endDate = null |
|
|
} |
|
|
} |
|
|
// if ( |
|
|
|
|
|
// !Boolean(startDate) || |
|
|
|
|
|
// startDate === "Invalid Date" || |
|
|
|
|
|
// !Boolean(endDate) || |
|
|
|
|
|
// endDate === "Invalid Date" || |
|
|
|
|
|
// new Date(startDate) > new Date(endDate) |
|
|
|
|
|
// ) { |
|
|
|
|
|
// formProps.setError("milestones", { |
|
|
|
|
|
// message: "milestones is not valid", |
|
|
|
|
|
// type: "invalid", |
|
|
|
|
|
// }); |
|
|
|
|
|
// setTabIndex(3); |
|
|
|
|
|
// hasErrors = true; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
unused code for checking the stage start date and end date |
|
|
|
|
|
if ( |
|
|
|
|
|
!Boolean(startDate) || |
|
|
|
|
|
startDate === "Invalid Date" || |
|
|
|
|
|
!Boolean(endDate) || |
|
|
|
|
|
endDate === "Invalid Date" || |
|
|
|
|
|
new Date(startDate) > new Date(endDate) |
|
|
|
|
|
) { |
|
|
|
|
|
formProps.setError("milestones", { |
|
|
|
|
|
message: "milestones is not valid", |
|
|
|
|
|
type: "invalid", |
|
|
|
|
|
}); |
|
|
|
|
|
setTabIndex(3); |
|
|
|
|
|
hasErrors = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
unused code for bulk add milestone payment |
|
|
projectTotal += payments.reduce( |
|
|
projectTotal += payments.reduce( |
|
|
(acc, payment) => acc + payment.amount, |
|
|
(acc, payment) => acc + payment.amount, |
|
|
0, |
|
|
0, |
|
|
); |
|
|
); |
|
|
|
|
|
**/ |
|
|
|
|
|
|
|
|
|
|
|
projectTotal += payments.reduce( |
|
|
|
|
|
(acc, p) => sumMoney(acc, p.amount), |
|
|
|
|
|
0, |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
// console.log(projectTotal) |
|
|
console.log(milestonesKeys) |
|
|
console.log(milestonesKeys) |
|
|
|
|
|
|
|
|
if ( |
|
|
if ( |
|
|