Skip to content

Commit 3366baa

Browse files
Merge pull request #2 from niscy-eudiw/feat/make-all-pages-dynamic
refactor: enable dynamic rendering and consolidate credential types
2 parents 5fe89b2 + 14af547 commit 3366baa

File tree

13 files changed

+65
-62
lines changed

13 files changed

+65
-62
lines changed

src/app/api/applications/qr-issue/[id]/route.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// src/app/api/applications/qr-issue/[id]/route.ts
22
import { NextResponse } from "next/server";
3-
import { Container } from "@/server";
4-
import { ApplicationService } from "@/server/services/ApplicationService";
5-
import { IssuerService } from "@/server/services/IssuerService";
63
import QRCode from "qrcode";
74

85
export async function GET(_req: Request, ctx: { params: Promise<{ id: string }> }) {

src/app/applications/[id]/confirmation/page.tsx

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { Chip } from "@mui/material";
1818
import SchoolIcon from "@mui/icons-material/School";
1919
import DirectionsBoatIcon from "@mui/icons-material/DirectionsBoat";
2020
import BadgeIcon from "@mui/icons-material/Badge";
21-
import LogoBanner from "@/components/atoms/LogoBanner";
2221

2322

2423
function Field({ label, value }: { label: string; value?: string | null }) {
@@ -155,35 +154,34 @@ export default async function ApplicationConfirmationPage({
155154
Verified Credentials:
156155
</Typography>
157156
<Stack direction="row" spacing={1} flexWrap="wrap" useFlexGap>
158-
{verifiedCredentials.map((cred) => {
159-
const isVerified = cred.status === "VERIFIED";
160-
const isPending = cred.status === "PENDING";
161-
162-
let icon = <BadgeIcon />;
163-
let label = cred.credentialType;
164-
165-
if (cred.credentialType === "PID") {
166-
icon = <BadgeIcon />;
167-
label = "PID (Person Identification)";
168-
} else if (cred.credentialType === "DIPLOMA") {
169-
icon = <SchoolIcon />;
170-
label = "Diploma";
171-
} else if (cred.credentialType === "SEAFARER") {
172-
icon = <DirectionsBoatIcon />;
173-
label = "Seafarer Certificate";
174-
}
175-
176-
return (
177-
<Chip
178-
key={cred.id}
179-
icon={icon}
180-
label={label}
181-
color={isVerified ? "success" : isPending ? "warning" : "default"}
182-
size="small"
183-
variant="filled"
184-
/>
185-
);
186-
})}
157+
{verifiedCredentials
158+
.filter((cred) => cred.status === "VERIFIED")
159+
.map((cred) => {
160+
let icon = <BadgeIcon />;
161+
let label: string = cred.credentialType;
162+
163+
if (cred.credentialType === "PID") {
164+
icon = <BadgeIcon />;
165+
label = "PID (Person Identification)";
166+
} else if (cred.credentialType === "DIPLOMA") {
167+
icon = <SchoolIcon />;
168+
label = "Diploma";
169+
} else if (cred.credentialType === "SEAFARER") {
170+
icon = <DirectionsBoatIcon />;
171+
label = "Seafarer Certificate";
172+
}
173+
174+
return (
175+
<Chip
176+
key={cred.id}
177+
icon={icon}
178+
label={label}
179+
color="success"
180+
size="small"
181+
variant="filled"
182+
/>
183+
);
184+
})}
187185
</Stack>
188186
</Grid>
189187
</Box>

src/app/applications/[id]/employee/page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export default async function EmployeeCredentialPage({
6060
}
6161

6262
const otp = existingCredential?.otp;
63-
const title = app.job?.title ?? "Application";
6463

6564
return (
6665
<main>

src/app/applications/[id]/extras/page.tsx

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,34 +42,20 @@ export default async function ApplicationExtrasPage({
4242
if (extrasCredentials.length === 0) return notFound();
4343

4444
// Determine what was requested based on credentials
45-
let extrasCredentialType: string;
4645
const hasDiploma = extrasCredentials.some((c) => c.credentialType === "DIPLOMA");
4746
const hasSeafarer = extrasCredentials.some((c) => c.credentialType === "SEAFARER");
4847

48+
let extrasCredentialTypeLabel: string;
4949
if (hasDiploma && hasSeafarer) {
50-
extrasCredentialType = "BOTH";
50+
extrasCredentialTypeLabel = "Diploma & Seafarer Certificate";
5151
} else if (hasDiploma) {
52-
extrasCredentialType = "DIPLOMA";
52+
extrasCredentialTypeLabel = "Diploma";
5353
} else {
54-
extrasCredentialType = "SEAFARER";
54+
extrasCredentialTypeLabel = "Seafarer Certificate";
5555
}
5656

5757
const title = app.job?.title ?? "Application";
5858

59-
// Format credential type for display
60-
const formatCredentialType = (type: string) => {
61-
switch (type) {
62-
case "BOTH":
63-
return "Diploma & Seafarer Certificate";
64-
case "DIPLOMA":
65-
return "Diploma";
66-
case "SEAFARER":
67-
return "Seafarer Certificate";
68-
default:
69-
return type;
70-
}
71-
};
72-
7359
return (
7460
<main>
7561
<Card variant="outlined">
@@ -88,7 +74,7 @@ export default async function ApplicationExtrasPage({
8874
Application ID: <strong>{app.id}</strong>
8975
</Typography>
9076
<Typography variant="body2" color="text.secondary">
91-
Requesting: <strong>{formatCredentialType(app.extrasCredentialType)}</strong>
77+
Requesting: <strong>{extrasCredentialTypeLabel}</strong>
9278
</Typography>
9379
</>
9480
}

src/app/jobs/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import "server-only";
22
import Link from "next/link";
33
import { Container } from "@/server";
44
import { JobService } from "@/server/services/JobService";
5+
6+
export const dynamic = "force-dynamic";
57
import {
68
Box,
79
Button,

src/app/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { Metadata } from 'next/types';
66

77
export const metadata: Metadata = { title: 'Recruitment Service Demo' };
88

9+
export const dynamic = "force-dynamic";
10+
911

1012
export default function RootLayout({ children }: { children: ReactNode }) {
1113
return (

src/app/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
export const dynamic = "force-dynamic";
2+
13
export { default } from "./jobs/page";

src/components/atoms/CredentialRequirementChips.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import { Chip, Stack, Typography } from "@mui/material";
44
import SchoolIcon from "@mui/icons-material/School";
55
import DirectionsBoatIcon from "@mui/icons-material/DirectionsBoat";
6-
7-
export type CredentialType = 'NONE' | 'DIPLOMA' | 'SEAFARER' | 'BOTH' | 'PID';
6+
import type { CredentialType } from "@/server/domain/types";
87

98
interface CredentialRequirementChipsProps {
109
requiredCredentials: CredentialType;

src/server/domain/entities/Job.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CredentialType } from "./Application";
1+
import { CredentialType } from "../types";
22

33
export class Job {
44
private constructor(

src/server/domain/mappers/JobMapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { JobPosting as PrismaJob } from "@prisma/client";
22
import { Job } from "../entities/Job";
3-
import type { CredentialType } from "../entities/Application";
3+
import type { CredentialType } from "../types";
44

55
export class JobMapper {
66
/**

0 commit comments

Comments
 (0)