Skip to content

Commit

Permalink
Merge branch 'main' into fuzzy-search
Browse files Browse the repository at this point in the history
  • Loading branch information
suxls committed Oct 6, 2024
2 parents c151fd6 + ff00668 commit 46ca58d
Show file tree
Hide file tree
Showing 14 changed files with 770 additions and 40 deletions.
46 changes: 34 additions & 12 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
Closes #(Task Number)

Only add the task number to the above statement if you have finished all of the subtasks.
<!--- Provide a general summary of your changes in the Title above -->

## Description

## Things to be reviewed
<!--- Describe your changes in detail -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->

Closes #[ticket<!--replace this with the GitHub Issue number-->]

## How has this been tested?

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, tests ran to see how -->
<!--- your change affects other areas of the code, etc. -->

## Screenshots (if appropriate):

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

## Screenshots (if applicable)
## Checklist:

## Checklist
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [ ] Add task name to the PR title
- [ ] Add ticket number to ("Closes #")
- [ ] Update `app/docs` (if applicable)
- [ ] Move task to "In Review" on the Cooper Project Board
- [ ] Add atleast one person to review your PR
- [ ] Ask for review on Slack
- [ ] My code follows the code style of this project.
- [ ] I have moved the ticket to "In Review"
- [ ] I have added reviewers to this PR
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,14 @@ jobs:

- name: Typecheck
run: pnpm typecheck

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup
uses: ./tooling/github/setup

