Browse Source

update escalation

master
cyril.tsui 6 days ago
parent
commit
054b874ba9
4 changed files with 23 additions and 11 deletions
  1. +3
    -0
      src/app/(main)/dashboard/page.tsx
  2. +4
    -3
      src/app/api/dashboard/index.ts
  3. +6
    -3
      src/components/DashboardPage/DashboardPage.tsx
  4. +10
    -5
      src/components/DashboardPage/DashboardWrapper.tsx

+ 3
- 0
src/app/(main)/dashboard/page.tsx View File

@@ -4,6 +4,7 @@ import { Suspense } from "react";
import { getServerI18n } from "@/i18n"; import { getServerI18n } from "@/i18n";
import DashboardPage from "@/components/DashboardPage"; import DashboardPage from "@/components/DashboardPage";
import { SearchParams } from "@/app/utils/fetchUtil"; import { SearchParams } from "@/app/utils/fetchUtil";
import { fetchEscalationLogsByUser } from "@/app/api/escalation";


export const metadata: Metadata = { export const metadata: Metadata = {
title: "Dashboard", title: "Dashboard",
@@ -14,6 +15,8 @@ type Props = {} & SearchParams;
const Dashboard: React.FC<Props> = async ({ searchParams }) => { const Dashboard: React.FC<Props> = async ({ searchParams }) => {
const { t } = await getServerI18n("dashboard"); const { t } = await getServerI18n("dashboard");


fetchEscalationLogsByUser()

return ( return (
<I18nProvider namespaces={["dashboard", "common"]}> <I18nProvider namespaces={["dashboard", "common"]}>
<Suspense fallback={<DashboardPage.Loading />}> <Suspense fallback={<DashboardPage.Loading />}>


+ 4
- 3
src/app/api/dashboard/index.ts View File

@@ -84,7 +84,8 @@ export const fetchPoWithStockInLines = cache(async (id: number) => {
}); });


export const fetchIqcLogByUser = cache(async () => { export const fetchIqcLogByUser = cache(async () => {
return serverFetchJson<IQCItems[]>(`${BASE_API_URL}/supervisionApprovalLog/stock-in`, {
next: { tags: ["qcLog"] },
});
// return serverFetchJson<IQCItems[]>(`${BASE_API_URL}/supervisionApprovalLog/stock-in`, {
// next: { tags: ["qcLog"] },
// });
return undefined;
}); });

+ 6
- 3
src/components/DashboardPage/DashboardPage.tsx View File

@@ -15,12 +15,15 @@ import OrderCompletionChart from "./chart/OrderCompletionChart";
import DashboardBox from "./Dashboardbox"; import DashboardBox from "./Dashboardbox";
import CollapsibleCard from "./CollapsibleCard"; import CollapsibleCard from "./CollapsibleCard";
import SupervisorQcApproval, { IQCItems } from "./QC/SupervisorQcApproval"; import SupervisorQcApproval, { IQCItems } from "./QC/SupervisorQcApproval";
import { EscalationResult } from "@/app/api/escalation";
type Props = { type Props = {
iqc: IQCItems[]
// iqc: IQCItems[] | undefined
escalationLogs: EscalationResult[]
}; };


const DashboardPage: React.FC<Props> = ({ const DashboardPage: React.FC<Props> = ({
iqc
// iqc,
escalationLogs
}) => { }) => {
const { t } = useTranslation("dashboard"); const { t } = useTranslation("dashboard");
const router = useRouter(); const router = useRouter();
@@ -31,7 +34,7 @@ const DashboardPage: React.FC<Props> = ({
<Grid item xs={12}> <Grid item xs={12}>
<CollapsibleCard title={t("stock in escalation list")}> <CollapsibleCard title={t("stock in escalation list")}>
<CardContent> <CardContent>
<SupervisorQcApproval items={iqc || []}/>
<SupervisorQcApproval items={escalationLogs || []}/>
</CardContent> </CardContent>
</CollapsibleCard> </CollapsibleCard>
</Grid> </Grid>


+ 10
- 5
src/components/DashboardPage/DashboardWrapper.tsx View File

@@ -4,7 +4,8 @@ import DashboardPage from "./DashboardPage";
import { Typography } from "@mui/material"; import { Typography } from "@mui/material";
import { I18nProvider, getServerI18n } from "@/i18n"; import { I18nProvider, getServerI18n } from "@/i18n";
import DashboardLoading from "./DashboardLoading"; import DashboardLoading from "./DashboardLoading";
import { fetchIqcLogByUser } from "@/app/api/dashboard";
import { fetchEscalationLogsByUser } from "@/app/api/escalation";
// import { fetchIqcLogByUser } from "@/app/api/dashboard";


// export type SessionWithAbilities = { // export type SessionWithAbilities = {
// abilities: string[] // abilities: string[]
@@ -23,16 +24,20 @@ const DashboardWrapper: React.FC<Props> & SubComponents = async ({
}) => { }) => {
const { t } = await getServerI18n("dashboard"); const { t } = await getServerI18n("dashboard");
// const session: SessionWithAbilities = await getServerSession(authOptions) // const session: SessionWithAbilities = await getServerSession(authOptions)
const [iqcLog] = await Promise.all([
fetchIqcLogByUser()
// const [iqcLog] = await Promise.all([
// fetchIqcLogByUser()
// ])

const [escalationLogs] = await Promise.all([
fetchEscalationLogsByUser()
]) ])
console.log(iqcLog)
return ( return (
<> <>
<Typography variant="h4">{t("Dashboard")}</Typography> <Typography variant="h4">{t("Dashboard")}</Typography>
<DashboardPage <DashboardPage
iqc={iqcLog}
escalationLogs={escalationLogs}
// iqc={iqcLog}
// abilities={session ? session?.abilities : []} // abilities={session ? session?.abilities : []}
/> />
</> </>


Loading…
Cancel
Save