From e704b30b16e73e8a5e55fee135482b24cd5b8424 Mon Sep 17 00:00:00 2001 From: Ankit Date: Tue, 8 Apr 2025 00:17:32 +0530 Subject: [PATCH 1/3] fixed propogation issue --- components/Job/MoreDialog.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/Job/MoreDialog.tsx b/components/Job/MoreDialog.tsx index ef62ec5..bfa6bcf 100755 --- a/components/Job/MoreDialog.tsx +++ b/components/Job/MoreDialog.tsx @@ -50,7 +50,13 @@ export function BookmarkPostComp({ postId }: { postId: string }) { return ( <>
-
handleBookmarkClick()}> +
{ + e.stopPropagation(); + + handleBookmarkClick(); + }} + > Date: Tue, 8 Apr 2025 00:29:55 +0530 Subject: [PATCH 2/3] made the jobs/id page accessible to logged out user --- lib/auth.ts | 2 +- middleware.ts | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/auth.ts b/lib/auth.ts index 577091d..41564fb 100755 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -1,4 +1,4 @@ -export const publicRoutes = ["/", "/jobs", "/api/jobs"]; +export const publicRoutes = ["/", "/jobs", "/api/jobs", "/jobs/[id]"]; export const authRoutes = ["/signin", "/signup"]; diff --git a/middleware.ts b/middleware.ts index b21c22f..72cc489 100755 --- a/middleware.ts +++ b/middleware.ts @@ -8,12 +8,23 @@ import { REDIRECT_URL, } from "@/lib/auth"; +function matchPublicRoute(pathname: string) { + return publicRoutes.some((route) => { + if (route.includes("[id]")) { + //eslint-disable-next-line + const regex = new RegExp("^" + route.replace("[id]", "[^/]+") + "$"); + return regex.test(pathname); + } + return route === pathname; + }); +} + export default auth((req) => { const { nextUrl } = req; const isLoggedIn = !!req.auth; const isNextApiRoute = nextUrl.pathname.startsWith(nextApiRoutes); const isAuthRoute = authRoutes.includes(nextUrl.pathname); - const isPublicRoute = publicRoutes.includes(nextUrl.pathname); + const isPublicRoute = matchPublicRoute(nextUrl.pathname); const isAdminRoute = nextUrl.pathname.startsWith(adminRoute); if (isNextApiRoute) return NextResponse.next(); From 79f78c1a4f4c7b3d2df501997f6cbe3e06f48f60 Mon Sep 17 00:00:00 2001 From: Ankit Date: Tue, 8 Apr 2025 00:58:11 +0530 Subject: [PATCH 3/3] removed apply btn & direct approval for job posting for admins --- app/actions/posts/jobs.ts | 2 +- app/actions/users/checkUser.ts | 1 + app/layout.tsx | 2 ++ components/Job/filterCard.tsx | 7 ------ package-lock.json | 39 ++++++++++++++++++++++++++++++++++ package.json | 1 + schema/jobs.ts | 2 +- 7 files changed, 45 insertions(+), 9 deletions(-) diff --git a/app/actions/posts/jobs.ts b/app/actions/posts/jobs.ts index 54ad542..d85c104 100755 --- a/app/actions/posts/jobs.ts +++ b/app/actions/posts/jobs.ts @@ -38,7 +38,7 @@ export async function CreateJob(postdata: createJobSchemaType) { salary_disclosed: postdata.salary_disclosed, salary_max: postdata.salary_max, salary_min: postdata.salary_min, - approved: false, + approved: response.role === "ADMIN" ? true : false, author: { connect: { id: response.userId, diff --git a/app/actions/users/checkUser.ts b/app/actions/users/checkUser.ts index 87c34e1..9205576 100755 --- a/app/actions/users/checkUser.ts +++ b/app/actions/users/checkUser.ts @@ -23,6 +23,7 @@ export async function CheckUser() { status: 200, message: "Logged In", userId: session.user.id, + role: isUser.role, }; } catch (error: any) { return { diff --git a/app/layout.tsx b/app/layout.tsx index 5704913..9718673 100755 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -7,6 +7,7 @@ import { auth } from "@/auth"; import { Toaster } from "@/components/ui/sonner"; import Loader from "./loading"; import RegisterSw from "@/components/RegisterSw"; +import { Analytics } from "@vercel/analytics/react"; const inter = Inter({ subsets: ["latin"] }); @@ -33,6 +34,7 @@ export default async function RootLayout({
+ diff --git a/components/Job/filterCard.tsx b/components/Job/filterCard.tsx index 4202558..a64a486 100755 --- a/components/Job/filterCard.tsx +++ b/components/Job/filterCard.tsx @@ -15,7 +15,6 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select"; -import ApplyFilterBtn from "./applyBtn"; import ClearFilterBtn from "./clearFIlterBtn"; const experienceValues = ["Fresher", "0-1y", "1y", "3y", "5y"]; @@ -107,8 +106,6 @@ export default function FilterSideBar() {
); })} - - @@ -140,8 +137,6 @@ export default function FilterSideBar() {
); })} - - @@ -173,8 +168,6 @@ export default function FilterSideBar() { ); })} - - diff --git a/package-lock.json b/package-lock.json index a39e484..e458846 100755 --- a/package-lock.json +++ b/package-lock.json @@ -43,6 +43,7 @@ "@tiptap/starter-kit": "^2.6.6", "@types/bcryptjs": "^2.4.6", "@typescript-eslint/parser": "^8.14.0", + "@vercel/analytics": "^1.5.0", "bcryptjs": "^2.4.3", "class-variance-authority": "^0.7.0", "cloudinary": "^2.5.1", @@ -4832,6 +4833,44 @@ "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==" }, + "node_modules/@vercel/analytics": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@vercel/analytics/-/analytics-1.5.0.tgz", + "integrity": "sha512-MYsBzfPki4gthY5HnYN7jgInhAZ7Ac1cYDoRWFomwGHWEX7odTEzbtg9kf/QSo7XEsEAqlQugA6gJ2WS2DEa3g==", + "license": "MPL-2.0", + "peerDependencies": { + "@remix-run/react": "^2", + "@sveltejs/kit": "^1 || ^2", + "next": ">= 13", + "react": "^18 || ^19 || ^19.0.0-rc", + "svelte": ">= 4", + "vue": "^3", + "vue-router": "^4" + }, + "peerDependenciesMeta": { + "@remix-run/react": { + "optional": true + }, + "@sveltejs/kit": { + "optional": true + }, + "next": { + "optional": true + }, + "react": { + "optional": true + }, + "svelte": { + "optional": true + }, + "vue": { + "optional": true + }, + "vue-router": { + "optional": true + } + } + }, "node_modules/@webassemblyjs/ast": { "version": "1.12.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.12.1.tgz", diff --git a/package.json b/package.json index 8e0ff25..ad59ade 100755 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "@tiptap/starter-kit": "^2.6.6", "@types/bcryptjs": "^2.4.6", "@typescript-eslint/parser": "^8.14.0", + "@vercel/analytics": "^1.5.0", "bcryptjs": "^2.4.3", "class-variance-authority": "^0.7.0", "cloudinary": "^2.5.1", diff --git a/schema/jobs.ts b/schema/jobs.ts index e3bbc12..ba1b8aa 100755 --- a/schema/jobs.ts +++ b/schema/jobs.ts @@ -22,7 +22,7 @@ export const createJobSchema = z position: z .string({ message: "Position is required" }) .min(2, { message: "Extend it little" }) - .max(20, { message: "Keep it shorter" }), + .max(25, { message: "Keep it shorter" }), company: z .string({ message: "Company name is required" })