diff --git a/apps/portal/package.json b/apps/portal/package.json index f135cab3..9948c01e 100644 --- a/apps/portal/package.json +++ b/apps/portal/package.json @@ -22,11 +22,13 @@ "@trpc/react": "^9.27.2", "@trpc/server": "^9.27.2", "clsx": "^1.2.1", + "date-fns": "^2.29.3", "next": "12.3.1", "next-auth": "~4.10.3", "react": "18.2.0", "react-dom": "18.2.0", "react-hook-form": "^7.36.1", + "react-pdf": "^5.7.2", "react-query": "^3.39.2", "superjson": "^1.10.0", "zod": "^3.18.0" @@ -37,6 +39,7 @@ "@types/node": "^18.0.0", "@types/react": "^18.0.21", "@types/react-dom": "^18.0.6", + "@types/react-pdf": "^5.7.2", "autoprefixer": "^10.4.12", "postcss": "^8.4.16", "prettier-plugin-tailwindcss": "^0.1.13", diff --git a/apps/portal/prisma/migrations/20221006064944_add_resume_schemas/migration.sql b/apps/portal/prisma/migrations/20221006090216_add_resume_schemas/migration.sql similarity index 95% rename from apps/portal/prisma/migrations/20221006064944_add_resume_schemas/migration.sql rename to apps/portal/prisma/migrations/20221006090216_add_resume_schemas/migration.sql index 67b66abf..fac3cdd7 100644 --- a/apps/portal/prisma/migrations/20221006064944_add_resume_schemas/migration.sql +++ b/apps/portal/prisma/migrations/20221006090216_add_resume_schemas/migration.sql @@ -6,8 +6,11 @@ CREATE TABLE "ResumesResume" ( "id" TEXT NOT NULL, "userId" TEXT NOT NULL, "title" TEXT NOT NULL, - "additionalInfo" TEXT NOT NULL, + "role" TEXT NOT NULL, + "experience" TEXT NOT NULL, + "location" TEXT NOT NULL, "url" TEXT NOT NULL, + "additionalInfo" TEXT, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" TIMESTAMP(3) NOT NULL, diff --git a/apps/portal/prisma/migrations/20221007062555_add_resume_profile_model/migration.sql b/apps/portal/prisma/migrations/20221007062555_add_resume_profile_model/migration.sql new file mode 100644 index 00000000..64ef6108 --- /dev/null +++ b/apps/portal/prisma/migrations/20221007062555_add_resume_profile_model/migration.sql @@ -0,0 +1,74 @@ +/* + Warnings: + + - You are about to drop the column `userId` on the `ResumesComment` table. All the data in the column will be lost. + - You are about to drop the column `userId` on the `ResumesCommentVote` table. All the data in the column will be lost. + - You are about to drop the column `userId` on the `ResumesResume` table. All the data in the column will be lost. + - You are about to drop the column `userId` on the `ResumesStar` table. All the data in the column will be lost. + - A unique constraint covering the columns `[commentId,resumesProfileId]` on the table `ResumesCommentVote` will be added. If there are existing duplicate values, this will fail. + - A unique constraint covering the columns `[resumeId,resumesProfileId]` on the table `ResumesStar` will be added. If there are existing duplicate values, this will fail. + - Added the required column `resumesProfileId` to the `ResumesComment` table without a default value. This is not possible if the table is not empty. + - Added the required column `resumesProfileId` to the `ResumesCommentVote` table without a default value. This is not possible if the table is not empty. + - Added the required column `resumesProfileId` to the `ResumesResume` table without a default value. This is not possible if the table is not empty. + - Added the required column `resumesProfileId` to the `ResumesStar` table without a default value. This is not possible if the table is not empty. + +*/ +-- DropForeignKey +ALTER TABLE "ResumesComment" DROP CONSTRAINT "ResumesComment_userId_fkey"; + +-- DropForeignKey +ALTER TABLE "ResumesCommentVote" DROP CONSTRAINT "ResumesCommentVote_userId_fkey"; + +-- DropForeignKey +ALTER TABLE "ResumesResume" DROP CONSTRAINT "ResumesResume_userId_fkey"; + +-- DropForeignKey +ALTER TABLE "ResumesStar" DROP CONSTRAINT "ResumesStar_userId_fkey"; + +-- AlterTable +ALTER TABLE "ResumesComment" DROP COLUMN "userId", +ADD COLUMN "resumesProfileId" TEXT NOT NULL; + +-- AlterTable +ALTER TABLE "ResumesCommentVote" DROP COLUMN "userId", +ADD COLUMN "resumesProfileId" TEXT NOT NULL; + +-- AlterTable +ALTER TABLE "ResumesResume" DROP COLUMN "userId", +ADD COLUMN "resumesProfileId" TEXT NOT NULL; + +-- AlterTable +ALTER TABLE "ResumesStar" DROP COLUMN "userId", +ADD COLUMN "resumesProfileId" TEXT NOT NULL; + +-- CreateTable +CREATE TABLE "ResumesProfile" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + + CONSTRAINT "ResumesProfile_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "ResumesProfile_userId_key" ON "ResumesProfile"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "ResumesCommentVote_commentId_resumesProfileId_key" ON "ResumesCommentVote"("commentId", "resumesProfileId"); + +-- CreateIndex +CREATE UNIQUE INDEX "ResumesStar_resumeId_resumesProfileId_key" ON "ResumesStar"("resumeId", "resumesProfileId"); + +-- AddForeignKey +ALTER TABLE "ResumesProfile" ADD CONSTRAINT "ResumesProfile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ResumesResume" ADD CONSTRAINT "ResumesResume_resumesProfileId_fkey" FOREIGN KEY ("resumesProfileId") REFERENCES "ResumesProfile"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ResumesStar" ADD CONSTRAINT "ResumesStar_resumesProfileId_fkey" FOREIGN KEY ("resumesProfileId") REFERENCES "ResumesProfile"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ResumesComment" ADD CONSTRAINT "ResumesComment_resumesProfileId_fkey" FOREIGN KEY ("resumesProfileId") REFERENCES "ResumesProfile"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ResumesCommentVote" ADD CONSTRAINT "ResumesCommentVote_resumesProfileId_fkey" FOREIGN KEY ("resumesProfileId") REFERENCES "ResumesProfile"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/apps/portal/prisma/migrations/20221007135344_remove_resumes_profile_model/migration.sql b/apps/portal/prisma/migrations/20221007135344_remove_resumes_profile_model/migration.sql new file mode 100644 index 00000000..5b9baead --- /dev/null +++ b/apps/portal/prisma/migrations/20221007135344_remove_resumes_profile_model/migration.sql @@ -0,0 +1,73 @@ +/* + Warnings: + + - You are about to drop the column `resumesProfileId` on the `ResumesComment` table. All the data in the column will be lost. + - You are about to drop the column `resumesProfileId` on the `ResumesCommentVote` table. All the data in the column will be lost. + - You are about to drop the column `resumesProfileId` on the `ResumesResume` table. All the data in the column will be lost. + - You are about to drop the column `resumesProfileId` on the `ResumesStar` table. All the data in the column will be lost. + - You are about to drop the `ResumesProfile` table. If the table is not empty, all the data it contains will be lost. + - A unique constraint covering the columns `[userId,commentId]` on the table `ResumesCommentVote` will be added. If there are existing duplicate values, this will fail. + - A unique constraint covering the columns `[userId,resumeId]` on the table `ResumesStar` will be added. If there are existing duplicate values, this will fail. + - Added the required column `userId` to the `ResumesComment` table without a default value. This is not possible if the table is not empty. + - Added the required column `userId` to the `ResumesCommentVote` table without a default value. This is not possible if the table is not empty. + - Added the required column `userId` to the `ResumesResume` table without a default value. This is not possible if the table is not empty. + - Added the required column `userId` to the `ResumesStar` table without a default value. This is not possible if the table is not empty. + +*/ +-- DropForeignKey +ALTER TABLE "ResumesComment" DROP CONSTRAINT "ResumesComment_resumesProfileId_fkey"; + +-- DropForeignKey +ALTER TABLE "ResumesCommentVote" DROP CONSTRAINT "ResumesCommentVote_resumesProfileId_fkey"; + +-- DropForeignKey +ALTER TABLE "ResumesProfile" DROP CONSTRAINT "ResumesProfile_userId_fkey"; + +-- DropForeignKey +ALTER TABLE "ResumesResume" DROP CONSTRAINT "ResumesResume_resumesProfileId_fkey"; + +-- DropForeignKey +ALTER TABLE "ResumesStar" DROP CONSTRAINT "ResumesStar_resumesProfileId_fkey"; + +-- DropIndex +DROP INDEX "ResumesCommentVote_commentId_resumesProfileId_key"; + +-- DropIndex +DROP INDEX "ResumesStar_resumeId_resumesProfileId_key"; + +-- AlterTable +ALTER TABLE "ResumesComment" DROP COLUMN "resumesProfileId", +ADD COLUMN "userId" TEXT NOT NULL; + +-- AlterTable +ALTER TABLE "ResumesCommentVote" DROP COLUMN "resumesProfileId", +ADD COLUMN "userId" TEXT NOT NULL; + +-- AlterTable +ALTER TABLE "ResumesResume" DROP COLUMN "resumesProfileId", +ADD COLUMN "userId" TEXT NOT NULL; + +-- AlterTable +ALTER TABLE "ResumesStar" DROP COLUMN "resumesProfileId", +ADD COLUMN "userId" TEXT NOT NULL; + +-- DropTable +DROP TABLE "ResumesProfile"; + +-- CreateIndex +CREATE UNIQUE INDEX "ResumesCommentVote_userId_commentId_key" ON "ResumesCommentVote"("userId", "commentId"); + +-- CreateIndex +CREATE UNIQUE INDEX "ResumesStar_userId_resumeId_key" ON "ResumesStar"("userId", "resumeId"); + +-- AddForeignKey +ALTER TABLE "ResumesResume" ADD CONSTRAINT "ResumesResume_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ResumesStar" ADD CONSTRAINT "ResumesStar_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ResumesComment" ADD CONSTRAINT "ResumesComment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ResumesCommentVote" ADD CONSTRAINT "ResumesCommentVote_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/apps/portal/prisma/schema.prisma b/apps/portal/prisma/schema.prisma index 78fe5e7a..fcf404fb 100644 --- a/apps/portal/prisma/schema.prisma +++ b/apps/portal/prisma/schema.prisma @@ -97,15 +97,16 @@ model Company { // Add Resumes project models here, prefix all models with "Resumes", // use camelCase for field names, and try to name them consistently // across all models in this file. -// End of Resumes project models. - model ResumesResume { id String @id @default(cuid()) userId String title String @db.Text - additionalInfo String @db.Text - // TODO: Add role, experience, location from Enums + // TODO: Update role, experience, location to use Enums + role String @db.Text + experience String @db.Text + location String @db.Text url String + additionalInfo String? @db.Text createdAt DateTime @default(now()) updatedAt DateTime @updatedAt user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@ -115,24 +116,26 @@ model ResumesResume { model ResumesStar { id String @id @default(cuid()) - resumeId String userId String + resumeId String createdAt DateTime @default(now()) - user User @relation(fields: [userId], references: [id], onDelete: Cascade) resume ResumesResume @relation(fields: [resumeId], references: [id], onDelete: Cascade) + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + @@unique([userId, resumeId]) } model ResumesComment { id String @id @default(cuid()) - resumeId String userId String + resumeId String description String @db.Text section ResumesSection createdAt DateTime @default(now()) updatedAt DateTime @updatedAt - user User @relation(fields: [userId], references: [id], onDelete: Cascade) resume ResumesResume @relation(fields: [resumeId], references: [id], onDelete: Cascade) votes ResumesCommentVote[] + user User @relation(fields: [userId], references: [id], onDelete: Cascade) } enum ResumesSection { @@ -145,15 +148,19 @@ enum ResumesSection { model ResumesCommentVote { id String @id @default(cuid()) - commentId String userId String + commentId String value Int createdAt DateTime @default(now()) updatedAt DateTime @updatedAt - user User @relation(fields: [userId], references: [id], onDelete: Cascade) comment ResumesComment @relation(fields: [commentId], references: [id], onDelete: Cascade) + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + @@unique([userId, commentId]) } +// End of Resumes project models. + // Start of Offers project models. // Add Offers project models here, prefix all models with "Offer", // use camelCase for field names, and try to name them consistently diff --git a/apps/portal/public/test_resume.pdf b/apps/portal/public/test_resume.pdf new file mode 100644 index 00000000..279b6a25 Binary files /dev/null and b/apps/portal/public/test_resume.pdf differ diff --git a/apps/portal/src/components/resumes/ResumePdf.tsx b/apps/portal/src/components/resumes/ResumePdf.tsx new file mode 100644 index 00000000..82e26395 --- /dev/null +++ b/apps/portal/src/components/resumes/ResumePdf.tsx @@ -0,0 +1,52 @@ +import { useState } from 'react'; +import { Document, Page, pdfjs } from 'react-pdf'; +import type { PDFDocumentProxy } from 'react-pdf/node_modules/pdfjs-dist'; +import { ArrowLeftIcon, ArrowRightIcon } from '@heroicons/react/20/solid'; +import { Button, Spinner } from '@tih/ui'; + +pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.min.js`; + +type Props = Readonly<{ + url: string; +}>; + +export default function ResumePdf({ url }: Props) { + const [numPages, setNumPages] = useState(0); + const [pageNumber] = useState(1); + + const onPdfLoadSuccess = (pdf: PDFDocumentProxy) => { + setNumPages(pdf.numPages); + }; + + return ( +
+ Page {pageNumber} of {numPages} +
+ ++ Please fill in at least one section to submit your review +
+ + + + ++ { + event.preventDefault(); + signIn(); + }}> + Sign in + {' '} + to join discussion +
+