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

Home / Search page #45

Merged
merged 40 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7ff2b1d
fix: fix company router errors when fetching companys that don't exist
banushi-a Feb 11, 2024
6d558b8
refactor(form): move card to a separate component
RishikeshNK Feb 11, 2024
53175c9
refactor(form): abstract form section
RishikeshNK Feb 11, 2024
b5b1068
refactor(form): abstract review section
RishikeshNK Feb 11, 2024
fc33a40
feat(form): add a radio group for coop cycle
RishikeshNK Feb 11, 2024
c1488ae
feat(form): add co-op cycle section
RishikeshNK Feb 11, 2024
12ea5a4
feat(form): add a few company details questions
RishikeshNK Feb 12, 2024
1b00680
feat(form): update review section
RishikeshNK Feb 12, 2024
1cc1b0b
fix(schema): modify schema
RishikeshNK Feb 12, 2024
00401e3
fix(form): add numbers to heading
RishikeshNK Feb 12, 2024
9c0c521
feat(form): add benefits checklish
RishikeshNK Feb 13, 2024
883ceb9
fix(form): remove no benefits option
RishikeshNK Feb 13, 2024
f2b5db2
refactor(form): clean up checklist code
RishikeshNK Feb 13, 2024
d497cea
fix(trpc): modify review schema for endpoint
RishikeshNK Feb 13, 2024
441dd51
feat(form): add a ratings section
RishikeshNK Feb 13, 2024
4672d2a
feat(form): add star component
RishikeshNK Feb 13, 2024
3a67088
feat(form): add remaining star rating fields
RishikeshNK Feb 13, 2024
01df4e0
feat(form): improve star rating ux
RishikeshNK Feb 13, 2024
ca6af66
feat(form): add other benefits input box
RishikeshNK Feb 13, 2024
d05df95
fix(form): change optional property of the form schema
RishikeshNK Feb 13, 2024
35f3e0a
feat(form): add a reset button
RishikeshNK Feb 13, 2024
d7143ed
refactor(schema): sync form and schema field names
RishikeshNK Feb 13, 2024
cb5ec43
fix(form): add a temporary fix to uncheck radio buttons on form reset
RishikeshNK Feb 14, 2024
1bd3aad
docs: update readme
RishikeshNK Feb 14, 2024
77f57dc
Merge branch 'main' into create-review-form
RishikeshNK Feb 14, 2024
38c45c4
feat(ui): improve responsiveness on smaller devices
RishikeshNK Feb 14, 2024
7b0465f
fix(form): add jsdoc, improve responsiveness, and add coop dates till…
RishikeshNK Feb 14, 2024
af7a06f
feat: added Colored Checkpoints to Header
banushi-a Feb 15, 2024
51b657e
refactor: merge new form into header changes
banushi-a Feb 15, 2024
42a7e97
fix: compiled Changes for Push
banushi-a Feb 15, 2024
d4ff1b3
Merge branch 'main' into review-header
banushi-a Feb 15, 2024
f180239
chore: prettier github action error
banushi-a Feb 15, 2024
85edd3c
style: responsive UI Updates
banushi-a Feb 15, 2024
9fecf81
feat: home page / Search Page + Filter
banushi-a Feb 24, 2024
b656bf2
chore: got rid of up
banushi-a Feb 24, 2024
7c1eadf
feat: homepage fixes, abstractions, code changes, tailwind changes
banushi-a Feb 25, 2024
ff738ab
fix: pR comment changes
banushi-a Mar 11, 2024
77b97f2
fix: fix BentonSans Font implementation, moved header components around
banushi-a Mar 15, 2024
bc3a603
Merge branch 'main' into home-page
banushi-a Mar 15, 2024
40d2317
style: format review-form.tsx
banushi-a Mar 15, 2024
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
27 changes: 27 additions & 0 deletions public/svg/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 1 addition & 7 deletions src/app/(protected)/review/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,5 @@ export default async function Page() {
redirect("/");
}

