Skip to content

Commit

Permalink
added neu validation
Browse files Browse the repository at this point in the history
  • Loading branch information
gpalmer27 committed Jan 30, 2025
2 parents ea79496 + 88a1f5a commit 8ad0714
Show file tree
Hide file tree
Showing 25 changed files with 731 additions and 130 deletions.
4 changes: 2 additions & 2 deletions apps/auth-proxy/routes/r/[...auth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export default eventHandler(async (event) =>
callbacks: {
async signIn({ user }) {

Check failure on line 18 in apps/auth-proxy/routes/r/[...auth].ts

View workflow job for this annotation

GitHub Actions / lint

Async method 'signIn' has no 'await' expression
const email = user?.email;

Check failure on line 19 in apps/auth-proxy/routes/r/[...auth].ts

View workflow job for this annotation

GitHub Actions / lint

Unnecessary optional chain on a non-nullish value

if (!email?.endsWith("@husky.neu.edu")) {
return false
return false;
}
return true;
},
Expand Down
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@trpc/react-query": "11.0.0-rc.441",
"@trpc/server": "11.0.0-rc.441",
"dayjs": "^1.11.13",
"fuse.js": "^7.0.0",
"geist": "^1.3.0",
"lucide-react": "^0.436.0",
"next": "^14.2.4",
Expand Down
49 changes: 21 additions & 28 deletions apps/web/public/svg/hidingLogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 12 additions & 7 deletions apps/web/src/app/(pages)/(dashboard)/companies/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { unstable_noStore as noStore } from "next/cache";

import NoResults from "~/app/_components/no-results";
import { RoleReviewCard } from "~/app/_components/reviews/role-review-card";
import SearchFilter from "~/app/_components/search/search-filter";
import { api } from "~/trpc/server";
Expand All @@ -20,13 +21,17 @@ export default async function Companies() {
return (
<>
<SearchFilter />
<div className="mb-8 grid h-[70dvh] w-3/4 grid-cols-1 gap-4 overflow-y-scroll md:grid-cols-2 xl:grid-cols-3">
{roles.map((role) => {
return (
<RoleReviewCard key={role.id} roleObj={role} className="mb-4" />
);
})}
</div>
{roles.length > 0 ? (
<div className="mb-8 grid h-[70dvh] w-3/4 grid-cols-1 gap-4 overflow-y-scroll md:grid-cols-2 xl:grid-cols-3">
{roles.map((role) => {
return (
<RoleReviewCard key={role.id} roleObj={role} className="mb-4" />
);
})}
</div>
) : (
<NoResults />
)}
</>
);
}
2 changes: 1 addition & 1 deletion apps/web/src/app/(pages)/(dashboard)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default function Home() {
return (
<div className="flex h-[85vh] flex-col">
<div className="flex h-full flex-col items-center justify-center">
<SearchFilter />
<SearchFilter alternatePathname="/roles" />
</div>
</div>
);
Expand Down
18 changes: 10 additions & 8 deletions apps/web/src/app/(pages)/(dashboard)/redirection/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import React from "react";

export default function ErrorPage() {

return (
<div className="min-h-screen flex items-center justify-center">
<div className="text-center">
<h1 className="text-2xl font-bold text-gray-900 mb-4">Authentication Error</h1>
<p className="text-gray-600 mb-4">You must log in with husky.neu.edu</p>
<p className="text-gray-600 mb-4">Click the sign in button to try again</p>
</div>
<div className="flex min-h-screen items-center justify-center">
<div className="text-center">
<h1 className="mb-4 text-2xl font-bold text-gray-900">
Authentication Error
</h1>
<p className="mb-4 text-gray-600">You must log in with husky.neu.edu</p>
<p className="mb-4 text-gray-600">
Click the sign in button to try again
</p>
</div>
</div>
);
}

34 changes: 22 additions & 12 deletions apps/web/src/app/(pages)/(dashboard)/roles/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
import { useEffect, useState } from "react";
import { z } from "zod";

import {
import type {
ReviewType,
WorkEnvironment,
WorkEnvironmentType,
WorkTerm,
WorkTermType,
} from "@cooper/db/schema";
import { WorkEnvironment, WorkTerm } from "@cooper/db/schema";
import { cn } from "@cooper/ui";
import { useToast } from "@cooper/ui/hooks/use-toast";

import LoadingResults from "~/app/_components/loading-results";
import NoResults from "~/app/_components/no-results";
import { ReviewCard } from "~/app/_components/reviews/review-card";
import { ReviewCardPreview } from "~/app/_components/reviews/review-card-preview";
import SearchFilter from "~/app/_components/search/search-filter";
Expand All @@ -22,6 +23,7 @@ export default function Roles({
searchParams,
}: {
searchParams?: {
search?: string;
cycle?: WorkTermType;
term?: WorkEnvironmentType;
};
Expand All @@ -47,33 +49,39 @@ export default function Roles({
useEffect(() => {
setMounted(true);
}, []);

useEffect(() => {
if (!mounted) {
return;
}
if (!validationResult.success) {
if (mounted && !validationResult.success) {
toast({
title: "Invalid search params",
title: "Invalid Search Parameters",
description: validationResult.error.issues
.map((issue) => issue.message)
.join(", "),
variant: "destructive",
});
setMounted(false);
}
}, [toast, mounted]);
}, [toast, mounted, validationResult]);

const reviews = api.review.list.useQuery({
search: searchParams?.search,
options: validationResult.success ? validationResult.data : {},
});

const [selectedReview, setSelectedReview] = useState<ReviewType | undefined>(
reviews.data ? reviews.data[0] : undefined,
reviews.isSuccess ? reviews.data[0] : undefined,
);

useEffect(() => {
if (reviews.isSuccess) {
setSelectedReview(reviews.data[0]);
}
}, [reviews.isSuccess, reviews.data]);

return (
<>
<SearchFilter />
{reviews.data && (
<SearchFilter search={searchParams?.search} {...validationResult.data} />
{reviews.isSuccess && reviews.data.length > 0 && (
<div className="mb-8 grid h-[70dvh] w-4/5 grid-cols-5 gap-4 lg:w-3/4">
<div className="col-span-2 gap-3 overflow-scroll pr-4">
{reviews.data.map((review, i) => {
Expand All @@ -100,6 +108,8 @@ export default function Roles({
</div>
</div>
)}
{reviews.isSuccess && reviews.data.length === 0 && <NoResults />}
{reviews.isPending && <LoadingResults />}
</>
);
}
2 changes: 1 addition & 1 deletion apps/web/src/app/_components/auth/login-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function LoginButton() {
className="rounded-xl border-cooper-blue-400 bg-cooper-blue-400 px-5 py-2.5 text-sm font-semibold text-white hover:border-cooper-blue-200 hover:bg-cooper-blue-200 hover:text-cooper-blue-600 focus:outline-none focus:ring-4 focus:ring-white"
formAction={async () => {
"use server";
await signIn("google");
await signIn("google", { redirectTo: "/" });
}}
>
Sign In
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/_components/auth/logout-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function LogoutButton() {
className="rounded-xl border-cooper-blue-400 bg-cooper-blue-400 px-5 py-2.5 text-sm font-semibold text-white hover:border-cooper-blue-200 hover:bg-cooper-blue-200 hover:text-cooper-blue-600 focus:outline-none focus:ring-4 focus:ring-white"
formAction={async () => {
"use server";
await signOut();
await signOut({ redirectTo: "/" });
}}
>
Sign Out
Expand Down
16 changes: 16 additions & 0 deletions apps/web/src/app/_components/cooper-logo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Image from "next/image";

interface CooperLogoProps {
width?: number;
}

export default function CooperLogo({ width }: CooperLogoProps) {
return (
<Image
src="/svg/hidingLogo.svg"
width={width ?? 137}
height={width ? width / 2.28 : 60} // 2.28 is the approximate ratio in the hidingLogo.svg file
alt="Logo Picture"
/>
);
}
24 changes: 9 additions & 15 deletions apps/web/src/app/_components/header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use client";

import Image from "next/image";
import Link from "next/link";
import { usePathname } from "next/navigation";

Expand All @@ -9,6 +8,7 @@ import { cn } from "@cooper/ui";

import { NewReviewDialog } from "~/app/_components/reviews/new-review-dialogue";
import { altivoFont } from "~/app/styles/font";
import CooperLogo from "./cooper-logo";

interface HeaderProps {
session: Session | null;
Expand All @@ -28,13 +28,8 @@ export default function Header({ session, auth }: HeaderProps) {
<header className="flex h-20 w-full grid-cols-3 items-center justify-between border-b border-b-[#9A9A9A] bg-white pr-2 drop-shadow-sm">
{/* Logo + Cooper */}
<Link href="/" className={cn("flex flex-grow items-end", outerWidth)}>
<div className="mx-4 flex min-h-20 items-end">
<Image
src="/svg/hidingLogo.svg"
height={150}
width={150}
alt="Logo Picture"
/>
<div className="mx-4 flex h-20 items-end">
<CooperLogo />
</div>
<h1
className={cn(
Expand All @@ -46,25 +41,24 @@ export default function Header({ session, auth }: HeaderProps) {
</h1>
</Link>
{/* Centered Links */}
<div className="lg: mb-8 flex min-h-20 flex-shrink grid-cols-2 items-end justify-start gap-4 lg:gap-12">
<div className="flex min-h-20 flex-shrink grid-cols-2 items-end justify-start gap-4 lg:gap-12">
<Link href="/roles">
<h2
className={cn(
"font-semibold",
"mb-[1.375rem] font-semibold",
pathname.includes("roles") &&
"underline decoration-cooper-pink-500 decoration-[3px] underline-offset-[6px]",
"mb-0 after:mt-4 after:block after:h-1.5 after:w-full after:rounded-t-full after:bg-cooper-pink-500",
)}
>
{" "}
Jobs{" "}
Jobs
</h2>
</Link>
<Link href="/companies">
<h2
className={cn(
"font-semibold",
"mb-[1.375rem] font-semibold",
pathname.includes("companies") &&
"underline decoration-cooper-green-500 decoration-[3px] underline-offset-[6px]",
"mb-0 after:mt-4 after:block after:h-1.5 after:w-full after:rounded-t-full after:bg-cooper-green-500",
)}
>
Companies
Expand Down
Loading

0 comments on commit 8ad0714

Please sign in to comment.