- name: Test
run: pnpm test
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Cooper is a tool for Northeastern students to both submit reviews of their co-op
- [Zod](https://zod.dev/) - Validation

### Future
- [Jest](https://jestjs.io/) - Unit tests

- [Vitest](https://vitest.dev/) - Unit tests
- [Playwright](https://playwright.dev/) - E2E tests

This is a [T3 Stack](https://create.t3.gg/) project bootstrapped with `create-t3-turbo`. See [create-t3-turbo](https://github.com/t3-oss/create-t3-turbo)!
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/docs/02-technology.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ Adding unit and end-to-end tests is a work in progress so we do not have any tes
- [Docker](https://www.docker.com/) - Containerization
- [tRPC](https://trpc.io/) - End-to-end typesafe API
- [Zod](https://zod.dev/) - Validation
- [Jest](https://jestjs.io/) - Unit tests
- [Vitest](https://vitest.dev/) - Unit tests
- [Playwright](https://playwright.dev/) - E2E tests
2 changes: 1 addition & 1 deletion apps/web/src/app/(pages)/(dashboard)/companies/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default async function Companies() {
return (
<>
<SearchFilter />
<div className="grid w-3/4 grid-cols-3 gap-4">
<div className="grid h-[75dvh] w-3/4 grid-cols-3 gap-4">
{roles.map((role) => {
return (
<RoleReviewCard key={role.id} roleObj={role} className="mb-4" />
Expand Down
39 changes: 31 additions & 8 deletions apps/web/src/app/(pages)/(dashboard)/roles/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,33 @@

import { useState } from "react";

import type { ReviewType } from "@cooper/db/schema";
import type {
ReviewType,
WorkEnvironmentType,
WorkTermType,
} from "@cooper/db/schema";
import { cn } from "@cooper/ui";

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";
import { api } from "~/trpc/react";

export default function Roles() {
const reviews = api.review.list.useQuery();
export default function Roles({
searchParams,
}: {
searchParams?: {
workTerm?: WorkTermType;
workEnvironment?: WorkEnvironmentType;
};
}) {
const reviews = api.review.list.useQuery({
options: {
cycle: searchParams?.workTerm,
term: searchParams?.workEnvironment,
},
});

const [selectedReview, setSelectedReview] = useState<ReviewType | undefined>(
reviews.data ? reviews.data[0] : undefined,
);
Expand All @@ -21,20 +38,26 @@ export default function Roles() {
<SearchFilter />
{/* TODO: Loading animations */}
{reviews.data && (
<div className="mb-8 grid w-4/5 grid-cols-5 gap-4 lg:w-3/4">
<div className="col-span-2 gap-3">
{reviews.data.map((review) => {
<div className="mb-8 grid h-[75dvh] 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) => {
return (
<div key={review.id} onClick={() => setSelectedReview(review)}>
<ReviewCardPreview
reviewObj={review}
className={cn("mb-4 hover:border-2")}
className={cn(
"mb-4 hover:border-2",
selectedReview
? selectedReview.id === review.id &&
"border-2 bg-cooper-gray-100"
: !i && "border-2 bg-cooper-gray-100",
)}
/>
</div>
);
})}
</div>
<div className="col-span-3">
<div className="col-span-3 overflow-scroll">
{reviews.data.length > 0 && reviews.data[0] && (
<ReviewCard reviewObj={selectedReview ?? reviews.data[0]} />
)}
Expand Down
26 changes: 26 additions & 0 deletions apps/web/src/app/_components/footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Image from "next/image";
import Link from "next/link";

export default function Footer() {
return (
<footer className="flex h-20 w-full grid-cols-2 items-center justify-between border-t border-t-[#919191] bg-white px-4">
<Link
href="https://github.com/sandboxnu/cooper"
target="_blank"
className="flex items-center gap-2"
>
<Image
src="https://upload.wikimedia.org/wikipedia/commons/9/91/Octicons-mark-github.svg"
height={20}
width={20}
alt="Github Logo"
className="mt-[-0.25rem]"
/>
<h2 className="text-xl font-semibold">Checkout cooper on GitHub</h2>
</Link>
<a href="https://clearbit.com" target="_blank" className="italic">
Logos provided by Clearbit
</a>
</footer>
);
}
2 changes: 2 additions & 0 deletions apps/web/src/app/_components/header-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { auth } from "@cooper/auth";
import Header from "~/app/_components/header";
import LoginButton from "./auth/login-button";
import LogoutButton from "./auth/logout-button";
import Footer from "./footer";

/**
* This should be used when placing content under the header, standardizes how children are placed under a header.
Expand All @@ -25,6 +26,7 @@ export default async function HeaderLayout({
<article className="mt-16 flex w-[100vw] flex-col items-center justify-center gap-16">
{children}
</article>
<Footer />
</div>
);
}
5 changes: 5 additions & 0 deletions apps/web/test/app.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { expect, test } from "vitest";

test("should pass", () => {
expect(true).toBe(true);
});
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"__CLEAN_____________": "",
"clean": "git clean -xdf node_modules",
"clean:workspaces": "turbo run clean",
"__TEST______________": "",
"test": "vitest",
"test:ui": "vitest --ui",
"test:run": "vitest run",
"__DATABASE__________": "",
"db:push": "turbo run -F @cooper/db push",
"db:generate": "turbo run -F @cooper/db generate",
Expand All @@ -35,9 +39,11 @@
"devDependencies": {
"@cooper/prettier-config": "workspace:*",
"@turbo/gen": "^2.1.1",
"@vitest/ui": "2.1.2",
"prettier": "catalog:",
"turbo": "^2.1.1",
"typescript": "catalog:"
"typescript": "catalog:",
"vitest": "catalog:"
},
"prettier": "@cooper/prettier-config"
}
31 changes: 25 additions & 6 deletions packages/api/src/router/review.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
import type { TRPCRouterRecord } from "@trpc/server";
import { z } from "zod";

import { desc, eq } from "@cooper/db";
import { and, desc, eq } from "@cooper/db";
import { CreateReviewSchema, Review } from "@cooper/db/schema";

import { protectedProcedure, publicProcedure } from "../trpc";

export const reviewRouter = {
list: publicProcedure.query(({ ctx }) => {
return ctx.db.query.Review.findMany({
orderBy: desc(Review.id),
});
}),
list: publicProcedure
.input(
z.object({
options: z
.object({
cycle: z.enum(["SPRING", "FALL", "SUMMER"]).optional(),
term: z.enum(["INPERSON", "HYBRID", "REMOTE"]).optional(),
})
.optional(),
}),
)
.query(({ ctx, input }) => {
const { options } = input;

const conditions = [
options?.cycle && eq(Review.workTerm, options.cycle),
options?.term && eq(Review.workEnvironment, options.term),
].filter(Boolean);

return ctx.db.query.Review.findMany({
orderBy: desc(Review.id),
where: conditions.length > 0 ? and(...conditions) : undefined,
});
}),

getByRole: publicProcedure
.input(z.object({ id: z.string() }))
Expand Down
Loading

0 comments on commit 46ca58d

Please sign in to comment.