return (
<div className="container mx-auto px-4 py-10 sm:px-6 lg:px-8">
<div className="mx-auto max-w-lg">
<ReviewForm />
</div>
</div>
);
return <ReviewForm />;
}
49 changes: 9 additions & 40 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,19 @@
import Header from "~/components/header";
import SearchFilter from "~/components/search-filter";
import { getServerAuthSession } from "~/server/auth";

export default async function Home() {
const session = await getServerAuthSession();
banushi-a marked this conversation as resolved.
Show resolved Hide resolved

if (!session) {
return (
<div className="flex h-screen flex-col items-center justify-center space-y-4">
<p className="text-3xl font-semibold text-red-500">
You are not signed in!
return (
<div className="flex h-[85vh] flex-col">
<Header />
<div className="flex h-full flex-col items-center justify-center">
<p className="mb-8 text-2xl font-semibold">
Search your dream co-op role!
</p>
<a
href="/api/auth/signin/google"
type="button"
className="mb-2 me-2 inline-flex items-center rounded-lg bg-[#4285F4] px-5 py-2.5 text-center text-sm font-medium text-white hover:bg-[#4285F4]/90 focus:outline-none focus:ring-4 focus:ring-[#4285F4]/50 dark:focus:ring-[#4285F4]/55"
>
<svg
className="me-2 h-4 w-4"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
viewBox="0 0 18 19"
>
<path
fillRule="evenodd"
d="M8.842 18.083a8.8 8.8 0 0 1-8.65-8.948 8.841 8.841 0 0 1 8.8-8.652h.153a8.464 8.464 0 0 1 5.7 2.257l-2.193 2.038A5.27 5.27 0 0 0 9.09 3.4a5.882 5.882 0 0 0-.2 11.76h.124a5.091 5.091 0 0 0 5.248-4.057L14.3 11H9V8h8.34c.066.543.095 1.09.088 1.636-.086 5.053-3.463 8.449-8.4 8.449l-.186-.002Z"
clipRule="evenodd"
/>
</svg>
Sign in with Google
</a>
<SearchFilter />
</div>
);
}

return (
<div className="flex h-screen flex-col items-center justify-center space-y-4">
<p className="text-3xl font-semibold text-emerald-500">
Welcome, {session.user.name}!
</p>
<a
href="/api/auth/signout"
type="button"
className="mb-2 me-2 rounded-lg bg-red-700 px-5 py-2.5 text-sm font-medium text-white hover:bg-red-800 focus:outline-none focus:ring-4 focus:ring-red-300 dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-900"
>
Sign Out
</a>
</div>
);
}
22 changes: 22 additions & 0 deletions src/components/header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Image from "next/image";

import LoginButton from "./login-button";
banushi-a marked this conversation as resolved.
Show resolved Hide resolved
import LogoutButton from "./logout-button";

export default async function Header() {
return (
banushi-a marked this conversation as resolved.
Show resolved Hide resolved
<header className="flex h-16 w-full items-center justify-between border border-blue-500 bg-cooper-blue-400 p-4">
<h1 className="text-3xl font-extrabold text-white">COOPER</h1>
banushi-a marked this conversation as resolved.
Show resolved Hide resolved
<LoginButton />
<LogoutButton />
<div className="mt-2">
<Image
src="/svg/logo.svg"
width={100}
height={100}
alt="Logo Picture"
/>
</div>
</header>
);
}
32 changes: 32 additions & 0 deletions src/components/login-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { getServerAuthSession } from "~/server/auth";

export default async function LoginButton() {
const session = await getServerAuthSession();

if (!session) {
return (
<a
banushi-a marked this conversation as resolved.
Show resolved Hide resolved
href="/api/auth/signin/google"
type="button"
className="inline-flex items-center rounded-lg bg-[#4285F4] px-5 py-2.5 text-center text-sm font-medium text-white hover:bg-[#4285F4]/90 focus:outline-none focus:ring-4 focus:ring-[#4285F4]/50 dark:focus:ring-[#4285F4]/55"
>
<svg
className="me-2 h-4 w-4"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
viewBox="0 0 18 19"
>
<path
fillRule="evenodd"
d="M8.842 18.083a8.8 8.8 0 0 1-8.65-8.948 8.841 8.841 0 0 1 8.8-8.652h.153a8.464 8.464 0 0 1 5.7 2.257l-2.193 2.038A5.27 5.27 0 0 0 9.09 3.4a5.882 5.882 0 0 0-.2 11.76h.124a5.091 5.091 0 0 0 5.248-4.057L14.3 11H9V8h8.34c.066.543.095 1.09.088 1.636-.086 5.053-3.463 8.449-8.4 8.449l-.186-.002Z"
clipRule="evenodd"
/>
</svg>
Sign in with Google
</a>
);
}

return <></>;
banushi-a marked this conversation as resolved.
Show resolved Hide resolved
}
19 changes: 19 additions & 0 deletions src/components/logout-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { getServerAuthSession } from "~/server/auth";

export default async function LogoutButton() {
const session = await getServerAuthSession();

if (session) {
return (
<a
href="/api/auth/signout"
banushi-a marked this conversation as resolved.
Show resolved Hide resolved
type="button"
className="rounded-lg bg-red-700 px-5 py-2.5 text-sm font-medium text-white hover:bg-red-800 focus:outline-none focus:ring-4 focus:ring-red-300 dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-900"
>
Sign Out
</a>
);
}

return <></>;
}
51 changes: 33 additions & 18 deletions src/components/review-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,28 +152,43 @@ export function ReviewForm() {
console.log(values);
}

// Header Data
// going to fix the below TODO useMemo
// eslint-disable-next-line react-hooks/exhaustive-deps
const headerSections: { title: string; bound: number }[] = [
banushi-a marked this conversation as resolved.
Show resolved Hide resolved
{ title: "Co-op Cycle", bound: 400 },
{ title: "Ratings", bound: 800 },
{ title: "Review", bound: 1200 },
{ title: "Company Details", bound: 1600 },
{ title: "Submit", bound: 10000000 },
];

function onReset() {
form.reset();
}

return (
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
onReset={onReset}
className="space-y-6"
>
<CoopCycleSection />
<RatingsSection />
<ReviewSection />
<CompanyDetailsSection />
<div className="flex justify-end space-x-2">
<Button variant="secondary" type="reset">
Clear form
</Button>
<Button type="submit">Submit</Button>
</div>
</form>
</Form>
<div className="mx-auto px-4 pt-10 sm:px-6 lg:px-8">
<div className="mx-auto max-w-lg">
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
onReset={onReset}
className="space-y-6"
>
<CoopCycleSection />
<RatingsSection />
<ReviewSection />
<CompanyDetailsSection />
<div className="flex justify-end space-x-2">
<Button variant="secondary" type="reset">
Clear form
</Button>
<Button type="submit">Submit</Button>
</div>
</form>
</Form>
</div>
</div>
);
}
43 changes: 43 additions & 0 deletions src/components/search-bar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { useFormContext } from "react-hook-form";
import { FormControl, FormField, FormItem } from "./ui/form";
import { Input } from "./ui/input";

export function SearchBar() {
const form = useFormContext();

return (
<FormField
control={form.control}
name="searchText"
render={({ field }) => (
<FormItem>
<FormControl>
<div className="relative w-80">
{/* SEARCH TEXT INPUT */}
<svg
xmlns="http://www.w3.org/2000/svg"
className="absolute bottom-0 left-3 top-0 my-auto h-6 w-6 text-gray-500"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
/>
</svg>

<Input
banushi-a marked this conversation as resolved.
Show resolved Hide resolved
{...field}
className="min-w-96 rounded-3xl border-none bg-cooper-blue-200 pl-12"
placeholder="Search"
/>
</div>
</FormControl>
</FormItem>
)}
/>
);
}
Loading
Loading