diff --git a/next.config.js b/next.config.js
index 3b56536..02b8bf2 100644
--- a/next.config.js
+++ b/next.config.js
@@ -3,6 +3,16 @@ const nextConfig = {
experimental: {
serverActions: true,
},
+ webpack: (config, { isServer }) => {
+ if (!isServer) {
+ // don't resolve 'fs' module on the client to prevent this error on build --> Error: Can't resolve 'fs'
+ config.resolve.fallback = {
+ fs: false,
+ };
+ }
+
+ return config;
+ },
};
module.exports = nextConfig;
diff --git a/src/app/dashboard/tools/exam-seating/exam/new/_components/NewExamForm.tsx b/src/app/dashboard/tools/exam-seating/exam/new/_components/NewExamForm.tsx
index f6c850f..27af974 100644
--- a/src/app/dashboard/tools/exam-seating/exam/new/_components/NewExamForm.tsx
+++ b/src/app/dashboard/tools/exam-seating/exam/new/_components/NewExamForm.tsx
@@ -230,7 +230,7 @@ function GenerateSection({
}, [finalBatches, finalHalls]);
return (
-
+
);
diff --git a/src/app/dashboard/tools/exam-seating/exam/new/_components/PDFgen.tsx b/src/app/dashboard/tools/exam-seating/exam/new/_components/PDFgen.tsx
index ec28b42..e068de7 100644
--- a/src/app/dashboard/tools/exam-seating/exam/new/_components/PDFgen.tsx
+++ b/src/app/dashboard/tools/exam-seating/exam/new/_components/PDFgen.tsx
@@ -171,7 +171,13 @@ export function GenerateSeatArrangements({
}: {
seats: ArrangedResult[];
}) {
- const [options, setOptions] = useState
>();
+ const [examPdf, setExamPdf] = useState(() => (
+
+ ));
+
+ const [instance, updateInstance] = usePDF({
+ document: ,
+ });
const form = useForm>({
resolver: zodResolver(seatingSchema),
@@ -183,11 +189,9 @@ export function GenerateSeatArrangements({
});
function onSubmit(data: z.infer) {
- setOptions(data);
+ updateInstance();
}
- const opts = useMemo(() => options, [options]);
-
return (
- {seats && }
+ {seats && instance.url && (
+
+ )}
@@ -310,93 +316,85 @@ export function ExamHallPDF({
);
}, [seats]);
const maxWidth = options?.alignment === "landscape" ? 842 : 595;
- const [, forceUpdate] = useReducer((x) => x + 1, 0);
-
- useEffect(() => {
- forceUpdate();
- }, [options]);
return (
-
-
- {seats.map((hall) => (
-
- {options?.title && options.title.length > 0 && (
-
- {options?.title}
-
- )}
-
- {hall.hallName}
-
-
- Seating arrangement
-
-
- FRONT SIDE
+
+ {seats.map((hall) => (
+
+ {options?.title && options.title !== "" && (
+
+ {options?.title}
-
- {hall.hallStructure.map((row, ri) => (
-
- {row.map((desks, i) => {
- const isBlank = desks.structure.every(
- (x) => x === SeatType.BLANK
- );
- return (
-
- {desks.structure.map((seat, di) => {
- const col =
- row
- .slice(0, i)
- .reduce((a, b) => a + b.seatCount, 0) + di;
+ )}
+
+ {hall.hallName}
+
+
+ Seating arrangement
+
+
+ FRONT SIDE
+
+
+ {hall.hallStructure.map((row, ri) => (
+
+ {row.map((desks, i) => {
+ const isBlank = desks.structure.every(
+ (x) => x === SeatType.BLANK
+ );
+ return (
+
+ {desks.structure.map((seat, di) => {
+ const col =
+ row.slice(0, i).reduce((a, b) => a + b.seatCount, 0) +
+ di;
- return (
-
+ {
+ return getSeatData(
+ ri,
+ col,
+ hall.seats,
+ options?.nameSelect
+ );
}}
- key={di}
- >
- {
- return getSeatData(
- ri,
- col,
- hall.seats,
- options?.nameSelect
- );
- }}
- />
-
- );
- })}
-
- );
- })}
-
- ))}
-
-
- Sign and designation of Invigilator
-
-
- ))}
-
-
+ />
+
+ );
+ })}
+
+ );
+ })}
+
+ ))}
+
+
+ Sign and designation of Invigilator
+
+
+ ))}
+
);
}
@@ -407,16 +405,10 @@ function getSeatData(
type?: string
) {
const seat = allocated.find((e) => e.row === row && e.seat === col);
+ console.log("Option", type);
+ console.log(seat);
if (type && seat && seat[type as keyof typeof seat]) {
return seat[type as keyof typeof seat];
}
return seat?.regNo || " ";
}
-
-export function GeneratePDF({ seats }: { seats: ArrangedResult[] }) {
- return (
-
-
-
- );
-}