Skip to content

Commit

Permalink
fix: next config and remove experimental features
Browse files Browse the repository at this point in the history
  • Loading branch information
amjed-ali-k committed Oct 28, 2023
1 parent 6a19f53 commit 9af60d2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 34 deletions.
16 changes: 1 addition & 15 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/** @type {import('next').NextConfig} */
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;
},
};
const nextConfig = {};

module.exports = nextConfig;
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import {
SelectValue,
} from "@/components/ui/select";
import { Button } from "@/components/ui/button";
import { usePermenantGet } from "@/lib/swr";
import { Subject } from "@prisma/client";

const commonStyle = StyleSheet.create({
page: {
Expand Down Expand Up @@ -432,6 +434,10 @@ export function GenerateHallsAssignment({
},
});

const { data: subjects, isLoading: isSubsLoading } = usePermenantGet<
Subject[]
>("/api/secure/subjects/all");

function onSubmit(data: z.infer<typeof hallschema>) {
const hl = seats.map((hall) => {
return {
Expand All @@ -441,7 +447,9 @@ export function GenerateHallsAssignment({
count: hall.seats.length,
};
});
updateInstance(<HallArrangementPDF seats={hl} options={data} />);
updateInstance(
<HallArrangementPDF seats={hl} options={data} subjects={subjects} />
);
}

return (
Expand Down Expand Up @@ -611,8 +619,6 @@ const hallStyle = StyleSheet.create({
display: "flex",
flexDirection: "column",
justifyContent: "flex-start",
paddingHorizontal: 10,
paddingVertical: 10,
flexWrap: "wrap",
},
contentItem: {
Expand All @@ -621,11 +627,20 @@ const hallStyle = StyleSheet.create({
fontWeight: "normal",
flex: 1,
},
contentSubTitle: {
fontSize: 10,
fontWeight: "semibold",
marginBottom: 5,
},
contentSubContainer: {
padding: 10,
},
});

function HallArrangementPDF({
seats,
options,
subjects,
}: {
seats: {
id: string;
Expand All @@ -634,6 +649,7 @@ function HallArrangementPDF({
count: number;
}[];
options?: z.infer<typeof seatingSchema>;
subjects?: Subject[];
}) {
return (
<Document>
Expand Down Expand Up @@ -666,23 +682,32 @@ function HallArrangementPDF({
<View key={subCode} style={{ width: "100%" }}>
<View style={hallStyle.contentTitleContainer}>
{/* Subject Name */}
<Text style={hallStyle.contentTitle}>{subCode}</Text>
<Text style={hallStyle.contentTitle}>
{subCode}
{" - " +
subjects?.find((e) => e.code === subCode)?.name}
</Text>
</View>
<View style={hallStyle.contentSubContainer}>
<Text style={hallStyle.contentSubTitle}>
Electronics
</Text>
<Text style={hallStyle.contentDetails}>
{/* Details */}
{details?.map((seat) => (
<Text
key={seat.name}
style={hallStyle.contentItem}
wrap
>
{seat[options?.nameSelect as keyof typeof seat] ||
seat.name ||
" "}
,{" "}
</Text>
))}
</Text>
</View>
<Text style={hallStyle.contentDetails}>
{/* Details */}
{details?.map((seat) => (
<Text
key={seat.name}
style={hallStyle.contentItem}
wrap
>
{seat[options?.nameSelect as keyof typeof seat] ||
seat.name ||
" "}
,{" "}
</Text>
))}
</Text>
</View>
))}
</View>
Expand Down

0 comments on commit 9af60d2

Please sign in to comment.