Skip to content

Commit

Permalink
BREW UNINSTALL HARDCODED
Browse files Browse the repository at this point in the history
  • Loading branch information
marcfranquesa committed Mar 16, 2024
1 parent 67a21fa commit ab4deaa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/app/[slug]/submit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ProfileForm } from "@/components/Form"
import { db } from "@/lib/db"
import { getAuthSession } from "@/lib/auth"
import { notFound } from "next/navigation"
import { GCED_START } from "@/config"

interface PageProps {
params: {
Expand Down Expand Up @@ -34,10 +35,10 @@ const page = async ({ params }: PageProps) => {
<ProfileForm
PreselectedSubject={slug}
isAdmin={isAdmin}
generacio={session ? Number(session.user.generacio) : GCED_START}
semester={
subject.semester[0] === "Q" ? parseInt(subject.semester[1]) : 8
}
generacio={session ? Number(session.user.generacio) : 2017}
/>
</>
)
Expand Down
9 changes: 8 additions & 1 deletion src/app/submit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { getAuthSession } from "@/lib/auth"
import { ProfileForm } from "@/components/Form"
import { notFound } from "next/navigation"
import { GCED_START } from "@/config"

const page = async ({}) => {
const session = await getAuthSession()
const isAdmin = session?.user?.isAdmin
if (isAdmin === undefined) return notFound()
return <ProfileForm PreselectedSubject={"AllSubjects"} isAdmin={isAdmin} />
return (
<ProfileForm
PreselectedSubject={"AllSubjects"}
isAdmin={isAdmin}
generacio={session ? Number(session.user.generacio) : GCED_START}
/>
)
}

export default page
5 changes: 3 additions & 2 deletions src/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { Combobox } from "@/components/Combobox"
import { Checkbox } from "@/components/ui/checkbox"
import { ApuntsPostCreationRequest } from "@/lib/validators/post"
import { uploadFiles } from "@/lib/uploadthing"
import { GCED_START } from "@/config"

const formSchema = z.object({
pdf: z.any(),
Expand All @@ -46,13 +47,13 @@ const formSchema = z.object({
export function ProfileForm({
PreselectedSubject,
isAdmin,
generacio,
semester,
generacio = 2017,
}: {
PreselectedSubject: string
isAdmin: boolean
generacio: number
semester?: number
generacio?: number
}) {
const router = useRouter()

Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const INFINITE_SCROLL_PAGINATION_RESULTS = 4
export const GCED_START = 2017

2 comments on commit ab4deaa

@PauMatas
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Veig que em surt competència al Commit of The Month, entre aquest títol i l'altre video de youtube estas presentant candidatures

@marcfranquesa
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Veig que em surt competència al Commit of The Month, entre aquest títol i l'altre video de youtube estas presentant candidatures

Un ve a jugar 🙏

Please sign in to comment.