Parcourir la source

Add project total fee

tags/Baseline_30082024_FRONTEND_UAT
Wayne il y a 1 an
Parent
révision
29a4515eb1
3 fichiers modifiés avec 50 ajouts et 5 suppressions
  1. +1
    -1
      src/components/CreateProject/MilestoneSection.tsx
  2. +47
    -0
      src/components/CreateProject/ProjectTotalFee.tsx
  3. +2
    -4
      src/components/CreateProject/ResourceMilestone.tsx

+ 1
- 1
src/components/CreateProject/MilestoneSection.tsx Voir le fichier

@@ -218,7 +218,7 @@ const MilestoneSection: React.FC<Props> = ({ taskGroupId }) => {
return (
<Stack gap={1}>
<Typography variant="overline" display="block" marginBlockEnd={1}>
{t("Milestone")}
{t("Task Stage Milestones")}
</Typography>
<LocalizationProvider dateAdapter={AdapterDayjs} adapterLocale="zh-hk">
<Grid container spacing={2} columns={{ xs: 6, sm: 12 }}>


+ 47
- 0
src/components/CreateProject/ProjectTotalFee.tsx Voir le fichier

@@ -0,0 +1,47 @@
import { CreateProjectInputs } from "@/app/api/projects/actions";
import { TaskGroup } from "@/app/api/tasks";
import { moneyFormatter } from "@/app/utils/formatUtil";
import { Divider, Stack, Typography } from "@mui/material";
import React from "react";
import { useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";

interface Props {
taskGroups: TaskGroup[];
}

const ProjectTotalFee: React.FC<Props> = ({ taskGroups }) => {
const { t } = useTranslation();
const { watch } = useFormContext<CreateProjectInputs>();
const milestones = watch("milestones");

let projectTotal = 0;

return (
<Stack spacing={1}>
{taskGroups.map((group, index) => {
const payments = milestones[group.id]?.payments || [];
const paymentTotal = payments.reduce((acc, p) => acc + p.amount, 0);
projectTotal += paymentTotal;

return (
<Stack
key={`${group.id}-${index}`}
direction="row"
justifyContent="space-between"
>
<Typography variant="subtitle2">{group.name}</Typography>
<Typography>{moneyFormatter.format(paymentTotal)}</Typography>
</Stack>
);
})}
<Divider sx={{ paddingBlockStart: 2 }} />
<Stack direction="row" justifyContent="space-between">
<Typography variant="h6">{t("Project Total Fee")}</Typography>
<Typography>{moneyFormatter.format(projectTotal)}</Typography>
</Stack>
</Stack>
);
};

export default ProjectTotalFee;

+ 2
- 4
src/components/CreateProject/ResourceMilestone.tsx Voir le fichier

@@ -24,6 +24,7 @@ import { useFormContext } from "react-hook-form";
import { CreateProjectInputs } from "@/app/api/projects/actions";
import MilestoneSection from "./MilestoneSection";
import ResourceSection from "./ResourceSection";
import ProjectTotalFee from "./ProjectTotalFee";

export interface Props {
allTasks: Task[];
@@ -94,10 +95,7 @@ const ResourceMilestone: React.FC<Props> = ({
</Card>
<Card>
<CardContent>
<Stack direction="row" justifyContent="space-between">
<Typography variant="h6">{t("Project Total Fee")}</Typography>
<Typography>{moneyFormatter.format(80000)}</Typography>
</Stack>
<ProjectTotalFee taskGroups={taskGroups} />
</CardContent>
</Card>
</>


Chargement…
Annuler
Enregistrer