diff --git a/.eslintrc.js b/.eslintrc.js index 781274d..afb7ffa 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,10 +1,10 @@ // This configuration only applies to the package manager root. /** @type {import("eslint").Linter.Config} */ module.exports = { - ignorePatterns: ["apps/**", "packages/**"], - extends: ["@workspace/eslint-config/library.js"], - parser: "@typescript-eslint/parser", + ignorePatterns: ['apps/**', 'packages/**'], + extends: ['@workspace/eslint-config/library.js'], + parser: '@typescript-eslint/parser', parserOptions: { project: true, }, -} +}; diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..305f33b --- /dev/null +++ b/.prettierignore @@ -0,0 +1,11 @@ +node_modules/ +build/ +dist/ +.next/ +out/ +coverage/ +.DS_Store +pnpm-lock.yaml +*.env +*.log +.turbo/ \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..ef2237c --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "semi": true, + "singleQuote": true, + "trailingComma": "all", + "printWidth": 100, + "tabWidth": 2, + "endOfLine": "lf" +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 61683dd..05073cf 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,5 @@ { - "tailwindCSS.experimental.configFile": "packages/ui/src/styles/globals.css" + "tailwindCSS.experimental.configFile": "packages/ui/src/styles/globals.css", + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode" } diff --git a/README.md b/README.md index 226e3c4..497d6fe 100644 --- a/README.md +++ b/README.md @@ -27,5 +27,5 @@ Your `tailwind.config.ts` and `globals.css` are already set up to use the compon To use the components in your app, import them from the `ui` package. ```tsx -import { Button } from "@workspace/ui/components/button" +import { Button } from '@workspace/ui/components/button'; ``` diff --git a/apps/admin/app/api/auth/[...nextauth]/route.ts b/apps/admin/app/api/auth/[...nextauth]/route.ts index ad9858b..7a2b1b9 100644 --- a/apps/admin/app/api/auth/[...nextauth]/route.ts +++ b/apps/admin/app/api/auth/[...nextauth]/route.ts @@ -1,2 +1,2 @@ -import { handlers } from "@workspace/auth"; +import { handlers } from '@workspace/auth'; export const { GET, POST } = handlers; diff --git a/apps/admin/app/layout.tsx b/apps/admin/app/layout.tsx index 8521291..fbb088d 100644 --- a/apps/admin/app/layout.tsx +++ b/apps/admin/app/layout.tsx @@ -1,121 +1,119 @@ -import localFont from "next/font/local" +import localFont from 'next/font/local'; -import "@workspace/ui/globals.css" -import { Providers } from "@/components/providers" +import '@workspace/ui/globals.css'; +import { Providers } from '@/components/providers'; const firaSans = localFont({ src: [ { - path: "../fonts/Fira-sans/FiraSans-Thin.ttf", - weight: "100", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-Thin.ttf', + weight: '100', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-ThinItalic.ttf", - weight: "100", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-ThinItalic.ttf', + weight: '100', + style: 'italic', }, { - path: "../fonts/Fira-sans/FiraSans-ExtraLight.ttf", - weight: "200", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-ExtraLight.ttf', + weight: '200', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-ExtraLightItalic.ttf", - weight: "200", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-ExtraLightItalic.ttf', + weight: '200', + style: 'italic', }, { - path: "../fonts/Fira-sans/FiraSans-Light.ttf", - weight: "300", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-Light.ttf', + weight: '300', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-LightItalic.ttf", - weight: "300", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-LightItalic.ttf', + weight: '300', + style: 'italic', }, { - path: "../fonts/Fira-sans/FiraSans-Regular.ttf", - weight: "400", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-Regular.ttf', + weight: '400', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-Italic.ttf", - weight: "400", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-Italic.ttf', + weight: '400', + style: 'italic', }, { - path: "../fonts/Fira-sans/FiraSans-Medium.ttf", - weight: "500", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-Medium.ttf', + weight: '500', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-MediumItalic.ttf", - weight: "500", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-MediumItalic.ttf', + weight: '500', + style: 'italic', }, { - path: "../fonts/Fira-sans/FiraSans-SemiBold.ttf", - weight: "600", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-SemiBold.ttf', + weight: '600', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-SemiBoldItalic.ttf", - weight: "600", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-SemiBoldItalic.ttf', + weight: '600', + style: 'italic', }, { - path: "../fonts/Fira-sans/FiraSans-Bold.ttf", - weight: "700", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-Bold.ttf', + weight: '700', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-BoldItalic.ttf", - weight: "700", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-BoldItalic.ttf', + weight: '700', + style: 'italic', }, { - path: "../fonts/Fira-sans/FiraSans-ExtraBold.ttf", - weight: "800", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-ExtraBold.ttf', + weight: '800', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-ExtraBoldItalic.ttf", - weight: "800", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-ExtraBoldItalic.ttf', + weight: '800', + style: 'italic', }, { - path: "../fonts/Fira-sans/FiraSans-Black.ttf", - weight: "900", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-Black.ttf', + weight: '900', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-BlackItalic.ttf", - weight: "900", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-BlackItalic.ttf', + weight: '900', + style: 'italic', }, ], - variable: "--font-sans", -}) + variable: '--font-sans', +}); const marcellus = localFont({ - src: "../fonts/Marcellus/Marcellus-Regular.ttf", - variable: "--font-marcellus", -}) + src: '../fonts/Marcellus/Marcellus-Regular.ttf', + variable: '--font-marcellus', +}); export default function RootLayout({ children, }: Readonly<{ - children: React.ReactNode + children: React.ReactNode; }>) { return ( - + {children} - ) + ); } diff --git a/apps/admin/app/page.tsx b/apps/admin/app/page.tsx index 5855ba0..17ce246 100644 --- a/apps/admin/app/page.tsx +++ b/apps/admin/app/page.tsx @@ -1,21 +1,21 @@ -import Login from "@/components/login"; -import Studs from "@/components/studs"; -import { db, admins } from "@workspace/db"; -import { auth, signIn, signOut } from "@workspace/auth"; +import Login from '@/components/login'; +import Studs from '@/components/studs'; +import { db, admins } from '@workspace/db'; +import { auth, signIn, signOut } from '@workspace/auth'; async function getStudents() { - "use server"; + 'use server'; const s = await db.select().from(admins); console.log(s); } async function logIn() { - "use server"; - await signIn("google"); + 'use server'; + await signIn('google'); } async function logOut() { - "use server"; + 'use server'; await signOut(); } @@ -24,9 +24,7 @@ export default async function Page() { return (
-

- Hello admin {session?.user?.name} -

+

Hello admin {session?.user?.name}

