Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: restrict cv #64

Merged
merged 4 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/auth/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { auth, signIn } from "@/auth"
import Link from "@/components/Link"
import ThemedLogo from "@/components/ThemedLogo"

import styles from "./page.module.scss"

import { Button, Flex, Separator, Text } from "@radix-ui/themes"
import { Heading } from "@react-email/components"
import { AuthError } from "next-auth"
import Image from "next/image"
import { redirect } from "next/navigation"
import React from "react"

Expand Down Expand Up @@ -36,7 +36,7 @@ const LoginPage = async () => {
return (
<Flex gap="6" direction="column">
<Flex className={styles.logosContainer}>
<Image src="/images/imperial-logo-blue.svg" alt="imperial logo in blue" width={0} height={0} />
<ThemedLogo />
</Flex>
<Flex pl="9" pr="9" direction="column" gap="5">
<Flex direction="column" justify="center" align="center">
Expand Down
2 changes: 1 addition & 1 deletion app/auth/login/partner/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const LoginPage = () => {
</TextField.Root>

<Button size="3" style={{ width: "100%" }}>
{isPending ? <Spinner /> : "Sign In With Magic Link"}
{isPending ? <Spinner /> : "Sign in with magic link"}
</Button>
</form>
</Flex>
Expand Down
20 changes: 14 additions & 6 deletions app/students/[shortcode]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,20 @@ const StudentProfilePage = async ({ params }: { params: { shortcode: string } })
)}

{studentProfile.cv && (
<Flex align="center" gap="2" asChild>
<Link href={`/api/uploads/${studentProfile.cv}`} target="_blank" underline="none">
<BsFileEarmarkText title="download cv" color="black" />
<Text>{studentProfile.user.name?.split(",").reverse()[0].trim()}&apos;s CV</Text>
</Link>
</Flex>
<RestrictedArea
showMessage={false}
allowedRoles={["COMPANY", "STUDENT"]}
additionalCheck={async session =>
session.user.role === "COMPANY" || session.user.id === studentProfile.userId
}
>
<Flex align="center" gap="2" asChild>
<Link href={`/api/uploads/${studentProfile.cv}`} target="_blank" underline="none">
<BsFileEarmarkText title="download cv" color="var(--gray-12)" />
<Text>{studentProfile.user.name?.split(",").reverse()[0].trim()}&apos;s CV</Text>
</Link>
</Flex>
</RestrictedArea>
)}
<Flex align="center" gap="2">
<BsEnvelope />
Expand Down
19 changes: 19 additions & 0 deletions components/ThemedLogo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use client"

import { useTheme } from "next-themes"
import Image from "next/image"

const ThemedLogo = () => {
const { resolvedTheme } = useTheme()
let src

if (resolvedTheme === "dark") {
src = "/images/imperial-logo.svg"
} else {
src = "/images/imperial-logo-blue.svg"
}

return <Image src={src} alt="imperial logo" width={0} height={0} />
}

export default ThemedLogo
Loading