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.
TypeScript ai-agentai-resume-analyzerapplication-trackerapplication-tracking-systematscareerjob-applicationjob-automationjob-huntingjob-searchjob-seeker-toolsjob-trackerjob-trackingjobsearchjobseekersmcpollamaresumeresume-reviewself-hosted
feat(profile): add a confirmed Delete button to each resume certification, removing the section with its last entry; toast on successful certification and skills section deletes
Khuram Niaz440012e72bf7
diff --git a/__tests__/ResumeContainer.spec.tsx b/__tests__/ResumeContainer.spec.tsxindex e5b6454..67f74f6 100644--- a/__tests__/ResumeContainer.spec.tsx+++ b/__tests__/ResumeContainer.spec.tsx@@ -18,6 +18,7 @@ vi.mock("next/navigation", () => ({vi.mock("@/actions/profile.actions", () => ({deleteResumeById: vi.fn(),+ deleteCertification: vi.fn(),deleteSkillsSection: vi.fn(),setDefaultResume: vi.fn(),}));diff --git a/__tests__/resumeSection.actions.spec.ts b/__tests__/resumeSection.actions.spec.tsindex 7659ea9..4635dda 100644--- a/__tests__/resumeSection.actions.spec.ts+++ b/__tests__/resumeSection.actions.spec.ts@@ -7,6 +7,7 @@ import {updateEducation,addCertification,updateCertification,+ deleteCertification,addSkillsSection,updateSkillsSection,deleteSkillsSection,@@ -28,7 +29,12 @@ vi.mock("@prisma/client", () => {},workExperience: { update: vi.fn() },education: { update: vi.fn() },- licenseOrCertification: { update: vi.fn() },+ licenseOrCertification: {+ update: vi.fn(),+ findFirst: vi.fn(),+ delete: vi.fn(),+ count: vi.fn(),+ },skill: { createMany: vi.fn(), deleteMany: vi.fn() },$transaction: vi.fn(),};@@ -472,6 +478,59 @@ describe("Resume section actions", () => {});});+ describe("deleteCertification", () => {+ beforeEach(() => {+ (prisma.$transaction as any).mockImplementation((fn: any) =>+ fn(prisma),+ );+ (prisma.licenseOrCertification.findFirst as any).mockResolvedValue({+ id: "cert-1",+ resumeSectionId: "section-1",+ ResumeSection: { resumeId: "resume-1" },+ });+ });+ // clearAllMocks keeps implementations; the skills specs expect the bare fn+ afterEach(() => (prisma.$transaction as any).mockReset());++ it("scopes the lookup through section -> resume -> profile", async () => {+ (prisma.licenseOrCertification.findFirst as any).mockResolvedValue(null);++ const result = await deleteCertification("someone-elses-cert");++ expect(result.success).toBe(false);+ expect(+ (prisma.licenseOrCertification.findFirst as any).mock.calls[0][0].where,+ ).toEqual({+ id: "someone-elses-cert",+ ResumeSection: { Resume: { profile: { userId: "user-1" } } },+ });+ expect(prisma.licenseOrCertification.delete).not.toHaveBeenCalled();+ });++ it("keeps the section while other certifications remain", async () => {+ (prisma.licenseOrCertification.count as any).mockResolvedValue(2);++ const result = await deleteCertification("cert-1");++ expect(result.success).toBe(true);+ expect(prisma.licenseOrCertification.delete).toHaveBeenCalledWith({+ where: { id: "cert-1" },+ });+ expect(prisma.resumeSection.delete).not.toHaveBeenCalled();+ });++ it("removes the section with its last certification", async () => {+ (prisma.licenseOrCertification.count as any).mockResolvedValue(0);++ const result = await deleteCertification("cert-1");++ expect(result.success).toBe(true);+ expect(prisma.resumeSection.delete).toHaveBeenCalledWith({+ where: { id: "section-1" },+ });+ });+ });+describe("addSkillsSection", () => {const form = {resumeId: "resume-1",diff --git a/src/actions/profile.actions.ts b/src/actions/profile.actions.tsindex 62435e0..32ccfed 100644--- a/src/actions/profile.actions.ts+++ b/src/actions/profile.actions.ts@@ -32,7 +32,11 @@ export { addExperience, updateExperience } from "./profile/experience";export { addEducation, updateEducation } from "./profile/education";-export { addCertification, updateCertification } from "./profile/certification";+export {+ addCertification,+ updateCertification,+ deleteCertification,+} from "./profile/certification";export {addSkillsSection,diff --git a/src/actions/profile/certification.ts b/src/actions/profile/certification.tsindex e7c2203..490cf7c 100644--- a/src/actions/profile/certification.ts+++ b/src/actions/profile/certification.ts@@ -76,3 +76,42 @@ export const updateCertification = async (return handleError(error, msg);}};++export const deleteCertification = async (+ certificationId: string,+): Promise<any | undefined> => {+ try {+ const user = await requireUser();++ const cert = await prisma.licenseOrCertification.findFirst({+ where: {+ id: certificationId,+ ResumeSection: { Resume: { profile: { userId: user.id } } },+ },+ select: {+ id: true,+ resumeSectionId: true,+ ResumeSection: { select: { resumeId: true } },+ },+ });+ if (!cert) throw new Error("Certification not found or access denied");++ await prisma.$transaction(async (tx) => {+ await tx.licenseOrCertification.delete({ where: { id: cert.id } });+ // Drop the section with its last entry so no empty heading lingers+ const remaining = await tx.licenseOrCertification.count({+ where: { resumeSectionId: cert.resumeSectionId },+ });+ if (remaining === 0) {+ await tx.resumeSection.delete({+ where: { id: cert.resumeSectionId! },+ });+ }+ });++ revalidatePath(`/dashboard/profile/resume/${cert.ResumeSection?.resumeId}`);+ return { success: true };+ } catch (error) {+ return handleError(error, "Failed to delete certification.");+ }+};diff --git a/src/components/profile/CertificationCard.tsx b/src/components/profile/CertificationCard.tsxindex af3e701..e5c1597 100644--- a/src/components/profile/CertificationCard.tsx+++ b/src/components/profile/CertificationCard.tsx@@ -8,17 +8,30 @@ import {CardTitle,} from "../ui/card";import { Button } from "../ui/button";-import { Pencil, ExternalLink } from "lucide-react";+import { Pencil, ExternalLink, Trash2 } from "lucide-react";import { format } from "date-fns";+import {+ AlertDialog,+ AlertDialogAction,+ AlertDialogCancel,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+ AlertDialogTrigger,+} from "../ui/alert-dialog";interface CertificationCardProps {certificationSection: ResumeSection | undefined;openDialogForEdit: (id: string) => void;+ onDelete: (id: string) => void;}function CertificationCard({certificationSection,openDialogForEdit,+ onDelete,}: CertificationCardProps) {const { sectionTitle, licenseOrCertifications } = certificationSection!;return (@@ -36,16 +49,48 @@ function CertificationCard({<Card key={id}><CardHeader className="p-2 pb-0 flex-row justify-between relative"><CardTitle className="text-xl pl-4">{title}</CardTitle>- <Button- title="Edit"- variant="ghost"- size="icon"- className="h-8 w-8 absolute top-2 right-2"- onClick={() => openDialogForEdit(id!)}- >- <Pencil className="h-3.5 w-3.5" />- <span className="sr-only">Edit</span>- </Button>+ <div className="flex gap-1 absolute top-2 right-2">+ <Button+ title="Edit"+ variant="ghost"+ size="icon"+ className="h-8 w-8"+ onClick={() => openDialogForEdit(id!)}+ >+ <Pencil className="h-3.5 w-3.5" />+ <span className="sr-only">Edit</span>+ </Button>+ <AlertDialog>+ <AlertDialogTrigger asChild>+ <Button+ title="Delete"+ variant="ghost"+ size="icon"+ className="h-8 w-8 text-destructive hover:text-destructive"+ >+ <Trash2 className="h-3.5 w-3.5" />+ <span className="sr-only">Delete</span>+ </Button>+ </AlertDialogTrigger>+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>Delete certification?</AlertDialogTitle>+ <AlertDialogDescription>+ This will remove "{title}" from this resume.+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogCancel>Cancel</AlertDialogCancel>+ <AlertDialogAction+ className="bg-destructive-bg text-destructive-foreground hover:bg-destructive-bg/90"+ onClick={() => onDelete(id!)}+ >+ Delete+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>+ </div></CardHeader><CardContent><h3>{organization}</h3>diff --git a/src/components/profile/ResumeContainer.tsx b/src/components/profile/ResumeContainer.tsxindex dc9fa7f..f2ad638 100644--- a/src/components/profile/ResumeContainer.tsx+++ b/src/components/profile/ResumeContainer.tsx@@ -5,7 +5,7 @@ import { AddResumeSectionRef } from "./AddResumeSection";import ContactInfoCard from "./ContactInfoCard";import { useMemo, useRef, useState } from "react";import { useRouter } from "next/navigation";-import { toastSuccess, toastError } from "@/lib/toast";+import { toastSuccess, toastError, toastActionResult } from "@/lib/toast";import SummarySectionCard from "./SummarySectionCard";import ExperienceCard from "./ExperienceCard";import EducationCard from "./EducationCard";@@ -16,7 +16,11 @@ import { useAgentChat } from "@/components/agent/AgentChatProvider";import type { ResumeReviewData } from "@/models/ai.schemas";import { ExportPdfDialog } from "./ExportPdfDialog";import { Sparkles } from "lucide-react";-import { deleteSkillsSection, setDefaultResume } from "@/actions/profile.actions";+import {+ deleteCertification,+ deleteSkillsSection,+ setDefaultResume,+} from "@/actions/profile.actions";import { DeleteAlertDialog } from "../DeleteAlertDialog";import { ResumeHeader } from "./resume-container/ResumeHeader";import { ImportReviewBanner } from "./resume-container/ImportReviewBanner";@@ -150,11 +154,10 @@ function ResumeContainer({const handleDeleteSkillsSection = async () => {if (!skillsSection?.id) return;const result = await deleteSkillsSection(skillsSection.id);- if (!result.success) {- toastError(result.message);- } else {- router.refresh();- }+ toastActionResult(result, {+ success: "Skills section has been deleted successfully",+ onSuccess: () => router.refresh(),+ });};const openCertificationDialogForEdit = (certificationId: string) => {@@ -167,6 +170,13 @@ function ResumeContainer({};resumeSectionRef.current?.openCertificationDialog(section);};+ const handleDeleteCertification = async (certificationId: string) => {+ const result = await deleteCertification(certificationId);+ toastActionResult(result, {+ success: "Certification has been deleted successfully",+ onSuccess: () => router.refresh(),+ });+ };const isEmptyResume =!ContactInfo && (!ResumeSections || ResumeSections.length === 0);@@ -280,6 +290,7 @@ function ResumeContainer({<CertificationCardcertificationSection={certificationSection}openDialogForEdit={openCertificationDialogForEdit}+ onDelete={handleDeleteCertification}/>)}