{!session?.user && }
diff --git a/apps/admin/components/login.tsx b/apps/admin/components/login.tsx index 58c5d59..d442f81 100644 --- a/apps/admin/components/login.tsx +++ b/apps/admin/components/login.tsx @@ -1,6 +1,6 @@ -"use client"; -import { signIn } from "@workspace/auth"; -import { Button } from "@workspace/ui/components/button"; +'use client'; +import { signIn } from '@workspace/auth'; +import { Button } from '@workspace/ui/components/button'; export default function Login({ action }: { action: () => Promise }) { return ( diff --git a/apps/admin/components/providers.tsx b/apps/admin/components/providers.tsx index bb8a9ff..2541892 100644 --- a/apps/admin/components/providers.tsx +++ b/apps/admin/components/providers.tsx @@ -1,16 +1,11 @@ -"use client"; +'use client'; -import * as React from "react"; -import { ThemeProvider as NextThemesProvider } from "next-themes"; +import * as React from 'react'; +import { ThemeProvider as NextThemesProvider } from 'next-themes'; export function Providers({ children }: { children: React.ReactNode }) { return ( - + {children} ); diff --git a/apps/admin/components/studs.tsx b/apps/admin/components/studs.tsx index 7e49d2a..e771e7c 100644 --- a/apps/admin/components/studs.tsx +++ b/apps/admin/components/studs.tsx @@ -1,5 +1,5 @@ -import { Button } from "@workspace/ui/components/button"; -import { auth } from "@workspace/auth"; +import { Button } from '@workspace/ui/components/button'; +import { auth } from '@workspace/auth'; export default async function Studs({ action, @@ -12,7 +12,9 @@ export default async function Studs({ if (!session?.user) return null; return (
- +
); diff --git a/apps/admin/eslint.config.js b/apps/admin/eslint.config.js index 5062ee3..28db55c 100644 --- a/apps/admin/eslint.config.js +++ b/apps/admin/eslint.config.js @@ -1,4 +1,4 @@ -import { nextJsConfig } from "@workspace/eslint-config/next-js" +import { nextJsConfig } from '@workspace/eslint-config/next-js'; /** @type {import("eslint").Linter.Config} */ -export default nextJsConfig +export default nextJsConfig; diff --git a/apps/admin/middleware.ts b/apps/admin/middleware.ts index d084074..0b87fc6 100644 --- a/apps/admin/middleware.ts +++ b/apps/admin/middleware.ts @@ -1,18 +1,18 @@ -import { auth } from "@workspace/auth"; +import { auth } from '@workspace/auth'; import { NextResponse } from 'next/server'; export default auth((req: any) => { // If the user is unauthenticated or an admin, allow the request. - if (!req.auth || req.auth.user?.role === "ADMIN") { + if (!req.auth || req.auth.user?.role === 'ADMIN') { return NextResponse.next(); } // Otherwise, redirect to the student app. - const studentUrl = process.env.STUDENT_URL ?? "http://localhost:3000" + const studentUrl = process.env.STUDENT_URL ?? 'http://localhost:3000'; return NextResponse.redirect(new URL(studentUrl, req.url)); }) as any; export const config = { - matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"], -} \ No newline at end of file + matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'], +}; diff --git a/apps/admin/next-auth.d.ts b/apps/admin/next-auth.d.ts index 0eeed9b..f201cb6 100644 --- a/apps/admin/next-auth.d.ts +++ b/apps/admin/next-auth.d.ts @@ -1,19 +1,19 @@ -import "next-auth"; +import 'next-auth'; -declare module "next-auth" { +declare module 'next-auth' { interface Session { user: { - role?: "ADMIN" | "USER"; + role?: 'ADMIN' | 'USER'; adminId?: number; studentId?: number; [key: string]: any; }; } } -declare module "next-auth/jwt" { +declare module 'next-auth/jwt' { interface JWT { - role?: "ADMIN" | "USER"; + role?: 'ADMIN' | 'USER'; adminId?: number; studentId?: number; } -} \ No newline at end of file +} diff --git a/apps/admin/next.config.mjs b/apps/admin/next.config.mjs index 58e988e..1e6e901 100644 --- a/apps/admin/next.config.mjs +++ b/apps/admin/next.config.mjs @@ -1,6 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { - transpilePackages: ["@workspace/ui", "@workspace/db", "@workspace/auth"], + transpilePackages: ['@workspace/ui', '@workspace/db', '@workspace/auth'], }; export default nextConfig; diff --git a/apps/admin/package.json b/apps/admin/package.json index 2fe35ae..564d5e8 100644 --- a/apps/admin/package.json +++ b/apps/admin/package.json @@ -12,7 +12,6 @@ "typecheck": "tsc --noEmit" }, "dependencies": { - "@hookform/resolvers": "^5.1.1", "@workspace/auth": "workspace:*", "@workspace/db": "workspace:*", "@workspace/ui": "workspace:*", @@ -22,9 +21,7 @@ "next-auth": "^4.24.11", "next-themes": "^0.4.4", "react": "^19.0.0", - "react-dom": "^19.0.0", - "react-hook-form": "^7.58.1", - "zod": "^3.24.2" + "react-dom": "^19.0.0" }, "devDependencies": { "@types/node": "^20", diff --git a/apps/admin/postcss.config.mjs b/apps/admin/postcss.config.mjs index 535dec4..00b6e2f 100644 --- a/apps/admin/postcss.config.mjs +++ b/apps/admin/postcss.config.mjs @@ -1 +1 @@ -export { default } from "@workspace/ui/postcss.config"; \ No newline at end of file +export { default } from '@workspace/ui/postcss.config'; diff --git a/apps/admin/tsconfig.json b/apps/admin/tsconfig.json index e6b5186..21c6218 100644 --- a/apps/admin/tsconfig.json +++ b/apps/admin/tsconfig.json @@ -6,7 +6,7 @@ "@/*": ["./*"], "@workspace/ui/*": ["../../packages/ui/src/*"], "@workspace/db/*": ["../../packages/db/src/*"], - "@workspace/auth/*": ["../../packages/auth/src/*"], + "@workspace/auth/*": ["../../packages/auth/src/*"] }, "plugins": [ { @@ -14,12 +14,6 @@ } ] }, - "include": [ - "next-env.d.ts", - "next.config.ts", - "**/*.ts", - "**/*.tsx", - ".next/types/**/*.ts" - ], + "include": ["next-env.d.ts", "next.config.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "exclude": ["node_modules"] } diff --git a/apps/student/app/api/auth/[...nextauth]/route.ts b/apps/student/app/api/auth/[...nextauth]/route.ts index ad9858b..7a2b1b9 100644 --- a/apps/student/app/api/auth/[...nextauth]/route.ts +++ b/apps/student/app/api/auth/[...nextauth]/route.ts @@ -1,2 +1,2 @@ -import { handlers } from "@workspace/auth"; +import { handlers } from '@workspace/auth'; export const { GET, POST } = handlers; diff --git a/apps/student/app/layout.tsx b/apps/student/app/layout.tsx index 8521291..fbb088d 100644 --- a/apps/student/app/layout.tsx +++ b/apps/student/app/layout.tsx @@ -1,121 +1,119 @@ -import localFont from "next/font/local" +import localFont from 'next/font/local'; -import "@workspace/ui/globals.css" -import { Providers } from "@/components/providers" +import '@workspace/ui/globals.css'; +import { Providers } from '@/components/providers'; const firaSans = localFont({ src: [ { - path: "../fonts/Fira-sans/FiraSans-Thin.ttf", - weight: "100", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-Thin.ttf', + weight: '100', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-ThinItalic.ttf", - weight: "100", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-ThinItalic.ttf', + weight: '100', + style: 'italic', }, { - path: "../fonts/Fira-sans/FiraSans-ExtraLight.ttf", - weight: "200", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-ExtraLight.ttf', + weight: '200', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-ExtraLightItalic.ttf", - weight: "200", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-ExtraLightItalic.ttf', + weight: '200', + style: 'italic', }, { - path: "../fonts/Fira-sans/FiraSans-Light.ttf", - weight: "300", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-Light.ttf', + weight: '300', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-LightItalic.ttf", - weight: "300", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-LightItalic.ttf', + weight: '300', + style: 'italic', }, { - path: "../fonts/Fira-sans/FiraSans-Regular.ttf", - weight: "400", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-Regular.ttf', + weight: '400', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-Italic.ttf", - weight: "400", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-Italic.ttf', + weight: '400', + style: 'italic', }, { - path: "../fonts/Fira-sans/FiraSans-Medium.ttf", - weight: "500", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-Medium.ttf', + weight: '500', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-MediumItalic.ttf", - weight: "500", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-MediumItalic.ttf', + weight: '500', + style: 'italic', }, { - path: "../fonts/Fira-sans/FiraSans-SemiBold.ttf", - weight: "600", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-SemiBold.ttf', + weight: '600', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-SemiBoldItalic.ttf", - weight: "600", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-SemiBoldItalic.ttf', + weight: '600', + style: 'italic', }, { - path: "../fonts/Fira-sans/FiraSans-Bold.ttf", - weight: "700", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-Bold.ttf', + weight: '700', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-BoldItalic.ttf", - weight: "700", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-BoldItalic.ttf', + weight: '700', + style: 'italic', }, { - path: "../fonts/Fira-sans/FiraSans-ExtraBold.ttf", - weight: "800", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-ExtraBold.ttf', + weight: '800', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-ExtraBoldItalic.ttf", - weight: "800", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-ExtraBoldItalic.ttf', + weight: '800', + style: 'italic', }, { - path: "../fonts/Fira-sans/FiraSans-Black.ttf", - weight: "900", - style: "normal", + path: '../fonts/Fira-sans/FiraSans-Black.ttf', + weight: '900', + style: 'normal', }, { - path: "../fonts/Fira-sans/FiraSans-BlackItalic.ttf", - weight: "900", - style: "italic", + path: '../fonts/Fira-sans/FiraSans-BlackItalic.ttf', + weight: '900', + style: 'italic', }, ], - variable: "--font-sans", -}) + variable: '--font-sans', +}); const marcellus = localFont({ - src: "../fonts/Marcellus/Marcellus-Regular.ttf", - variable: "--font-marcellus", -}) + src: '../fonts/Marcellus/Marcellus-Regular.ttf', + variable: '--font-marcellus', +}); export default function RootLayout({ children, }: Readonly<{ - children: React.ReactNode + children: React.ReactNode; }>) { return ( - + {children} - ) + ); } diff --git a/apps/student/app/page.tsx b/apps/student/app/page.tsx index 3217851..b265cf9 100644 --- a/apps/student/app/page.tsx +++ b/apps/student/app/page.tsx @@ -1,26 +1,26 @@ -import Login from "@/components/login"; -import Studs from "@/components/studs"; -import { db, admins } from "@workspace/db"; -import { auth, signIn, signOut } from "@workspace/auth"; +import Login from '@/components/login'; +import Studs from '@/components/studs'; +import { db, admins } from '@workspace/db'; +import { auth, signIn, signOut } from '@workspace/auth'; async function getStudents() { - "use server"; + 'use server'; const s = await db.select().from(admins); console.log(s); } async function logIn() { - "use server"; - await signIn("google"); + 'use server'; + await signIn('google'); } async function logOut() { - "use server"; + 'use server'; await signOut(); } export default async function Page() { - const session = await auth() + const session = await auth(); return (
diff --git a/apps/admin/app/signup/page.tsx b/apps/student/app/signup/page.tsx similarity index 75% rename from apps/admin/app/signup/page.tsx rename to apps/student/app/signup/page.tsx index 8136ee4..9a86ddc 100644 --- a/apps/admin/app/signup/page.tsx +++ b/apps/student/app/signup/page.tsx @@ -1,151 +1,176 @@ -"use client" +'use client'; -import { useState } from "react" -import { useForm } from "react-hook-form" -import { zodResolver } from "@hookform/resolvers/zod" -import * as z from "zod" -import { Button } from "@workspace/ui/components/button" -import { Input } from "@workspace/ui/components/input" -import { Textarea } from "@workspace/ui/components/textarea" -import { Progress } from "@workspace/ui/components/progress" -import { Separator } from "@workspace/ui/components/separator" -import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, FormDescription } from "@workspace/ui/components/form" -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@workspace/ui/components/select" -import { Card, CardContent, CardHeader, CardTitle } from "@workspace/ui/components/card" +import { useState } from 'react'; +import { useForm } from 'react-hook-form'; +import { zodResolver } from '@hookform/resolvers/zod'; +import * as z from 'zod'; +import { Button } from '@workspace/ui/components/button'; +import { Input } from '@workspace/ui/components/input'; +import { Textarea } from '@workspace/ui/components/textarea'; +import { Progress } from '@workspace/ui/components/progress'; +import { Separator } from '@workspace/ui/components/separator'; +import { + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, + FormDescription, +} from '@workspace/ui/components/form'; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from '@workspace/ui/components/select'; +import { Card, CardContent, CardHeader, CardTitle } from '@workspace/ui/components/card'; // Form schema const formSchema = z.object({ // Personal Details - firstName: z.string().min(1, "First name is required"), - lastName: z.string().min(1, "Last name is required"), + firstName: z.string().min(1, 'First name is required'), + lastName: z.string().min(1, 'Last name is required'), fathersName: z.string().optional(), mothersName: z.string().optional(), - email: z.string().email("Invalid email address"), - rollNumber: z.string().min(1, "Roll number is required"), - phoneNumber: z.string().min(10, "Phone number must be at least 10 digits"), - address: z.string().min(1, "Address is required"), + email: z.string().email('Invalid email address'), + rollNumber: z.string().min(1, 'Roll number is required'), + phoneNumber: z.string().min(10, 'Phone number must be at least 10 digits'), + address: z.string().min(1, 'Address is required'), // Academic Details - degree: z.string().min(1, "Degree is required"), - year: z.string().min(1, "Year is required"), - branch: z.string().min(1, "Branch is required"), - ssc: z.string().min(1, "SSC percentage is required"), - hsc: z.string().min(1, "HSC percentage is required"), + degree: z.string().min(1, 'Degree is required'), + year: z.string().min(1, 'Year is required'), + branch: z.string().min(1, 'Branch is required'), + ssc: z.string().min(1, 'SSC percentage is required'), + hsc: z.string().min(1, 'HSC percentage is required'), // Semester Grades - sem1: z.string().min(1, "Semester 1 grade is required"), - sem1KT: z.string().min(1, "Semester 1 KT status is required"), - sem2: z.string().min(1, "Semester 2 grade is required"), - sem2KT: z.string().min(1, "Semester 2 KT status is required"), + sem1: z.string().min(1, 'Semester 1 grade is required'), + sem1KT: z.string().min(1, 'Semester 1 KT status is required'), + sem2: z.string().min(1, 'Semester 2 grade is required'), + sem2KT: z.string().min(1, 'Semester 2 KT status is required'), // Additional Details - linkedin: z.string().url("Invalid LinkedIn URL"), - github: z.string().url("Invalid GitHub URL"), + linkedin: z.string().url('Invalid LinkedIn URL'), + github: z.string().url('Invalid GitHub URL'), skills: z.string().optional(), -}) +}); -type FormData = z.infer +type FormData = z.infer; const steps = [ { id: 1, - title: "Personal Details", - fields: ["firstName", "lastName", "fathersName", "mothersName", "email", "rollNumber", "phoneNumber", "address"], + title: 'Personal Details', + fields: [ + 'firstName', + 'lastName', + 'fathersName', + 'mothersName', + 'email', + 'rollNumber', + 'phoneNumber', + 'address', + ], }, - { id: 2, title: "Academic Details", fields: ["degree", "year", "branch", "ssc", "hsc"] }, - { id: 3, title: "Semester Grades", fields: ["sem1", "sem1KT", "sem2", "sem2KT"] }, - { id: 4, title: "Additional Details", fields: ["linkedin", "github", "skills"] }, -] + { id: 2, title: 'Academic Details', fields: ['degree', 'year', 'branch', 'ssc', 'hsc'] }, + { id: 3, title: 'Semester Grades', fields: ['sem1', 'sem1KT', 'sem2', 'sem2KT'] }, + { id: 4, title: 'Additional Details', fields: ['linkedin', 'github', 'skills'] }, +]; export default function StudentRegistrationForm() { - const [currentStep, setCurrentStep] = useState(1) - const [isSubmitting, setIsSubmitting] = useState(false) + const [currentStep, setCurrentStep] = useState(1); + const [isSubmitting, setIsSubmitting] = useState(false); const form = useForm({ resolver: zodResolver(formSchema), defaultValues: { - firstName: "", - lastName: "", - fathersName: "", - mothersName: "", - email: "", - rollNumber: "", - phoneNumber: "", - address: "", - degree: "", - year: "", - branch: "", - ssc: "", - hsc: "", - sem1: "", - sem1KT: "", - sem2: "", - sem2KT: "", - linkedin: "", - github: "", - skills: "", + firstName: '', + lastName: '', + fathersName: '', + mothersName: '', + email: '', + rollNumber: '', + phoneNumber: '', + address: '', + degree: '', + year: '', + branch: '', + ssc: '', + hsc: '', + sem1: '', + sem1KT: '', + sem2: '', + sem2KT: '', + linkedin: '', + github: '', + skills: '', }, - }) + }); const validateCurrentStep = async () => { - const currentStepData = steps.find((step) => step.id === currentStep) - if (!currentStepData) return false + const currentStepData = steps.find((step) => step.id === currentStep); + if (!currentStepData) return false; - const result = await form.trigger(currentStepData.fields as any) - return result - } + const result = await form.trigger(currentStepData.fields as any); + return result; + }; const nextStep = async () => { - const isValid = await validateCurrentStep() + const isValid = await validateCurrentStep(); if (isValid && currentStep < steps.length) { - setCurrentStep(currentStep + 1) + setCurrentStep(currentStep + 1); } - } + }; const prevStep = () => { if (currentStep > 1) { - setCurrentStep(currentStep - 1) + setCurrentStep(currentStep - 1); } - } + }; const onSubmit = async (data: FormData) => { - setIsSubmitting(true) + setIsSubmitting(true); try { // Simulate API call - await new Promise((resolve) => setTimeout(resolve, 2000)) - console.log("Form submitted:", data) - alert("Form submitted successfully!") + await new Promise((resolve) => setTimeout(resolve, 2000)); + console.log('Form submitted:', data); + alert('Form submitted successfully!'); } catch (error) { - console.error("Submission error:", error) - alert("Submission failed. Please try again.") + console.error('Submission error:', error); + alert('Submission failed. Please try again.'); } finally { - setIsSubmitting(false) + setIsSubmitting(false); } - } + }; const renderStep = () => { switch (currentStep) { case 1: - return + return ; case 2: - return + return ; case 3: - return + return ; case 4: - return + return ; default: - return null + return null; } - } + }; - const progress = (currentStep / steps.length) * 100 + const progress = (currentStep / steps.length) * 100; return (
- Student Registration Form + + Student Registration Form +
@@ -162,13 +187,18 @@ export default function StudentRegistrationForm() { {renderStep()}
- {currentStep === steps.length ? ( ) : (
- ) + ); } function PersonalDetailsStep({ form }: { form: any }) { @@ -308,30 +338,30 @@ function PersonalDetailsStep({ form }: { form: any }) { )} />
- ) + ); } function AcademicDetailsStep({ form }: { form: any }) { const degreeOptions = [ - { value: "btech", label: "B.Tech" }, - { value: "be", label: "B.E." }, - { value: "bsc", label: "B.Sc" }, - { value: "bca", label: "BCA" }, - ] + { value: 'btech', label: 'B.Tech' }, + { value: 'be', label: 'B.E.' }, + { value: 'bsc', label: 'B.Sc' }, + { value: 'bca', label: 'BCA' }, + ]; const yearOptions = [ - { value: "2024", label: "2024" }, - { value: "2025", label: "2025" }, - { value: "2026", label: "2026" }, - { value: "2027", label: "2027" }, - ] + { value: '2024', label: '2024' }, + { value: '2025', label: '2025' }, + { value: '2026', label: '2026' }, + { value: '2027', label: '2027' }, + ]; const branchOptions = [ - { value: "cse", label: "Computer Science" }, - { value: "it", label: "Information Technology" }, - { value: "ece", label: "Electronics & Communication" }, - { value: "mechanical", label: "Mechanical" }, - ] + { value: 'cse', label: 'Computer Science' }, + { value: 'it', label: 'Information Technology' }, + { value: 'ece', label: 'Electronics & Communication' }, + { value: 'mechanical', label: 'Mechanical' }, + ]; return (
@@ -443,16 +473,16 @@ function AcademicDetailsStep({ form }: { form: any }) { />
- ) + ); } function SemesterGradesStep({ form }: { form: any }) { const ktOptions = [ - { value: "0", label: "0 KT" }, - { value: "1", label: "1 KT" }, - { value: "2", label: "2 KT" }, - { value: "3+", label: "3+ KT" }, - ] + { value: '0', label: '0 KT' }, + { value: '1', label: '1 KT' }, + { value: '2', label: '2 KT' }, + { value: '3+', label: '3+ KT' }, + ]; return (
@@ -538,7 +568,7 @@ function SemesterGradesStep({ form }: { form: any }) { />
- ) + ); } function AdditionalDetailsStep({ form }: { form: any }) { @@ -594,5 +624,5 @@ function AdditionalDetailsStep({ form }: { form: any }) { )} />
- ) + ); } diff --git a/apps/student/components/login.tsx b/apps/student/components/login.tsx index 7b42ac7..2644e08 100644 --- a/apps/student/components/login.tsx +++ b/apps/student/components/login.tsx @@ -1,24 +1,20 @@ -"use client"; -import { signIn } from "@workspace/auth"; -import { Button } from "@workspace/ui/components/button"; +'use client'; +import { signIn } from '@workspace/auth'; +import { Button } from '@workspace/ui/components/button'; -export default function Login({logIn}: {logIn: () => Promise}) { +export default function Login({ logIn }: { logIn: () => Promise }) { return (
-
); diff --git a/apps/student/components/providers.tsx b/apps/student/components/providers.tsx index bb8a9ff..2541892 100644 --- a/apps/student/components/providers.tsx +++ b/apps/student/components/providers.tsx @@ -1,16 +1,11 @@ -"use client"; +'use client'; -import * as React from "react"; -import { ThemeProvider as NextThemesProvider } from "next-themes"; +import * as React from 'react'; +import { ThemeProvider as NextThemesProvider } from 'next-themes'; export function Providers({ children }: { children: React.ReactNode }) { return ( - + {children} ); diff --git a/apps/student/components/studs.tsx b/apps/student/components/studs.tsx index 7e49d2a..e771e7c 100644 --- a/apps/student/components/studs.tsx +++ b/apps/student/components/studs.tsx @@ -1,5 +1,5 @@ -import { Button } from "@workspace/ui/components/button"; -import { auth } from "@workspace/auth"; +import { Button } from '@workspace/ui/components/button'; +import { auth } from '@workspace/auth'; export default async function Studs({ action, @@ -12,7 +12,9 @@ export default async function Studs({ if (!session?.user) return null; return (
- +
); diff --git a/apps/student/eslint.config.js b/apps/student/eslint.config.js index 5062ee3..28db55c 100644 --- a/apps/student/eslint.config.js +++ b/apps/student/eslint.config.js @@ -1,4 +1,4 @@ -import { nextJsConfig } from "@workspace/eslint-config/next-js" +import { nextJsConfig } from '@workspace/eslint-config/next-js'; /** @type {import("eslint").Linter.Config} */ -export default nextJsConfig +export default nextJsConfig; diff --git a/apps/student/middleware.ts b/apps/student/middleware.ts index 09044e7..80b0d2d 100644 --- a/apps/student/middleware.ts +++ b/apps/student/middleware.ts @@ -1,18 +1,18 @@ -import { auth } from "@workspace/auth"; +import { auth } from '@workspace/auth'; import { NextResponse } from 'next/server'; export default auth((req: any) => { // If the user is unauthenticated or a student, allow the request. - if (!req.auth || req.auth.user?.role === "USER") { + if (!req.auth || req.auth.user?.role === 'USER') { return NextResponse.next(); } // Otherwise, redirect to the admin app. - const adminURL = process.env.ADMIN_URL ?? "http://localhost:3001" + const adminURL = process.env.ADMIN_URL ?? 'http://localhost:3001'; return NextResponse.redirect(new URL(adminURL, req.url)); }) as any; export const config = { - matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"], -} \ No newline at end of file + matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'], +}; diff --git a/apps/student/next-auth.d.ts b/apps/student/next-auth.d.ts index 8ac7c89..9bdda24 100644 --- a/apps/student/next-auth.d.ts +++ b/apps/student/next-auth.d.ts @@ -1,9 +1,9 @@ -import "next-auth"; +import 'next-auth'; -declare module "next-auth" { +declare module 'next-auth' { interface Session { user: { - role?: "ADMIN" | "USER"; + role?: 'ADMIN' | 'USER'; adminId?: number; studentId?: number; [key: string]: any; @@ -11,10 +11,10 @@ declare module "next-auth" { } } -declare module "next-auth/jwt" { +declare module 'next-auth/jwt' { interface JWT { - role?: "ADMIN" | "USER"; + role?: 'ADMIN' | 'USER'; adminId?: number; studentId?: number; } -} \ No newline at end of file +} diff --git a/apps/student/next.config.mjs b/apps/student/next.config.mjs index a69d65d..7fc6d4c 100644 --- a/apps/student/next.config.mjs +++ b/apps/student/next.config.mjs @@ -1,6 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { - transpilePackages: ["@workspace/ui", "@workspace/auth", "@workspace/db"], + transpilePackages: ['@workspace/ui', '@workspace/auth', '@workspace/db'], }; export default nextConfig; diff --git a/apps/student/package.json b/apps/student/package.json index 3179419..1bbe678 100644 --- a/apps/student/package.json +++ b/apps/student/package.json @@ -12,6 +12,7 @@ "typecheck": "tsc --noEmit" }, "dependencies": { + "@hookform/resolvers": "^5.1.1", "@workspace/ui": "workspace:*", "@workspace/db": "workspace:*", "@workspace/auth": "workspace:*", @@ -20,7 +21,9 @@ "next-auth": "^4.24.11", "next-themes": "^0.4.4", "react": "^19.0.0", - "react-dom": "^19.0.0" + "react-dom": "^19.0.0", + "react-hook-form": "^7.58.1", + "zod": "^3.24.2" }, "devDependencies": { "@types/node": "^20", diff --git a/apps/student/postcss.config.mjs b/apps/student/postcss.config.mjs index 535dec4..00b6e2f 100644 --- a/apps/student/postcss.config.mjs +++ b/apps/student/postcss.config.mjs @@ -1 +1 @@ -export { default } from "@workspace/ui/postcss.config"; \ No newline at end of file +export { default } from '@workspace/ui/postcss.config'; diff --git a/apps/student/tsconfig.json b/apps/student/tsconfig.json index 20ea701..033ac4a 100644 --- a/apps/student/tsconfig.json +++ b/apps/student/tsconfig.json @@ -14,12 +14,6 @@ } ] }, - "include": [ - "next-env.d.ts", - "next.config.ts", - "**/*.ts", - "**/*.tsx", - ".next/types/**/*.ts" - ], + "include": ["next-env.d.ts", "next.config.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "exclude": ["node_modules"] } diff --git a/packages/auth/index.ts b/packages/auth/index.ts index b4546e6..288b007 100644 --- a/packages/auth/index.ts +++ b/packages/auth/index.ts @@ -1,7 +1,7 @@ -import NextAuth, { type NextAuthConfig } from "next-auth"; -import Google from "next-auth/providers/google"; -import { db, admins, students } from "@workspace/db"; -import { eq } from "drizzle-orm"; +import NextAuth, { type NextAuthConfig } from 'next-auth'; +import Google from 'next-auth/providers/google'; +import { db, admins, students } from '@workspace/db'; +import { eq } from 'drizzle-orm'; const authConfig: NextAuthConfig = { providers: [Google], @@ -9,16 +9,12 @@ const authConfig: NextAuthConfig = { async jwt({ token, account, user, profile }) { // Only check DB on first sign in if (account && user && user.email) { - const admin = await db - .select() - .from(admins) - .where(eq(admins.email, user.email)) - .limit(1); + const admin = await db.select().from(admins).where(eq(admins.email, user.email)).limit(1); if (admin.length > 0 && admin[0]) { - token.role = "ADMIN"; + token.role = 'ADMIN'; token.adminId = admin[0].id; } else { - token.role = "USER"; + token.role = 'USER'; const student = await db .select() .from(students) @@ -27,9 +23,9 @@ const authConfig: NextAuthConfig = { if (student.length > 0 && student[0]) { token.studentId = student[0].id; } else { - const nameParts = user.name?.split(" ") ?? []; - const firstName = nameParts[0] || ""; - const lastName = nameParts.slice(1).join(" ") || ""; + const nameParts = user.name?.split(' ') ?? []; + const firstName = nameParts[0] || ''; + const lastName = nameParts.slice(1).join(' ') || ''; const newStudent = await db .insert(students) .values({ @@ -49,7 +45,7 @@ const authConfig: NextAuthConfig = { }, async session({ session, token }) { if (token?.role) { - session.user.role = token.role as "ADMIN" | "USER"; + session.user.role = token.role as 'ADMIN' | 'USER'; } if (token?.adminId) { session.user.adminId = token.adminId as number; diff --git a/packages/auth/types.d.ts b/packages/auth/types.d.ts index b4ceb09..23eb352 100644 --- a/packages/auth/types.d.ts +++ b/packages/auth/types.d.ts @@ -1,20 +1,20 @@ -import "next-auth"; -import "next-auth/jwt"; +import 'next-auth'; +import 'next-auth/jwt'; -declare module "next-auth" { +declare module 'next-auth' { interface Session { user: { - role?: "ADMIN" | "USER"; + role?: 'ADMIN' | 'USER'; adminId?: number; studentId?: number; [key: string]: any; }; } } -declare module "next-auth/jwt" { +declare module 'next-auth/jwt' { interface JWT { - role?: "ADMIN" | "USER"; + role?: 'ADMIN' | 'USER'; adminId?: number; studentId?: number; } -} \ No newline at end of file +} diff --git a/packages/db/drizzle.config.ts b/packages/db/drizzle.config.ts index ae100fa..fc0d2e6 100644 --- a/packages/db/drizzle.config.ts +++ b/packages/db/drizzle.config.ts @@ -1,12 +1,12 @@ -import { config } from "dotenv"; -import { defineConfig } from "drizzle-kit"; +import { config } from 'dotenv'; +import { defineConfig } from 'drizzle-kit'; -config({ path: "../../.env" }); +config({ path: '../../.env' }); export default defineConfig({ - schema: "./schema.ts", - out: "./migrations", - dialect: "postgresql", + schema: './schema.ts', + out: './migrations', + dialect: 'postgresql', dbCredentials: { url: process.env.DATABASE_URL!, }, diff --git a/packages/db/index.ts b/packages/db/index.ts index 3cf6d41..045a31f 100644 --- a/packages/db/index.ts +++ b/packages/db/index.ts @@ -1,5 +1,5 @@ -import { drizzle } from "drizzle-orm/neon-http"; +import { drizzle } from 'drizzle-orm/neon-http'; export const db = drizzle(process.env.DATABASE_URL!); -export * from "./schema"; +export * from './schema'; diff --git a/packages/db/migrations/meta/0000_snapshot.json b/packages/db/migrations/meta/0000_snapshot.json index d893d1e..f2f6b08 100644 --- a/packages/db/migrations/meta/0000_snapshot.json +++ b/packages/db/migrations/meta/0000_snapshot.json @@ -60,12 +60,8 @@ "name": "applications_job_id_jobs_id_fk", "tableFrom": "applications", "tableTo": "jobs", - "columnsFrom": [ - "job_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["job_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" }, @@ -73,12 +69,8 @@ "name": "applications_student_id_students_id_fk", "tableFrom": "applications", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" }, @@ -86,12 +78,8 @@ "name": "applications_resume_id_resumes_id_fk", "tableFrom": "applications", "tableTo": "resumes", - "columnsFrom": [ - "resume_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["resume_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -157,12 +145,8 @@ "name": "certificates_student_id_students_id_fk", "tableFrom": "certificates", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -303,12 +287,8 @@ "name": "grades_student_id_students_id_fk", "tableFrom": "grades", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -398,12 +378,8 @@ "name": "internships_student_id_students_id_fk", "tableFrom": "internships", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -535,12 +511,8 @@ "name": "jobs_company_id_companies_id_fk", "tableFrom": "jobs", "tableTo": "companies", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["company_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -607,12 +579,8 @@ "name": "projects_student_id_students_id_fk", "tableFrom": "projects", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -672,12 +640,8 @@ "name": "resumes_student_id_students_id_fk", "tableFrom": "resumes", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -843,4 +807,4 @@ "schemas": {}, "tables": {} } -} \ No newline at end of file +} diff --git a/packages/db/migrations/meta/0001_snapshot.json b/packages/db/migrations/meta/0001_snapshot.json index 3228860..27c7d7f 100644 --- a/packages/db/migrations/meta/0001_snapshot.json +++ b/packages/db/migrations/meta/0001_snapshot.json @@ -60,12 +60,8 @@ "name": "applications_job_id_jobs_id_fk", "tableFrom": "applications", "tableTo": "jobs", - "columnsFrom": [ - "job_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["job_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" }, @@ -73,12 +69,8 @@ "name": "applications_student_id_students_id_fk", "tableFrom": "applications", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" }, @@ -86,12 +78,8 @@ "name": "applications_resume_id_resumes_id_fk", "tableFrom": "applications", "tableTo": "resumes", - "columnsFrom": [ - "resume_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["resume_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -157,12 +145,8 @@ "name": "certificates_student_id_students_id_fk", "tableFrom": "certificates", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -303,12 +287,8 @@ "name": "grades_student_id_students_id_fk", "tableFrom": "grades", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -398,12 +378,8 @@ "name": "internships_student_id_students_id_fk", "tableFrom": "internships", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -535,12 +511,8 @@ "name": "jobs_company_id_companies_id_fk", "tableFrom": "jobs", "tableTo": "companies", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["company_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -607,12 +579,8 @@ "name": "projects_student_id_students_id_fk", "tableFrom": "projects", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -672,12 +640,8 @@ "name": "resumes_student_id_students_id_fk", "tableFrom": "resumes", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -843,4 +807,4 @@ "schemas": {}, "tables": {} } -} \ No newline at end of file +} diff --git a/packages/db/migrations/meta/0002_snapshot.json b/packages/db/migrations/meta/0002_snapshot.json index d321abd..418e085 100644 --- a/packages/db/migrations/meta/0002_snapshot.json +++ b/packages/db/migrations/meta/0002_snapshot.json @@ -42,9 +42,7 @@ "admins_email_unique": { "name": "admins_email_unique", "nullsNotDistinct": false, - "columns": [ - "email" - ] + "columns": ["email"] } }, "policies": {}, @@ -107,12 +105,8 @@ "name": "applications_job_id_jobs_id_fk", "tableFrom": "applications", "tableTo": "jobs", - "columnsFrom": [ - "job_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["job_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" }, @@ -120,12 +114,8 @@ "name": "applications_student_id_students_id_fk", "tableFrom": "applications", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" }, @@ -133,12 +123,8 @@ "name": "applications_resume_id_resumes_id_fk", "tableFrom": "applications", "tableTo": "resumes", - "columnsFrom": [ - "resume_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["resume_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -204,12 +190,8 @@ "name": "certificates_student_id_students_id_fk", "tableFrom": "certificates", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -350,12 +332,8 @@ "name": "grades_student_id_students_id_fk", "tableFrom": "grades", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -445,12 +423,8 @@ "name": "internships_student_id_students_id_fk", "tableFrom": "internships", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -582,12 +556,8 @@ "name": "jobs_company_id_companies_id_fk", "tableFrom": "jobs", "tableTo": "companies", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["company_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -654,12 +624,8 @@ "name": "projects_student_id_students_id_fk", "tableFrom": "projects", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -719,12 +685,8 @@ "name": "resumes_student_id_students_id_fk", "tableFrom": "resumes", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -890,4 +852,4 @@ "schemas": {}, "tables": {} } -} \ No newline at end of file +} diff --git a/packages/db/migrations/meta/0003_snapshot.json b/packages/db/migrations/meta/0003_snapshot.json index 5c7bc01..5b2da57 100644 --- a/packages/db/migrations/meta/0003_snapshot.json +++ b/packages/db/migrations/meta/0003_snapshot.json @@ -42,9 +42,7 @@ "admins_email_unique": { "name": "admins_email_unique", "nullsNotDistinct": false, - "columns": [ - "email" - ] + "columns": ["email"] } }, "policies": {}, @@ -107,12 +105,8 @@ "name": "applications_job_id_jobs_id_fk", "tableFrom": "applications", "tableTo": "jobs", - "columnsFrom": [ - "job_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["job_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" }, @@ -120,12 +114,8 @@ "name": "applications_student_id_students_id_fk", "tableFrom": "applications", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" }, @@ -133,12 +123,8 @@ "name": "applications_resume_id_resumes_id_fk", "tableFrom": "applications", "tableTo": "resumes", - "columnsFrom": [ - "resume_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["resume_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -204,12 +190,8 @@ "name": "certificates_student_id_students_id_fk", "tableFrom": "certificates", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -344,12 +326,8 @@ "name": "grades_student_id_students_id_fk", "tableFrom": "grades", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -357,10 +335,7 @@ "compositePrimaryKeys": { "grades_student_id_sem_pk": { "name": "grades_student_id_sem_pk", - "columns": [ - "student_id", - "sem" - ] + "columns": ["student_id", "sem"] } }, "uniqueConstraints": {}, @@ -452,12 +427,8 @@ "name": "internships_student_id_students_id_fk", "tableFrom": "internships", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -589,12 +560,8 @@ "name": "jobs_company_id_companies_id_fk", "tableFrom": "jobs", "tableTo": "companies", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["company_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -661,12 +628,8 @@ "name": "projects_student_id_students_id_fk", "tableFrom": "projects", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -726,12 +689,8 @@ "name": "resumes_student_id_students_id_fk", "tableFrom": "resumes", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -897,4 +856,4 @@ "schemas": {}, "tables": {} } -} \ No newline at end of file +} diff --git a/packages/db/migrations/meta/0004_snapshot.json b/packages/db/migrations/meta/0004_snapshot.json index c9107a2..1335d55 100644 --- a/packages/db/migrations/meta/0004_snapshot.json +++ b/packages/db/migrations/meta/0004_snapshot.json @@ -42,9 +42,7 @@ "admins_email_unique": { "name": "admins_email_unique", "nullsNotDistinct": false, - "columns": [ - "email" - ] + "columns": ["email"] } }, "policies": {}, @@ -107,12 +105,8 @@ "name": "applications_job_id_jobs_id_fk", "tableFrom": "applications", "tableTo": "jobs", - "columnsFrom": [ - "job_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["job_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" }, @@ -120,12 +114,8 @@ "name": "applications_student_id_students_id_fk", "tableFrom": "applications", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" }, @@ -133,12 +123,8 @@ "name": "applications_resume_id_resumes_id_fk", "tableFrom": "applications", "tableTo": "resumes", - "columnsFrom": [ - "resume_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["resume_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -267,12 +253,8 @@ "name": "grades_student_id_students_id_fk", "tableFrom": "grades", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -280,10 +262,7 @@ "compositePrimaryKeys": { "grades_student_id_sem_pk": { "name": "grades_student_id_sem_pk", - "columns": [ - "student_id", - "sem" - ] + "columns": ["student_id", "sem"] } }, "uniqueConstraints": {}, @@ -369,12 +348,8 @@ "name": "internships_student_id_students_id_fk", "tableFrom": "internships", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -506,12 +481,8 @@ "name": "jobs_company_id_companies_id_fk", "tableFrom": "jobs", "tableTo": "companies", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["company_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -571,12 +542,8 @@ "name": "resumes_student_id_students_id_fk", "tableFrom": "resumes", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -748,4 +715,4 @@ "schemas": {}, "tables": {} } -} \ No newline at end of file +} diff --git a/packages/db/migrations/meta/0005_snapshot.json b/packages/db/migrations/meta/0005_snapshot.json index b9eff47..8dd0168 100644 --- a/packages/db/migrations/meta/0005_snapshot.json +++ b/packages/db/migrations/meta/0005_snapshot.json @@ -42,9 +42,7 @@ "admins_email_unique": { "name": "admins_email_unique", "nullsNotDistinct": false, - "columns": [ - "email" - ] + "columns": ["email"] } }, "policies": {}, @@ -107,12 +105,8 @@ "name": "applications_job_id_jobs_id_fk", "tableFrom": "applications", "tableTo": "jobs", - "columnsFrom": [ - "job_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["job_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" }, @@ -120,12 +114,8 @@ "name": "applications_student_id_students_id_fk", "tableFrom": "applications", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" }, @@ -133,12 +123,8 @@ "name": "applications_resume_id_resumes_id_fk", "tableFrom": "applications", "tableTo": "resumes", - "columnsFrom": [ - "resume_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["resume_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -267,12 +253,8 @@ "name": "grades_student_id_students_id_fk", "tableFrom": "grades", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -280,10 +262,7 @@ "compositePrimaryKeys": { "grades_student_id_sem_pk": { "name": "grades_student_id_sem_pk", - "columns": [ - "student_id", - "sem" - ] + "columns": ["student_id", "sem"] } }, "uniqueConstraints": {}, @@ -369,12 +348,8 @@ "name": "internships_student_id_students_id_fk", "tableFrom": "internships", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -506,12 +481,8 @@ "name": "jobs_company_id_companies_id_fk", "tableFrom": "jobs", "tableTo": "companies", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["company_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -571,12 +542,8 @@ "name": "resumes_student_id_students_id_fk", "tableFrom": "resumes", "tableTo": "students", - "columnsFrom": [ - "student_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["student_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -766,4 +733,4 @@ "schemas": {}, "tables": {} } -} \ No newline at end of file +} diff --git a/packages/db/migrations/meta/_journal.json b/packages/db/migrations/meta/_journal.json index 1f2c754..261d76c 100644 --- a/packages/db/migrations/meta/_journal.json +++ b/packages/db/migrations/meta/_journal.json @@ -45,4 +45,4 @@ "breakpoints": true } ] -} \ No newline at end of file +} diff --git a/packages/db/schema.ts b/packages/db/schema.ts index b770cd1..09fe0c1 100644 --- a/packages/db/schema.ts +++ b/packages/db/schema.ts @@ -1,4 +1,4 @@ -import { sql, relations } from "drizzle-orm"; +import { sql, relations } from 'drizzle-orm'; import { pgTable, serial, @@ -10,9 +10,9 @@ import { numeric, primaryKey, check, -} from "drizzle-orm/pg-core"; +} from 'drizzle-orm/pg-core'; -export const students = pgTable("students", { +export const students = pgTable('students', { id: serial().primaryKey(), email: text().notNull(), rollNumber: varchar({ length: 12 }), @@ -45,9 +45,9 @@ export const students = pgTable("students", { .notNull(), }); -export const internships = pgTable("internships", { +export const internships = pgTable('internships', { id: serial().primaryKey(), - studentId: integer("student_id") + studentId: integer('student_id') .notNull() .references(() => students.id), title: text().notNull(), @@ -97,9 +97,9 @@ export const internships = pgTable("internships", { // .notNull(), // }); -export const resumes = pgTable("resumes", { +export const resumes = pgTable('resumes', { id: serial().primaryKey(), - studentId: integer("student_id") + studentId: integer('student_id') .notNull() .references(() => students.id), title: text().notNull(), @@ -112,9 +112,9 @@ export const resumes = pgTable("resumes", { }); export const grades = pgTable( - "grades", + 'grades', { - studentId: integer("student_id") + studentId: integer('student_id') .notNull() .references(() => students.id), sem: integer().notNull(), @@ -129,7 +129,7 @@ export const grades = pgTable( }, (table) => [ primaryKey({ columns: [table.studentId, table.sem] }), - check("sem_check1", sql`${table.sem} < 9`), + check('sem_check1', sql`${table.sem} < 9`), ], ); @@ -177,7 +177,7 @@ export const gradeRelations = relations(grades, ({ one }) => ({ }), })); -export const companies = pgTable("companies", { +export const companies = pgTable('companies', { id: serial().primaryKey(), name: text().notNull(), email: text().notNull(), @@ -192,9 +192,9 @@ export const companies = pgTable("companies", { .notNull(), }); -export const jobs = pgTable("jobs", { +export const jobs = pgTable('jobs', { id: serial().primaryKey(), - companyId: integer("company_id") + companyId: integer('company_id') .notNull() .references(() => companies.id), title: text().notNull(), @@ -205,9 +205,9 @@ export const jobs = pgTable("jobs", { salary: text().notNull(), applicationDeadline: timestamp().notNull(), active: boolean().notNull().default(false), - minCGPA: numeric({ precision: 4, scale: 2 }).notNull().default("0"), - minSSC: numeric({ precision: 4, scale: 2 }).notNull().default("0"), - minHSC: numeric({ precision: 4, scale: 2 }).notNull().default("0"), + minCGPA: numeric({ precision: 4, scale: 2 }).notNull().default('0'), + minSSC: numeric({ precision: 4, scale: 2 }).notNull().default('0'), + minHSC: numeric({ precision: 4, scale: 2 }).notNull().default('0'), allowDeadKT: boolean().notNull().default(true), allowLiveKT: boolean().notNull().default(true), createdAt: timestamp().notNull().defaultNow(), @@ -217,18 +217,18 @@ export const jobs = pgTable("jobs", { .notNull(), }); -export const applications = pgTable("applications", { +export const applications = pgTable('applications', { id: serial().primaryKey(), - jobId: integer("job_id") + jobId: integer('job_id') .notNull() .references(() => jobs.id), - studentId: integer("student_id") + studentId: integer('student_id') .notNull() .references(() => students.id), - resumeId: integer("resume_id") + resumeId: integer('resume_id') .notNull() .references(() => resumes.id), - status: text().notNull().default("pending"), + status: text().notNull().default('pending'), createdAt: timestamp().notNull().defaultNow(), updatedAt: timestamp() .defaultNow() @@ -263,7 +263,7 @@ export const applicationsRelations = relations(applications, ({ one }) => ({ }), })); -export const admins = pgTable("admins", { +export const admins = pgTable('admins', { id: serial().primaryKey(), email: text().notNull().unique(), createdAt: timestamp().notNull().defaultNow(), diff --git a/packages/eslint-config/base.js b/packages/eslint-config/base.js index b0f1eae..e14bf88 100644 --- a/packages/eslint-config/base.js +++ b/packages/eslint-config/base.js @@ -1,8 +1,8 @@ -import js from "@eslint/js" -import eslintConfigPrettier from "eslint-config-prettier" -import onlyWarn from "eslint-plugin-only-warn" -import turboPlugin from "eslint-plugin-turbo" -import tseslint from "typescript-eslint" +import js from '@eslint/js'; +import eslintConfigPrettier from 'eslint-config-prettier'; +import onlyWarn from 'eslint-plugin-only-warn'; +import turboPlugin from 'eslint-plugin-turbo'; +import tseslint from 'typescript-eslint'; /** * A shared ESLint configuration for the repository. @@ -18,7 +18,7 @@ export const config = [ turbo: turboPlugin, }, rules: { - "turbo/no-undeclared-env-vars": "warn", + 'turbo/no-undeclared-env-vars': 'warn', }, }, { @@ -27,6 +27,6 @@ export const config = [ }, }, { - ignores: ["dist/**"], + ignores: ['dist/**'], }, -] +]; diff --git a/packages/eslint-config/next.js b/packages/eslint-config/next.js index e40fffc..d70645c 100644 --- a/packages/eslint-config/next.js +++ b/packages/eslint-config/next.js @@ -1,12 +1,12 @@ -import js from "@eslint/js" -import pluginNext from "@next/eslint-plugin-next" -import eslintConfigPrettier from "eslint-config-prettier" -import pluginReact from "eslint-plugin-react" -import pluginReactHooks from "eslint-plugin-react-hooks" -import globals from "globals" -import tseslint from "typescript-eslint" +import js from '@eslint/js'; +import pluginNext from '@next/eslint-plugin-next'; +import eslintConfigPrettier from 'eslint-config-prettier'; +import pluginReact from 'eslint-plugin-react'; +import pluginReactHooks from 'eslint-plugin-react-hooks'; +import globals from 'globals'; +import tseslint from 'typescript-eslint'; -import { config as baseConfig } from "./base.js" +import { config as baseConfig } from './base.js'; /** * A custom ESLint configuration for libraries that use Next.js. @@ -29,23 +29,23 @@ export const nextJsConfig = [ }, { plugins: { - "@next/next": pluginNext, + '@next/next': pluginNext, }, rules: { ...pluginNext.configs.recommended.rules, - ...pluginNext.configs["core-web-vitals"].rules, + ...pluginNext.configs['core-web-vitals'].rules, }, }, { plugins: { - "react-hooks": pluginReactHooks, + 'react-hooks': pluginReactHooks, }, - settings: { react: { version: "detect" } }, + settings: { react: { version: 'detect' } }, rules: { ...pluginReactHooks.configs.recommended.rules, // React scope no longer necessary with new JSX transform. - "react/react-in-jsx-scope": "off", - "react/prop-types": "off", + 'react/react-in-jsx-scope': 'off', + 'react/prop-types': 'off', }, }, -] +]; diff --git a/packages/eslint-config/react-internal.js b/packages/eslint-config/react-internal.js index dda3143..6541688 100644 --- a/packages/eslint-config/react-internal.js +++ b/packages/eslint-config/react-internal.js @@ -1,11 +1,11 @@ -import js from "@eslint/js" -import eslintConfigPrettier from "eslint-config-prettier" -import pluginReact from "eslint-plugin-react" -import pluginReactHooks from "eslint-plugin-react-hooks" -import globals from "globals" -import tseslint from "typescript-eslint" +import js from '@eslint/js'; +import eslintConfigPrettier from 'eslint-config-prettier'; +import pluginReact from 'eslint-plugin-react'; +import pluginReactHooks from 'eslint-plugin-react-hooks'; +import globals from 'globals'; +import tseslint from 'typescript-eslint'; -import { config as baseConfig } from "./base.js" +import { config as baseConfig } from './base.js'; /** * A custom ESLint configuration for libraries that use React. @@ -28,14 +28,14 @@ export const config = [ }, { plugins: { - "react-hooks": pluginReactHooks, + 'react-hooks': pluginReactHooks, }, - settings: { react: { version: "detect" } }, + settings: { react: { version: 'detect' } }, rules: { ...pluginReactHooks.configs.recommended.rules, // React scope no longer necessary with new JSX transform. - "react/react-in-jsx-scope": "off", - "react/prop-types": "off", + 'react/react-in-jsx-scope': 'off', + 'react/prop-types': 'off', }, }, -] +]; diff --git a/packages/ui/eslint.config.js b/packages/ui/eslint.config.js index 69da3ed..0ed553d 100644 --- a/packages/ui/eslint.config.js +++ b/packages/ui/eslint.config.js @@ -1,4 +1,4 @@ -import { config } from "@workspace/eslint-config/react-internal" +import { config } from '@workspace/eslint-config/react-internal'; /** @type {import("eslint").Linter.Config} */ -export default config +export default config; diff --git a/packages/ui/postcss.config.mjs b/packages/ui/postcss.config.mjs index 4ae682d..f1c51c1 100644 --- a/packages/ui/postcss.config.mjs +++ b/packages/ui/postcss.config.mjs @@ -1,6 +1,6 @@ /** @type {import('postcss-load-config').Config} */ const config = { - plugins: { "@tailwindcss/postcss": {} }, + plugins: { '@tailwindcss/postcss': {} }, }; export default config; diff --git a/packages/ui/src/components/button.tsx b/packages/ui/src/components/button.tsx index a26f57f..198b3e8 100644 --- a/packages/ui/src/components/button.tsx +++ b/packages/ui/src/components/button.tsx @@ -1,8 +1,8 @@ -import React from "react"; -import { Slot } from "@radix-ui/react-slot"; -import { cva, type VariantProps } from "class-variance-authority"; +import React from 'react'; +import { Slot } from '@radix-ui/react-slot'; +import { cva, type VariantProps } from 'class-variance-authority'; -import { cn } from "@workspace/ui/lib/utils"; +import { cn } from '@workspace/ui/lib/utils'; const buttonVariants = cva( "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-lg text-sm font-medium transition-all duration-200 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-ring hover:scale-105 active:scale-95 transform-gpu", @@ -10,29 +10,28 @@ const buttonVariants = cva( variants: { variant: { default: - "bg-primary text-primary-foreground shadow-lg shadow-primary/25 hover:bg-primary/85 hover:shadow-xl hover:shadow-primary/35", + 'bg-primary text-primary-foreground shadow-lg shadow-primary/25 hover:bg-primary/85 hover:shadow-xl hover:shadow-primary/35', destructive: - "bg-destructive text-destructive-foreground shadow-lg shadow-destructive/25 hover:bg-destructive/85 hover:shadow-xl hover:shadow-destructive/35", + 'bg-destructive text-destructive-foreground shadow-lg shadow-destructive/25 hover:bg-destructive/85 hover:shadow-xl hover:shadow-destructive/35', outline: - "border-2 border-primary/20 bg-background hover:bg-primary/5 hover:text-primary hover:border-primary/40 shadow-md hover:shadow-lg hover:shadow-primary/15", + 'border-2 border-primary/20 bg-background hover:bg-primary/5 hover:text-primary hover:border-primary/40 shadow-md hover:shadow-lg hover:shadow-primary/15', secondary: - "bg-secondary text-secondary-foreground shadow-md hover:bg-secondary/80 hover:shadow-lg", - ghost: - "hover:bg-primary/10 hover:text-primary hover:shadow-md hover:shadow-primary/10", - link: "text-primary underline-offset-4 hover:underline hover:text-accent p-0 h-auto font-normal hover:scale-100 active:scale-100", + 'bg-secondary text-secondary-foreground shadow-md hover:bg-secondary/80 hover:shadow-lg', + ghost: 'hover:bg-primary/10 hover:text-primary hover:shadow-md hover:shadow-primary/10', + link: 'text-primary underline-offset-4 hover:underline hover:text-accent p-0 h-auto font-normal hover:scale-100 active:scale-100', accent: - "bg-accent text-accent-foreground shadow-lg shadow-accent/25 hover:bg-accent/85 hover:shadow-xl hover:shadow-accent/35", + 'bg-accent text-accent-foreground shadow-lg shadow-accent/25 hover:bg-accent/85 hover:shadow-xl hover:shadow-accent/35', }, size: { - default: "h-10 px-4 py-2", - sm: "h-8 rounded-md px-3 text-xs", - lg: "h-12 rounded-lg px-6 text-base", - icon: "h-10 w-10", + default: 'h-10 px-4 py-2', + sm: 'h-8 rounded-md px-3 text-xs', + lg: 'h-12 rounded-lg px-6 text-base', + icon: 'h-10 w-10', }, }, defaultVariants: { - variant: "default", - size: "default", + variant: 'default', + size: 'default', }, }, ); @@ -45,16 +44,12 @@ export interface ButtonProps const Button = React.forwardRef( ({ className, variant, size, asChild = false, ...props }, ref) => { - const Comp = asChild ? Slot : "button"; + const Comp = asChild ? Slot : 'button'; return ( - + ); }, ); -Button.displayName = "Button"; +Button.displayName = 'Button'; export { Button, buttonVariants }; diff --git a/packages/ui/src/components/card.tsx b/packages/ui/src/components/card.tsx index b0d1d94..dd6dbdd 100644 --- a/packages/ui/src/components/card.tsx +++ b/packages/ui/src/components/card.tsx @@ -1,75 +1,78 @@ -import type * as React from "react" +import type * as React from 'react'; -import { cn } from "@workspace/ui/lib/utils" +import { cn } from '@workspace/ui/lib/utils'; -function Card({ className, ...props }: React.ComponentProps<"div">) { +function Card({ className, ...props }: React.ComponentProps<'div'>) { return (
- ) + ); } -function CardHeader({ className, ...props }: React.ComponentProps<"div">) { +function CardHeader({ className, ...props }: React.ComponentProps<'div'>) { return (
- ) + ); } -function CardTitle({ className, ...props }: React.ComponentProps<"div">) { +function CardTitle({ className, ...props }: React.ComponentProps<'div'>) { return (
- ) + ); } -function CardDescription({ className, ...props }: React.ComponentProps<"div">) { +function CardDescription({ className, ...props }: React.ComponentProps<'div'>) { return (
- ) + ); } -function CardAction({ className, ...props }: React.ComponentProps<"div">) { +function CardAction({ className, ...props }: React.ComponentProps<'div'>) { return (
- ) + ); } -function CardContent({ className, ...props }: React.ComponentProps<"div">) { - return
+function CardContent({ className, ...props }: React.ComponentProps<'div'>) { + return
; } -function CardFooter({ className, ...props }: React.ComponentProps<"div">) { +function CardFooter({ className, ...props }: React.ComponentProps<'div'>) { return (
- ) + ); } -export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent } +export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent }; diff --git a/packages/ui/src/components/form.tsx b/packages/ui/src/components/form.tsx index 9dca733..4e3c22b 100644 --- a/packages/ui/src/components/form.tsx +++ b/packages/ui/src/components/form.tsx @@ -1,8 +1,8 @@ -"use client" +'use client'; -import * as React from "react" -import * as LabelPrimitive from "@radix-ui/react-label" -import { Slot } from "@radix-ui/react-slot" +import * as React from 'react'; +import * as LabelPrimitive from '@radix-ui/react-label'; +import { Slot } from '@radix-ui/react-slot'; import { Controller, FormProvider, @@ -11,23 +11,21 @@ import { type ControllerProps, type FieldPath, type FieldValues, -} from "react-hook-form" +} from 'react-hook-form'; -import { cn } from "@workspace/ui/lib/utils" -import { Label } from "@workspace/ui/components/label" +import { cn } from '@workspace/ui/lib/utils'; +import { Label } from '@workspace/ui/components/label'; -const Form = FormProvider +const Form = FormProvider; type FormFieldContextValue< TFieldValues extends FieldValues = FieldValues, TName extends FieldPath = FieldPath, > = { - name: TName -} + name: TName; +}; -const FormFieldContext = React.createContext( - {} as FormFieldContextValue -) +const FormFieldContext = React.createContext({} as FormFieldContextValue); const FormField = < TFieldValues extends FieldValues = FieldValues, @@ -39,21 +37,21 @@ const FormField = < - ) -} + ); +}; const useFormField = () => { - const fieldContext = React.useContext(FormFieldContext) - const itemContext = React.useContext(FormItemContext) - const { getFieldState } = useFormContext() - const formState = useFormState({ name: fieldContext.name }) - const fieldState = getFieldState(fieldContext.name, formState) + const fieldContext = React.useContext(FormFieldContext); + const itemContext = React.useContext(FormItemContext); + const { getFieldState } = useFormContext(); + const formState = useFormState({ name: fieldContext.name }); + const fieldState = getFieldState(fieldContext.name, formState); if (!fieldContext) { - throw new Error("useFormField should be used within ") + throw new Error('useFormField should be used within '); } - const { id } = itemContext + const { id } = itemContext; return { id, @@ -62,97 +60,84 @@ const useFormField = () => { formDescriptionId: `${id}-form-item-description`, formMessageId: `${id}-form-item-message`, ...fieldState, - } -} + }; +}; type FormItemContextValue = { - id: string -} + id: string; +}; -const FormItemContext = React.createContext( - {} as FormItemContextValue -) +const FormItemContext = React.createContext({} as FormItemContextValue); -function FormItem({ className, ...props }: React.ComponentProps<"div">) { - const id = React.useId() +function FormItem({ className, ...props }: React.ComponentProps<'div'>) { + const id = React.useId(); return ( -
+
- ) + ); } -function FormLabel({ - className, - ...props -}: React.ComponentProps) { - const { error, formItemId } = useFormField() +function FormLabel({ className, ...props }: React.ComponentProps) { + const { error, formItemId } = useFormField(); return (