Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

feat(jobs): add skill tags to jobs

Khuram Niaz5f37f34fb62f
diff --git a/__tests__/AddJob.spec.tsx b/__tests__/AddJob.spec.tsx
index c090cb0..21d49b9 100644
--- a/__tests__/AddJob.spec.tsx
+++ b/__tests__/AddJob.spec.tsx
@@ -70,9 +70,10 @@ describe("AddJob Component", () => {
jobTitles={mockJobTitles}
locations={mockLocations}
jobSources={mockJobSources}
+ tags={[]}
editJob={null}
resetEditJob={mockResetEditJob}
- />
+ />,
);
const addJobButton = screen.getByTestId("add-job-btn");
await user.click(addJobButton);
@@ -112,7 +113,7 @@ describe("AddJob Component", () => {
expect(screen.getByText("Location is required.")).toBeInTheDocument();
expect(screen.getByText("Source is required.")).toBeInTheDocument();
expect(
- screen.getByText("Job description is required.")
+ screen.getByText("Job description is required."),
).toBeInTheDocument();
});
it("should close the dialog when clicked on cancel button", async () => {
@@ -224,6 +225,7 @@ describe("AddJob Component", () => {
jobDescription: "<p>New Job Description</p>",
jobUrl: undefined,
applied: false,
+ tags: [],
});
});
});
diff --git a/__tests__/JobsContainer.spec.tsx b/__tests__/JobsContainer.spec.tsx
index ff332c3..6705d46 100644
--- a/__tests__/JobsContainer.spec.tsx
+++ b/__tests__/JobsContainer.spec.tsx
@@ -123,7 +123,12 @@ describe("JobsContainer Search Functionality", () => {
const mockLocations = [
{ id: "1", label: "Remote", value: "remote", createdBy: "user-1" },
- { id: "2", label: "San Francisco", value: "san francisco", createdBy: "user-1" },
+ {
+ id: "2",
+ label: "San Francisco",
+ value: "san francisco",
+ createdBy: "user-1",
+ },
];
const mockSources = [
@@ -135,9 +140,25 @@ describe("JobsContainer Search Functionality", () => {
{
id: "1",
userId: "user-1",
- JobTitle: { id: "1", label: "Full Stack Developer", value: "full stack developer", createdBy: "user-1" },
- Company: { id: "1", label: "Amazon", value: "amazon", createdBy: "user-1", logoUrl: "" },
- Location: { id: "1", label: "Remote", value: "remote", createdBy: "user-1" },
+ JobTitle: {
+ id: "1",
+ label: "Full Stack Developer",
+ value: "full stack developer",
+ createdBy: "user-1",
+ },
+ Company: {
+ id: "1",
+ label: "Amazon",
+ value: "amazon",
+ createdBy: "user-1",
+ logoUrl: "",
+ },
+ Location: {
+ id: "1",
+ label: "Remote",
+ value: "remote",
+ createdBy: "user-1",
+ },
Status: { id: "1", label: "Applied", value: "applied" },
JobSource: { id: "1", label: "Indeed", value: "indeed" },
jobType: "FT",
@@ -147,9 +168,25 @@ describe("JobsContainer Search Functionality", () => {
{
id: "2",
userId: "user-1",
- JobTitle: { id: "2", label: "Frontend Developer", value: "frontend developer", createdBy: "user-1" },
- Company: { id: "2", label: "Google", value: "google", createdBy: "user-1", logoUrl: "" },
- Location: { id: "2", label: "San Francisco", value: "san francisco", createdBy: "user-1" },
+ JobTitle: {
+ id: "2",
+ label: "Frontend Developer",
+ value: "frontend developer",
+ createdBy: "user-1",
+ },
+ Company: {
+ id: "2",
+ label: "Google",
+ value: "google",
+ createdBy: "user-1",
+ logoUrl: "",
+ },
+ Location: {
+ id: "2",
+ label: "San Francisco",
+ value: "san francisco",
+ createdBy: "user-1",
+ },
Status: { id: "2", label: "Interview", value: "interview" },
JobSource: { id: "2", label: "LinkedIn", value: "linkedin" },
jobType: "FT",
@@ -182,7 +219,8 @@ describe("JobsContainer Search Functionality", () => {
titles={mockTitles}
locations={mockLocations}
sources={mockSources}
- />
+ tags={[]}
+ />,
);
};
@@ -197,7 +235,9 @@ describe("JobsContainer Search Functionality", () => {
renderComponent();
await waitFor(() => {
- expect(screen.getByPlaceholderText("Search jobs...")).toBeInTheDocument();
+ expect(
+ screen.getByPlaceholderText("Search jobs..."),
+ ).toBeInTheDocument();
});
});
@@ -211,7 +251,9 @@ describe("JobsContainer Search Functionality", () => {
renderComponent();
await waitFor(() => {
- expect(screen.getByPlaceholderText("Search jobs...")).toBeInTheDocument();
+ expect(
+ screen.getByPlaceholderText("Search jobs..."),
+ ).toBeInTheDocument();
});
const searchInput = screen.getByPlaceholderText("Search jobs...");
@@ -356,7 +398,9 @@ describe("JobsContainer Search Functionality", () => {
renderComponent();
await waitFor(() => {
- expect(screen.getByPlaceholderText("Search jobs...")).toBeInTheDocument();
+ expect(
+ screen.getByPlaceholderText("Search jobs..."),
+ ).toBeInTheDocument();
});
// Type in search
diff --git a/__tests__/job.actions.spec.ts b/__tests__/job.actions.spec.ts
index 2e36441..5cb0cfc 100644
--- a/__tests__/job.actions.spec.ts
+++ b/__tests__/job.actions.spec.ts
@@ -67,6 +67,7 @@ describe("jobActions", () => {
applied: true,
userId: mockUser.id,
resume: "",
+ tags: [],
};
beforeEach(() => {
jest.clearAllMocks();
@@ -91,7 +92,7 @@ describe("jobActions", () => {
message: "Failed to fetch status list.",
};
(prisma.jobStatus.findMany as jest.Mock).mockRejectedValue(
- new Error("Failed to fetch status list.")
+ new Error("Failed to fetch status list."),
);
await expect(getStatusList()).resolves.toStrictEqual(mockErrorResponse);
@@ -113,7 +114,7 @@ describe("jobActions", () => {
it("should returns failure response on error", async () => {
(prisma.jobSource.findMany as jest.Mock).mockRejectedValue(
- new Error("Failed to fetch job source list.")
+ new Error("Failed to fetch job source list."),
);
const result = await getJobSourceList();
@@ -148,7 +149,7 @@ describe("jobActions", () => {
(getCurrentUser as jest.Mock).mockResolvedValue(mockUser);
(prisma.job.findMany as jest.Mock).mockRejectedValue(
- new Error("Database error")
+ new Error("Database error"),
);
const result = await getJobsList();
@@ -189,7 +190,7 @@ describe("jobActions", () => {
{ description: { contains: "Amazon" } },
],
}),
- })
+ }),
);
expect(prisma.job.count).toHaveBeenCalledWith(
expect.objectContaining({
@@ -201,7 +202,7 @@ describe("jobActions", () => {
{ description: { contains: "Amazon" } },
],
}),
- })
+ }),
);
});
@@ -212,7 +213,8 @@ describe("jobActions", () => {
await getJobsList(1, 10, undefined, "Developer");
- const findManyCall = (prisma.job.findMany as jest.Mock).mock.calls[0][0];
+ const findManyCall = (prisma.job.findMany as jest.Mock).mock
+ .calls[0][0];
expect(findManyCall.where.OR).toContainEqual({
JobTitle: { label: { contains: "Developer" } },
});
@@ -225,7 +227,8 @@ describe("jobActions", () => {
await getJobsList(1, 10, undefined, "Google");
- const findManyCall = (prisma.job.findMany as jest.Mock).mock.calls[0][0];
+ const findManyCall = (prisma.job.findMany as jest.Mock).mock
+ .calls[0][0];
expect(findManyCall.where.OR).toContainEqual({
Company: { label: { contains: "Google" } },
});
@@ -238,7 +241,8 @@ describe("jobActions", () => {
await getJobsList(1, 10, undefined, "Remote");
- const findManyCall = (prisma.job.findMany as jest.Mock).mock.calls[0][0];
+ const findManyCall = (prisma.job.findMany as jest.Mock).mock
+ .calls[0][0];
expect(findManyCall.where.OR).toContainEqual({
Location: { label: { contains: "Remote" } },
});
@@ -251,7 +255,8 @@ describe("jobActions", () => {
await getJobsList(1, 10, undefined, "React");
- const findManyCall = (prisma.job.findMany as jest.Mock).mock.calls[0][0];
+ const findManyCall = (prisma.job.findMany as jest.Mock).mock
+ .calls[0][0];
expect(findManyCall.where.OR).toContainEqual({
description: { contains: "React" },
});
@@ -264,7 +269,8 @@ describe("jobActions", () => {
await getJobsList(1, 10, "applied", "Developer");
- const findManyCall = (prisma.job.findMany as jest.Mock).mock.calls[0][0];
+ const findManyCall = (prisma.job.findMany as jest.Mock).mock
+ .calls[0][0];
expect(findManyCall.where).toMatchObject({
userId: mockUser.id,
Status: { value: "applied" },
@@ -279,7 +285,8 @@ describe("jobActions", () => {
await getJobsList(1, 10, undefined, undefined);
- const findManyCall = (prisma.job.findMany as jest.Mock).mock.calls[0][0];
+ const findManyCall = (prisma.job.findMany as jest.Mock).mock
+ .calls[0][0];
expect(findManyCall.where.OR).toBeUndefined();
});
@@ -290,7 +297,8 @@ describe("jobActions", () => {
await getJobsList(1, 10, undefined, "");
- const findManyCall = (prisma.job.findMany as jest.Mock).mock.calls[0][0];
+ const findManyCall = (prisma.job.findMany as jest.Mock).mock
+ .calls[0][0];
expect(findManyCall.where.OR).toBeUndefined();
});
@@ -322,7 +330,8 @@ describe("jobActions", () => {
await getJobsList(1, 10, "PT", "Developer");
- const findManyCall = (prisma.job.findMany as jest.Mock).mock.calls[0][0];
+ const findManyCall = (prisma.job.findMany as jest.Mock).mock
+ .calls[0][0];
expect(findManyCall.where).toMatchObject({
userId: mockUser.id,
jobType: "PT",
@@ -370,6 +379,7 @@ describe("jobActions", () => {
File: true,
},
},
+ tags: true,
},
});
});
@@ -378,7 +388,7 @@ describe("jobActions", () => {
(getCurrentUser as jest.Mock).mockResolvedValue({ id: "user123" });
(prisma.job.findUnique as jest.Mock).mockRejectedValue(
- new Error("Unexpected error")
+ new Error("Unexpected error"),
);
await expect(getJobDetails("job123")).resolves.toStrictEqual({
@@ -438,7 +448,7 @@ describe("jobActions", () => {
(getCurrentUser as jest.Mock).mockResolvedValue(mockUser);
(prisma.location.findFirst as jest.Mock).mockResolvedValue(null);
(prisma.location.create as jest.Mock).mockRejectedValue(
- new Error("Unexpected error")
+ new Error("Unexpected error"),
);
await expect(createLocation("location-name")).resolves.toStrictEqual({
@@ -510,7 +520,7 @@ describe("jobActions", () => {
(getCurrentUser as jest.Mock).mockResolvedValue(mockUser);
(prisma.job.create as jest.Mock).mockRejectedValue(
- new Error("Unexpected error")
+ new Error("Unexpected error"),
);
await expect(addJob(jobData)).resolves.toStrictEqual({
@@ -541,7 +551,7 @@ describe("jobActions", () => {
(getCurrentUser as jest.Mock).mockResolvedValue(mockUser);
(prisma.job.update as jest.Mock).mockRejectedValue(
- new Error("Unexpected error")
+ new Error("Unexpected error"),
);
await expect(updateJob(jobData)).resolves.toStrictEqual({
@@ -562,7 +572,7 @@ describe("jobActions", () => {
(getCurrentUser as jest.Mock).mockResolvedValue(mockUser);
await expect(
- updateJob({ ...jobData, id: undefined })
+ updateJob({ ...jobData, id: undefined }),
).resolves.toStrictEqual({
success: false,
message: "Id is not provide or no user privilages",
@@ -615,11 +625,11 @@ describe("jobActions", () => {
(getCurrentUser as jest.Mock).mockResolvedValue(mockUser);
(prisma.job.update as jest.Mock).mockRejectedValue(
- new Error("Unexpected error")
+ new Error("Unexpected error"),
);
await expect(
- updateJobStatus(jobData.id, jobData.status)
+ updateJobStatus(jobData.id, jobData.status),
).resolves.toStrictEqual({
success: false,
message: "Unexpected error",
@@ -629,7 +639,7 @@ describe("jobActions", () => {
(getCurrentUser as jest.Mock).mockResolvedValue(null);
await expect(
- updateJobStatus(jobData.id, jobData.status)
+ updateJobStatus(jobData.id, jobData.status),
).resolves.toStrictEqual({
success: false,
message: "Not authenticated",
@@ -664,7 +674,7 @@ describe("jobActions", () => {
(getCurrentUser as jest.Mock).mockResolvedValue(mockUser);
(prisma.job.delete as jest.Mock).mockRejectedValue(
- new Error("Unexpected error")
+ new Error("Unexpected error"),
);
await expect(deleteJobById("job-id")).resolves.toStrictEqual({
diff --git a/prisma/migrations/20260303014226_add_tag_model/migration.sql b/prisma/migrations/20260303014226_add_tag_model/migration.sql
new file mode 100644
index 0000000..1d9330f
--- /dev/null
+++ b/prisma/migrations/20260303014226_add_tag_model/migration.sql
@@ -0,0 +1,25 @@
+-- CreateTable
+CREATE TABLE "Tag" (
+ "id" TEXT NOT NULL PRIMARY KEY,
+ "label" TEXT NOT NULL,
+ "value" TEXT NOT NULL,
+ "createdBy" TEXT NOT NULL,
+ CONSTRAINT "Tag_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
+);
+
+-- CreateTable
+CREATE TABLE "_JobToTag" (
+ "A" TEXT NOT NULL,
+ "B" TEXT NOT NULL,
+ CONSTRAINT "_JobToTag_A_fkey" FOREIGN KEY ("A") REFERENCES "Job" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "_JobToTag_B_fkey" FOREIGN KEY ("B") REFERENCES "Tag" ("id") ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+-- CreateIndex
+CREATE UNIQUE INDEX "Tag_value_createdBy_key" ON "Tag"("value", "createdBy");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "_JobToTag_AB_unique" ON "_JobToTag"("A", "B");
+
+-- CreateIndex
+CREATE INDEX "_JobToTag_B_index" ON "_JobToTag"("B");
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index b968b38..c5d5393 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -32,6 +32,7 @@ model User {
Settings UserSettings?
ApiKey ApiKey[]
Note Note[]
+ Tag Tag[]
}
model ApiKey {
@@ -284,6 +285,7 @@ model Job {
Resume Resume? @relation(fields: [resumeId], references: [id])
resumeId String?
Notes Note[]
+ tags Tag[]
// Automation discovery fields
automationId String?
@@ -359,26 +361,26 @@ model Task {
}
model Automation {
- id String @id @default(uuid())
- userId String
- user User @relation(fields: [userId], references: [id])
+ id String @id @default(uuid())
+ userId String
+ user User @relation(fields: [userId], references: [id])
name String
jobBoard String
keywords String
location String
resumeId String
- resume Resume @relation(fields: [resumeId], references: [id])
- matchThreshold Int @default(80)
+ resume Resume @relation(fields: [resumeId], references: [id])
+ matchThreshold Int @default(80)
- scheduleHour Int
- nextRunAt DateTime?
- lastRunAt DateTime?
+ scheduleHour Int
+ nextRunAt DateTime?
+ lastRunAt DateTime?
- status String @default("active")
+ status String @default("active")
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
runs AutomationRun[]
discoveredJobs Job[]
@@ -388,22 +390,22 @@ model Automation {
}
model AutomationRun {
- id String @id @default(uuid())
- automationId String
- automation Automation @relation(fields: [automationId], references: [id], onDelete: Cascade)
+ id String @id @default(uuid())
+ automationId String
+ automation Automation @relation(fields: [automationId], references: [id], onDelete: Cascade)
- jobsSearched Int @default(0)
- jobsDeduplicated Int @default(0)
- jobsProcessed Int @default(0)
- jobsMatched Int @default(0)
- jobsSaved Int @default(0)
+ jobsSearched Int @default(0)
+ jobsDeduplicated Int @default(0)
+ jobsProcessed Int @default(0)
+ jobsMatched Int @default(0)
+ jobsSaved Int @default(0)
- status String @default("running")
- errorMessage String?
- blockedReason String?
+ status String @default("running")
+ errorMessage String?
+ blockedReason String?
- startedAt DateTime @default(now())
- completedAt DateTime?
+ startedAt DateTime @default(now())
+ completedAt DateTime?
@@index([automationId])
@@index([startedAt])
@@ -422,3 +424,14 @@ model Note {
@@index([jobId])
@@index([userId])
}
+
+model Tag {
+ id String @id @default(uuid())
+ label String
+ value String
+ createdBy String
+ user User @relation(fields: [createdBy], references: [id])
+ jobs Job[]
+
+ @@unique([value, createdBy])
+}
diff --git a/src/actions/job.actions.ts b/src/actions/job.actions.ts
index 28a740e..1658142 100644
--- a/src/actions/job.actions.ts
+++ b/src/actions/job.actions.ts
@@ -40,7 +40,7 @@ export const getJobsList = async (
page: number = 1,
limit: number = APP_CONSTANTS.RECORDS_PER_PAGE,
filter?: string,
- search?: string
+ search?: string,
): Promise<any | undefined> => {
try {
const user = await getCurrentUser();
@@ -162,7 +162,7 @@ export async function* getJobsIterator(filter?: string, pageSize = 200) {
}
export const getJobDetails = async (
- jobId: string
+ jobId: string,
): Promise<any | undefined> => {
try {
if (!jobId) {
@@ -189,6 +189,7 @@ export const getJobDetails = async (
File: true,
},
},
+ tags: true,
},
});
return { job, success: true };
@@ -199,7 +200,7 @@ export const getJobDetails = async (
};
export const createLocation = async (
- label: string
+ label: string,
): Promise<any | undefined> => {
try {
const user = await getCurrentUser();
@@ -233,7 +234,7 @@ export const createLocation = async (
};
export const createJobSource = async (
- label: string
+ label: string,
): Promise<any | undefined> => {
try {
const user = await getCurrentUser();
@@ -267,7 +268,7 @@ export const createJobSource = async (
};
export const addJob = async (
- data: z.infer<typeof AddJobFormSchema>
+ data: z.infer<typeof AddJobFormSchema>,
): Promise<any | undefined> => {
try {
const user = await getCurrentUser();
@@ -290,8 +291,11 @@ export const addJob = async (
jobUrl,
applied,
resume,
+ tags,
} = data;
+ const tagIds = tags ?? [];
+
const job = await prisma.job.create({
data: {
jobTitleId: title,
@@ -309,6 +313,9 @@ export const addJob = async (
jobUrl,
applied,
resumeId: resume,
+ ...(tagIds.length > 0
+ ? { tags: { connect: tagIds.map((id) => ({ id })) } }
+ : {}),
},
});
return { job, success: true };
@@ -319,7 +326,7 @@ export const addJob = async (
};
export const updateJob = async (
- data: z.infer<typeof AddJobFormSchema>
+ data: z.infer<typeof AddJobFormSchema>,
): Promise<any | undefined> => {
try {
const user = await getCurrentUser();
@@ -346,8 +353,11 @@ export const updateJob = async (
jobUrl,
applied,
resume,
+ tags,
} = data;
+ const tagIds = tags ?? [];
+
const job = await prisma.job.update({
where: {
id,
@@ -367,6 +377,7 @@ export const updateJob = async (
jobUrl,
applied,
resumeId: resume,
+ tags: { set: tagIds.map((id) => ({ id })) },
},
});
// revalidatePath("/dashboard/myjobs", "page");
@@ -379,7 +390,7 @@ export const updateJob = async (
export const updateJobStatus = async (
jobId: string,
- status: JobStatus
+ status: JobStatus,
): Promise<any | undefined> => {
try {
const user = await getCurrentUser();
@@ -422,7 +433,7 @@ export const updateJobStatus = async (
};
export const deleteJobById = async (
- jobId: string
+ jobId: string,
): Promise<any | undefined> => {
try {
const user = await getCurrentUser();
diff --git a/src/actions/tag.actions.ts b/src/actions/tag.actions.ts
new file mode 100644
index 0000000..49acfd4
--- /dev/null
+++ b/src/actions/tag.actions.ts
@@ -0,0 +1,113 @@
+"use server";
+import prisma from "@/lib/db";
+import { handleError } from "@/lib/utils";
+import { getCurrentUser } from "@/utils/user.utils";
+import { APP_CONSTANTS } from "@/lib/constants";
+
+export const getAllTags = async (): Promise<any | undefined> => {
+ try {
+ const user = await getCurrentUser();
+ if (!user) {
+ throw new Error("Not authenticated");
+ }
+ const list = await prisma.tag.findMany({
+ where: { createdBy: user.id },
+ orderBy: { label: "asc" },
+ });
+ return list;
+ } catch (error) {
+ const msg = "Failed to fetch tag list. ";
+ return handleError(error, msg);
+ }
+};
+
+export const getTagList = async (
+ page: number = 1,
+ limit: number = APP_CONSTANTS.RECORDS_PER_PAGE,
+): Promise<any | undefined> => {
+ try {
+ const user = await getCurrentUser();
+ if (!user) {
+ throw new Error("Not authenticated");
+ }
+ const skip = (page - 1) * limit;
+
+ const [data, total] = await Promise.all([
+ prisma.tag.findMany({
+ where: { createdBy: user.id },
+ skip,
+ take: limit,
+ select: {
+ id: true,
+ label: true,
+ value: true,
+ _count: { select: { jobs: true } },
+ },
+ orderBy: { label: "asc" },
+ }),
+ prisma.tag.count({ where: { createdBy: user.id } }),
+ ]);
+
+ return { data, total };
+ } catch (error) {
+ const msg = "Failed to fetch tag list. ";
+ return handleError(error, msg);
+ }
+};
+
+export const createTag = async (label: string): Promise<any | undefined> => {
+ try {
+ const user = await getCurrentUser();
+ if (!user) {
+ throw new Error("Not authenticated");
+ }
+
+ const trimmed = label.trim();
+ if (!trimmed) {
+ throw new Error("Tag label cannot be empty.");
+ }
+
+ const value = trimmed.toLowerCase();
+
+ const tag = await prisma.tag.upsert({
+ where: { value_createdBy: { value, createdBy: user.id } },
+ update: {},
+ create: { label: trimmed, value, createdBy: user.id },
+ });
+
+ return { data: tag, success: true };
+ } catch (error) {
+ const msg = "Failed to create tag. ";
+ return handleError(error, msg);
+ }
+};
+
+export const deleteTagById = async (
+ tagId: string,
+): Promise<any | undefined> => {
+ try {
+ const user = await getCurrentUser();
+ if (!user) {
+ throw new Error("Not authenticated");
+ }
+
+ const jobs = await prisma.job.count({
+ where: { tags: { some: { id: tagId } } },
+ });
+
+ if (jobs > 0) {
+ throw new Error(
+ `Skill tag cannot be deleted because it is linked to ${jobs} job(s).`,
+ );
+ }
+
+ const res = await prisma.tag.delete({
+ where: { id: tagId, createdBy: user.id },
+ });
+
+ return { res, success: true };
+ } catch (error) {
+ const msg = "Failed to delete tag.";
+ return handleError(error, msg);
+ }
+};
diff --git a/src/app/dashboard/myjobs/page.tsx b/src/app/dashboard/myjobs/page.tsx
index 90bf512..1bbbfc2 100644
--- a/src/app/dashboard/myjobs/page.tsx
+++ b/src/app/dashboard/myjobs/page.tsx
@@ -5,19 +5,22 @@ import JobsContainer from "@/components/myjobs/JobsContainer";
import { getAllCompanies } from "@/actions/company.actions";
import { getAllJobTitles } from "@/actions/jobtitle.actions";
import { getAllJobLocations } from "@/actions/jobLocation.actions";
+import { getAllTags } from "@/actions/tag.actions";
export const metadata: Metadata = {
title: "My Jobs | JobSync",
};
async function MyJobs() {
- const [statuses, companies, titles, locations, sources] = await Promise.all([
- getStatusList(),
- getAllCompanies(),
- getAllJobTitles(),
- getAllJobLocations(),
- getJobSourceList(),
- ]);
+ const [statuses, companies, titles, locations, sources, tags] =
+ await Promise.all([
+ getStatusList(),
+ getAllCompanies(),
+ getAllJobTitles(),
+ getAllJobLocations(),
+ getJobSourceList(),
+ getAllTags(),
+ ]);
return (
<div className="col-span-3">
<JobsContainer
@@ -26,6 +29,7 @@ async function MyJobs() {
locations={locations}
sources={sources}
statuses={statuses}
+ tags={tags ?? []}
/>
</div>
);
diff --git a/src/components/admin/AddTag.tsx b/src/components/admin/AddTag.tsx
new file mode 100644
index 0000000..0614df7
--- /dev/null
+++ b/src/components/admin/AddTag.tsx
@@ -0,0 +1,135 @@
+"use client";
+import { useTransition, useState } from "react";
+import { Button } from "../ui/button";
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "../ui/dialog";
+import { Loader, PlusCircle } from "lucide-react";
+import { z } from "zod";
+import { useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import {
+ Form,
+ FormControl,
+ FormField,
+ FormItem,
+ FormLabel,
+ FormMessage,
+} from "../ui/form";
+import { Input } from "../ui/input";
+import { toast } from "../ui/use-toast";
+import { createTag } from "@/actions/tag.actions";
+
+const AddTagFormSchema = z.object({
+ label: z
+ .string({ error: "Skill label is required." })
+ .min(1, { message: "Skill label cannot be empty." })
+ .max(60, { message: "Skill label must be 60 characters or fewer." }),
+});
+
+type AddTagProps = {
+ reloadTags: () => void;
+};
+
+function AddTag({ reloadTags }: AddTagProps) {
+ const [dialogOpen, setDialogOpen] = useState(false);
+ const [isPending, startTransition] = useTransition();
+
+ const form = useForm<z.infer<typeof AddTagFormSchema>>({
+ resolver: zodResolver(AddTagFormSchema),
+ defaultValues: { label: "" },
+ });
+
+ const { reset } = form;
+
+ const openDialog = () => {
+ reset();
+ setDialogOpen(true);
+ };
+
+ const onSubmit = (values: z.infer<typeof AddTagFormSchema>) => {
+ startTransition(async () => {
+ const result = await createTag(values.label);
+ if (result?.success) {
+ toast({
+ variant: "success",
+ description: "Skill tag has been added successfully.",
+ });
+ setDialogOpen(false);
+ reset();
+ reloadTags();
+ } else {
+ toast({
+ variant: "destructive",
+ title: "Error!",
+ description: result?.message ?? "Failed to create skill tag.",
+ });
+ }
+ });
+ };
+
+ return (
+ <>
+ <Button
+ size="sm"
+ variant="outline"
+ className="h-8 gap-1"
+ onClick={openDialog}
+ >
+ <PlusCircle className="h-3.5 w-3.5" />
+ <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">
+ Add Skill
+ </span>
+ </Button>
+ <Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>Add Skill</DialogTitle>
+ <DialogDescription>
+ Add a new skill tag to use across your job applications.
+ </DialogDescription>
+ </DialogHeader>
+ <Form {...form}>
+ <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
+ <FormField
+ control={form.control}
+ name="label"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Skill Name</FormLabel>
+ <FormControl>
+ <Input placeholder="e.g. React, AWS, Python" {...field} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ <DialogFooter>
+ <Button
+ type="button"
+ variant="outline"
+ onClick={() => setDialogOpen(false)}
+ >
+ Cancel
+ </Button>
+ <Button type="submit" disabled={isPending}>
+ Save
+ {isPending && (
+ <Loader className="ml-2 h-4 w-4 shrink-0 spinner" />
+ )}
+ </Button>
+ </DialogFooter>
+ </form>
+ </Form>
+ </DialogContent>
+ </Dialog>
+ </>
+ );
+}
+
+export default AddTag;
diff --git a/src/components/admin/AdminTabsContainer.tsx b/src/components/admin/AdminTabsContainer.tsx
index a5801c5..450b2df 100644
--- a/src/components/admin/AdminTabsContainer.tsx
+++ b/src/components/admin/AdminTabsContainer.tsx
@@ -3,6 +3,7 @@ import CompaniesContainer from "@/components/admin/CompaniesContainer";
import JobLocationsContainer from "@/components/admin/JobLocationsContainer";
import JobSourcesContainer from "@/components/admin/JobSourcesContainer";
import JobTitlesContainer from "@/components/admin/JobTitlesContainer";
+import TagsContainer from "@/components/admin/TagsContainer";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useCallback } from "react";
@@ -19,7 +20,7 @@ function AdminTabsContainer() {
return params.toString();
},
- [queryParams]
+ [queryParams],
);
const onTabChange = (tab: string) => {
@@ -35,6 +36,7 @@ function AdminTabsContainer() {
<TabsTrigger value="job-titles">Job Titles</TabsTrigger>
<TabsTrigger value="locations">Locations</TabsTrigger>
<TabsTrigger value="sources">Sources</TabsTrigger>
+ <TabsTrigger value="skills">Skills</TabsTrigger>
</TabsList>
<TabsContent value="companies">
<CompaniesContainer />
@@ -48,6 +50,9 @@ function AdminTabsContainer() {
<TabsContent value="sources">
<JobSourcesContainer />
</TabsContent>
+ <TabsContent value="skills">
+ <TagsContainer />
+ </TabsContent>
</Tabs>
);
}
diff --git a/src/components/admin/TagsContainer.tsx b/src/components/admin/TagsContainer.tsx
new file mode 100644
index 0000000..2b948cf
--- /dev/null
+++ b/src/components/admin/TagsContainer.tsx
@@ -0,0 +1,100 @@
+"use client";
+import { useCallback, useEffect, useState } from "react";
+import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";
+import { Tag } from "@/models/job.model";
+import { getTagList } from "@/actions/tag.actions";
+import { APP_CONSTANTS } from "@/lib/constants";
+import Loading from "../Loading";
+import { Button } from "../ui/button";
+import { RecordsPerPageSelector } from "../RecordsPerPageSelector";
+import { RecordsCount } from "../RecordsCount";
+import TagsTable from "./TagsTable";
+import AddTag from "./AddTag";
+
+function TagsContainer() {
+ const [tags, setTags] = useState<Tag[]>([]);
+ const [totalTags, setTotalTags] = useState<number>(0);
+ const [page, setPage] = useState<number>(1);
+ const [loading, setLoading] = useState<boolean>(false);
+ const [recordsPerPage, setRecordsPerPage] = useState<number>(
+ APP_CONSTANTS.RECORDS_PER_PAGE,
+ );
+
+ const loadTags = useCallback(
+ async (page: number) => {
+ setLoading(true);
+ try {
+ const { data, total } = await getTagList(page, recordsPerPage);
+ if (data) {
+ setTags((prev) => (page === 1 ? data : [...prev, ...data]));
+ setTotalTags(total);
+ setPage(page);
+ }
+ } finally {
+ setLoading(false);
+ }
+ },
+ [recordsPerPage],
+ );
+
+ const reloadTags = useCallback(async () => {
+ await loadTags(1);
+ }, [loadTags]);
+
+ useEffect(() => {
+ (async () => await loadTags(1))();
+ }, [loadTags, recordsPerPage]);
+
+ return (
+ <>
+ <div className="col-span-3">
+ <Card>
+ <CardHeader className="flex-row justify-between items-center">
+ <CardTitle>Skills</CardTitle>
+ <div className="flex items-center">
+ <div className="ml-auto flex items-center gap-2">
+ <AddTag reloadTags={reloadTags} />
+ </div>
+ </div>
+ </CardHeader>
+ <CardContent>
+ {loading && <Loading />}
+ {tags.length > 0 && (
+ <>
+ <TagsTable tags={tags} reloadTags={reloadTags} />
+ <div className="flex items-center justify-between mt-4">
+ <RecordsCount
+ count={tags.length}
+ total={totalTags}
+ label="skills"
+ />
+ {totalTags > APP_CONSTANTS.RECORDS_PER_PAGE && (
+ <RecordsPerPageSelector
+ value={recordsPerPage}
+ onChange={setRecordsPerPage}
+ />
+ )}
+ </div>
+ </>
+ )}
+ {tags.length < totalTags && (
+ <div className="flex justify-center p-4">
+ <Button
+ size="sm"
+ variant="outline"
+ onClick={() => loadTags(page + 1)}
+ disabled={loading}
+ className="btn btn-primary"
+ >
+ {loading ? "Loading..." : "Load More"}
+ </Button>
+ </div>
+ )}
+ </CardContent>
+ </Card>
+ </div>
+ </>
+ );
+}
+
+export default TagsContainer;
diff --git a/src/components/admin/TagsTable.tsx b/src/components/admin/TagsTable.tsx
new file mode 100644
index 0000000..34bd295
--- /dev/null
+++ b/src/components/admin/TagsTable.tsx
@@ -0,0 +1,130 @@
+"use client";
+import { Button } from "../ui/button";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuTrigger,
+} from "../ui/dropdown-menu";
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "../ui/table";
+import { Tag } from "@/models/job.model";
+import { MoreHorizontal, Trash } from "lucide-react";
+import { useState } from "react";
+import { deleteTagById } from "@/actions/tag.actions";
+import { toast } from "../ui/use-toast";
+import { DeleteAlertDialog } from "../DeleteAlertDialog";
+import { AlertDialog } from "@/models/alertDialog.model";
+
+type TagsTableProps = {
+ tags: Tag[];
+ reloadTags: () => void;
+};
+
+function TagsTable({ tags, reloadTags }: TagsTableProps) {
+ const [alert, setAlert] = useState<AlertDialog>({
+ openState: false,
+ deleteAction: false,
+ });
+
+ const onDeleteTag = (tag: Tag) => {
+ if ((tag._count?.jobs ?? 0) > 0) {
+ setAlert({
+ openState: true,
+ title: "Skill is in use!",
+ description: `This skill is linked to ${tag._count?.jobs} job(s) and cannot be deleted.`,
+ deleteAction: false,
+ });
+ } else {
+ setAlert({
+ openState: true,
+ deleteAction: true,
+ itemId: tag.id,
+ });
+ }
+ };
+
+ const deleteTag = async (tagId: string | undefined) => {
+ if (!tagId) return;
+ const { success, message } = await deleteTagById(tagId);
+ if (success) {
+ toast({
+ variant: "success",
+ description: "Skill tag has been deleted successfully",
+ });
+ reloadTags();
+ } else {
+ toast({
+ variant: "destructive",
+ title: "Error!",
+ description: message,
+ });
+ }
+ };
+
+ return (
+ <>
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Skill Label</TableHead>
+ <TableHead className="hidden sm:table-cell">Value</TableHead>
+ <TableHead># Jobs</TableHead>
+ <TableHead>Actions</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {tags.map((tag: Tag) => (
+ <TableRow key={tag.id}>
+ <TableCell className="font-medium">{tag.label}</TableCell>
+ <TableCell className="font-medium hidden sm:table-cell">
+ {tag.value}
+ </TableCell>
+ <TableCell className="font-medium">
+ {tag._count?.jobs ?? 0}
+ </TableCell>
+ <TableCell>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button aria-haspopup="true" size="icon" variant="ghost">
+ <MoreHorizontal className="h-4 w-4" />
+ <span className="sr-only">Toggle menu</span>
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuLabel>Actions</DropdownMenuLabel>
+ <DropdownMenuItem
+ className="text-red-600 cursor-pointer"
+ onClick={() => onDeleteTag(tag)}
+ >
+ <Trash className="mr-2 h-4 w-4" />
+ Delete
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ <DeleteAlertDialog
+ pageTitle="skill"
+ open={alert.openState}
+ onOpenChange={() => setAlert({ openState: false, deleteAction: false })}
+ onDelete={() => deleteTag(alert.itemId)}
+ alertTitle={alert.title}
+ alertDescription={alert.description}
+ deleteAction={alert.deleteAction}
+ />
+ </>
+ );
+}
+
+export default TagsTable;
diff --git a/src/components/myjobs/AddJob.tsx b/src/components/myjobs/AddJob.tsx
index 4ace990..097359c 100644
--- a/src/components/myjobs/AddJob.tsx
+++ b/src/components/myjobs/AddJob.tsx
@@ -22,6 +22,7 @@ import {
JobSource,
JobStatus,
JobTitle,
+ Tag,
} from "@/models/job.model";
import { addDays } from "date-fns";
import { z } from "zod";
@@ -47,6 +48,7 @@ import { NotesCollapsibleSection } from "./NotesCollapsibleSection";
import { Resume } from "@/models/profile.model";
import CreateResume from "../profile/CreateResume";
import { getResumeList } from "@/actions/profile.actions";
+import { TagInput } from "./TagInput";
type AddJobProps = {
jobStatuses: JobStatus[];
@@ -54,6 +56,7 @@ type AddJobProps = {
jobTitles: JobTitle[];
locations: JobLocation[];
jobSources: JobSource[];
+ tags: Tag[];
editJob?: JobResponse | null;
resetEditJob: () => void;
};
@@ -64,12 +67,14 @@ export function AddJob({
jobTitles,
locations,
jobSources,
+ tags,
editJob,
resetEditJob,
}: AddJobProps) {
const [dialogOpen, setDialogOpen] = useState(false);
const [resumeDialogOpen, setResumeDialogOpen] = useState(false);
const [resumes, setResumes] = useState<Resume[]>([]);
+ const [availableTags, setAvailableTags] = useState<Tag[]>(tags);
const [isPending, startTransition] = useTransition();
const form = useForm<z.infer<typeof AddJobFormSchema>>({
resolver: zodResolver(AddJobFormSchema) as any,
@@ -113,9 +118,18 @@ export function AddJob({
jobUrl: editJob.jobUrl ?? undefined,
dateApplied: editJob.appliedDate ?? undefined,
resume: editJob.Resume?.id ?? undefined,
+ tags: editJob.tags?.map((t) => t.id) ?? [],
},
{ keepDefaultValues: true },
);
+ // Merge any tags from editJob into the local pool so they're selectable
+ if (editJob.tags && editJob.tags.length > 0) {
+ setAvailableTags((prev) => {
+ const existing = new Set(prev.map((t) => t.id));
+ const incoming = editJob.tags!.filter((t) => !existing.has(t.id));
+ return incoming.length > 0 ? [...prev, ...incoming] : prev;
+ });
+ }
setDialogOpen(true);
}
}, [editJob, reset]);
@@ -475,6 +489,27 @@ export function AddJob({
/>
</div>
+ {/* Add Skill Tags */}
+ <div className="md:col-span-2">
+ <FormField
+ control={form.control}
+ name="tags"
+ render={({ field }) => (
+ <FormItem className="flex flex-col">
+ <FormLabel>Add Skill</FormLabel>
+ <FormControl>
+ <TagInput
+ availableTags={availableTags}
+ selectedTagIds={field.value ?? []}
+ onChange={(ids) => field.onChange(ids)}
+ />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </div>
+
{/* Job Description */}
<div className="md:col-span-2">
<FormField
@@ -493,9 +528,7 @@ export function AddJob({
)}
/>
</div>
- {editJob && (
- <NotesCollapsibleSection jobId={editJob.id} />
- )}
+ {editJob && <NotesCollapsibleSection jobId={editJob.id} />}
<div className="md:col-span-2">
<DialogFooter
// className="md:col-span
diff --git a/src/components/myjobs/JobDetails.tsx b/src/components/myjobs/JobDetails.tsx
index 7d4f141..8c7dc2d 100644
--- a/src/components/myjobs/JobDetails.tsx
+++ b/src/components/myjobs/JobDetails.tsx
@@ -83,7 +83,7 @@ function JobDetails({ job }: { job: JobResponse }) {
? DownloadFileButton(
job?.Resume?.File?.filePath,
job?.Resume?.title,
- job?.Resume?.File?.fileName
+ job?.Resume?.File?.fileName,
)
: null}
</div>
@@ -96,7 +96,7 @@ function JobDetails({ job }: { job: JobResponse }) {
className={cn(
"w-[70px] justify-center",
job.Status?.value === "applied" && "bg-cyan-500",
- job.Status?.value === "interview" && "bg-green-500"
+ job.Status?.value === "interview" && "bg-green-500",
)}
>
{job.Status?.label}
@@ -106,6 +106,15 @@ function JobDetails({ job }: { job: JobResponse }) {
{job?.appliedDate ? format(new Date(job?.appliedDate), "PP") : ""}
</span>
</h3>
+ {job.tags && job.tags.length > 0 && (
+ <div className="my-3 ml-4 flex flex-wrap gap-1">
+ {job.tags.map((tag) => (
+ <Badge key={tag.id} variant="secondary">
+ {tag.label}
+ </Badge>
+ ))}
+ </div>
+ )}
{job.jobUrl && (
<div className="my-3 ml-4">
<span className="font-semibold mr-2">Job URL:</span>
diff --git a/src/components/myjobs/JobsContainer.tsx b/src/components/myjobs/JobsContainer.tsx
index f94a3ff..4a23867 100644
--- a/src/components/myjobs/JobsContainer.tsx
+++ b/src/components/myjobs/JobsContainer.tsx
@@ -24,6 +24,7 @@ import {
JobSource,
JobStatus,
JobTitle,
+ Tag,
} from "@/models/job.model";
import {
Select,
@@ -51,6 +52,7 @@ type MyJobsProps = {
titles: JobTitle[];
locations: JobLocation[];
sources: JobSource[];
+ tags: Tag[];
};
function JobsContainer({
@@ -59,6 +61,7 @@ function JobsContainer({
titles,
locations,
sources,
+ tags,
}: MyJobsProps) {
const router = useRouter();
const pathname = usePathname();
@@ -70,7 +73,7 @@ function JobsContainer({
return params.toString();
},
- [queryParams]
+ [queryParams],
);
const [jobs, setJobs] = useState<JobResponse[]>([]);
const [page, setPage] = useState(1);
@@ -95,7 +98,7 @@ function JobsContainer({
page,
jobsPerPage,
filter,
- search
+ search,
);
if (success && data) {
setJobs((prev) => (page === 1 ? data : [...prev, ...data]));
@@ -112,7 +115,7 @@ function JobsContainer({
return;
}
},
- [jobsPerPage]
+ [jobsPerPage],
);
const reloadJobs = useCallback(async () => {
@@ -292,6 +295,7 @@ function JobsContainer({
jobTitles={titles}
locations={locations}
jobSources={sources}
+ tags={tags}
editJob={editJob}
resetEditJob={resetEditJob}
/>
@@ -329,7 +333,9 @@ function JobsContainer({
<Button
size="sm"
variant="outline"
- onClick={() => loadJobs(page + 1, filterKey, searchTerm || undefined)}
+ onClick={() =>
+ loadJobs(page + 1, filterKey, searchTerm || undefined)
+ }
disabled={loading}
className="btn btn-primary"
>
diff --git a/src/components/myjobs/TagInput.tsx b/src/components/myjobs/TagInput.tsx
new file mode 100644
index 0000000..18496b7
--- /dev/null
+++ b/src/components/myjobs/TagInput.tsx
@@ -0,0 +1,181 @@
+"use client";
+import { useState, useTransition } from "react";
+import { X, ChevronsUpDown, CirclePlus, Loader } from "lucide-react";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@/components/ui/popover";
+import {
+ Command,
+ CommandEmpty,
+ CommandGroup,
+ CommandInput,
+ CommandItem,
+ CommandList,
+} from "@/components/ui/command";
+import { Badge } from "@/components/ui/badge";
+import { Button } from "@/components/ui/button";
+import { Tag } from "@/models/job.model";
+import { createTag } from "@/actions/tag.actions";
+import { toast } from "../ui/use-toast";
+import { cn } from "@/lib/utils";
+
+const MAX_TAGS = 10;
+
+interface TagInputProps {
+ availableTags: Tag[];
+ selectedTagIds: string[];
+ onChange: (ids: string[]) => void;
+}
+
+export function TagInput({
+ availableTags,
+ selectedTagIds,
+ onChange,
+}: TagInputProps) {
+ const [open, setOpen] = useState(false);
+ const [inputValue, setInputValue] = useState("");
+ const [localTags, setLocalTags] = useState<Tag[]>(availableTags);
+ const [isPending, startTransition] = useTransition();
+
+ const selectedTags = localTags.filter((t) => selectedTagIds.includes(t.id));
+ const isMaxReached = selectedTagIds.length >= MAX_TAGS;
+
+ // Tags not yet selected, filtered by input
+ const filteredOptions = localTags.filter(
+ (t) =>
+ !selectedTagIds.includes(t.id) &&
+ t.label.toLowerCase().includes(inputValue.toLowerCase()),
+ );
+
+ // Whether the typed value exactly matches an existing tag (case-insensitive)
+ const exactMatchExists = localTags.some(
+ (t) => t.value === inputValue.trim().toLowerCase(),
+ );
+
+ const addTagById = (id: string) => {
+ if (selectedTagIds.length >= MAX_TAGS) return;
+ onChange([...selectedTagIds, id]);
+ };
+
+ const removeTagById = (id: string) => {
+ onChange(selectedTagIds.filter((tid) => tid !== id));
+ };
+
+ const handleCreate = () => {
+ const label = inputValue.trim();
+ if (!label || isMaxReached) return;
+
+ startTransition(async () => {
+ const result = await createTag(label);
+ if (!result?.success) {
+ toast({
+ variant: "destructive",
+ title: "Error!",
+ description: result?.message ?? "Failed to create skill tag.",
+ });
+ return;
+ }
+ const newTag: Tag = result.data;
+ // Add to local pool if not already there
+ setLocalTags((prev) =>
+ prev.some((t) => t.id === newTag.id) ? prev : [...prev, newTag],
+ );
+ addTagById(newTag.id);
+ setInputValue("");
+ setOpen(false);
+ });
+ };
+
+ const handleSelect = (tagId: string) => {
+ addTagById(tagId);
+ setInputValue("");
+ setOpen(false);
+ };
+
+ return (
+ <div className="flex flex-col gap-2">
+ <Popover open={open} onOpenChange={setOpen}>
+ <PopoverTrigger asChild>
+ <Button
+ variant="outline"
+ role="combobox"
+ aria-expanded={open}
+ className={cn(
+ "w-full justify-between font-normal",
+ isMaxReached && "opacity-50 cursor-not-allowed",
+ )}
+ disabled={isMaxReached}
+ type="button"
+ >
+ {isMaxReached
+ ? `Max ${MAX_TAGS} skills reached`
+ : "Search or add a skill..."}
+ <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent className="w-full p-0" align="start">
+ <Command shouldFilter={false}>
+ <CommandInput
+ placeholder="Type a skill..."
+ value={inputValue}
+ onValueChange={setInputValue}
+ />
+ <CommandList>
+ {filteredOptions.length === 0 && !inputValue && (
+ <CommandEmpty>No skills found.</CommandEmpty>
+ )}
+ {filteredOptions.length > 0 && (
+ <CommandGroup>
+ {filteredOptions.map((tag) => (
+ <CommandItem
+ key={tag.id}
+ onSelect={() => handleSelect(tag.id)}
+ >
+ {tag.label}
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ )}
+ {inputValue.trim() && !exactMatchExists && (
+ <CommandGroup>
+ <CommandItem
+ onSelect={handleCreate}
+ disabled={isPending || isMaxReached}
+ className="text-primary"
+ >
+ {isPending ? (
+ <Loader className="mr-2 h-4 w-4 spinner" />
+ ) : (
+ <CirclePlus className="mr-2 h-4 w-4" />
+ )}
+ Create &quot;{inputValue.trim()}&quot;
+ </CommandItem>
+ </CommandGroup>
+ )}
+ </CommandList>
+ </Command>
+ </PopoverContent>
+ </Popover>
+
+ {selectedTags.length > 0 && (
+ <div className="flex flex-wrap gap-1.5">
+ {selectedTags.map((tag) => (
+ <Badge key={tag.id} variant="secondary" className="gap-1 pr-1">
+ {tag.label}
+ <button
+ type="button"
+ onClick={() => removeTagById(tag.id)}
+ className="ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5"
+ aria-label={`Remove ${tag.label}`}
+ >
+ <X className="h-3 w-3" />
+ </button>
+ </Badge>
+ ))}
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/src/models/addJobForm.schema.ts b/src/models/addJobForm.schema.ts
index 1469d09..4ad9e86 100644
--- a/src/models/addJobForm.schema.ts
+++ b/src/models/addJobForm.schema.ts
@@ -58,4 +58,5 @@ export const AddJobFormSchema = z.object({
jobUrl: z.string().optional(),
applied: z.boolean().default(false),
resume: z.string().optional(),
+ tags: z.array(z.string()).max(10).optional().default([]),
});
diff --git a/src/models/job.model.ts b/src/models/job.model.ts
index 3e0ee4a..44350fd 100644
--- a/src/models/job.model.ts
+++ b/src/models/job.model.ts
@@ -17,6 +17,16 @@ export interface JobForm {
applied: boolean;
}
+export interface Tag {
+ id: string;
+ label: string;
+ value: string;
+ createdBy: string;
+ _count?: {
+ jobs: number;
+ };
+}
+
export interface JobResponse {
id: string;
userId: string;
@@ -37,6 +47,7 @@ export interface JobResponse {
Resume?: Resume;
matchScore?: number | null;
matchData?: string | null;
+ tags?: Tag[];
_count?: { Notes?: number };
}