From 61c73b683070ccbec602127863462c2714536e6a Mon Sep 17 00:00:00 2001 From: DaKheera47 Date: Tue, 6 Jan 2026 23:29:58 +0000 Subject: [PATCH] allow editing jd --- .../src/client/components/JobList.tsx | 97 +++++++++++++++++-- orchestrator/src/components/ui/textarea.tsx | 22 +++++ orchestrator/src/server/api/routes.ts | 1 + orchestrator/src/shared/types.ts | 1 + 4 files changed, 112 insertions(+), 9 deletions(-) create mode 100644 orchestrator/src/components/ui/textarea.tsx diff --git a/orchestrator/src/client/components/JobList.tsx b/orchestrator/src/client/components/JobList.tsx index 50a76e5..babfe19 100644 --- a/orchestrator/src/client/components/JobList.tsx +++ b/orchestrator/src/client/components/JobList.tsx @@ -3,13 +3,14 @@ */ import React, { useEffect, useMemo, useState } from "react"; -import { ArrowUpDown, Filter, LayoutGrid, Search, Sparkles, Table2, X } from "lucide-react"; +import { ArrowUpDown, Edit2, Filter, LayoutGrid, Save, Search, Sparkles, Table2, Undo, X } from "lucide-react"; import ReactMarkdown from "react-markdown"; import remarkGfm from "remark-gfm"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { Textarea } from "@/components/ui/textarea"; import { DropdownMenu, DropdownMenuContent, @@ -29,6 +30,7 @@ import { AccordionTrigger, } from "@/components/ui/accordion"; import { cn } from "@/lib/utils"; +import * as api from "../api"; import type { Job, JobStatus, JobSource } from "../../shared/types"; import { JobCard } from "./JobCard"; import { JobTable, type JobSort } from "./JobTable"; @@ -205,6 +207,9 @@ export const JobList: React.FC = ({ const [batchAction, setBatchAction] = useState(null); const [highlightedJobId, setHighlightedJobId] = useState(null); const [isHighlightVisible, setIsHighlightVisible] = useState(false); + const [isEditingDescription, setIsEditingDescription] = useState(false); + const [editedDescription, setEditedDescription] = useState(""); + const [isSavingDescription, setIsSavingDescription] = useState(false); const [viewMode, setViewMode] = useState(() => { try { const raw = localStorage.getItem(JOB_LIST_VIEW_STORAGE_KEY); @@ -314,6 +319,31 @@ export const JobList: React.FC = ({ return jd; }, [highlightedJob]); + useEffect(() => { + if (!highlightedJobId) { + setIsEditingDescription(false); + setEditedDescription(""); + } else if (highlightedJob && !isEditingDescription) { + setEditedDescription(highlightedJob.jobDescription || ""); + } + }, [highlightedJobId, highlightedJob, isEditingDescription]); + + const handleSaveDescription = async () => { + if (!highlightedJobId) return; + try { + setIsSavingDescription(true); + await api.updateJob(highlightedJobId, { jobDescription: editedDescription }); + toast.success("Job description updated"); + setIsEditingDescription(false); + await onUpdate(); + } catch (error) { + const message = error instanceof Error ? error.message : "Failed to update description"; + toast.error(message); + } finally { + setIsSavingDescription(false); + } + }; + useEffect(() => { setSelectedJobIds((current) => { const visibleIds = new Set(activeTabJobs.map((job) => job.id)); @@ -432,16 +462,65 @@ export const JobList: React.FC = ({ - - Job description -
Press Esc or click outside to exit highlight.
+ +
+ Job description + {!isEditingDescription && ( +
Press Esc or click outside to exit highlight.
+ )} +
+ {!isEditingDescription ? ( + + ) : ( +
+ + +
+ )}
-
- - {highlightedJobDescription} - -
+ {isEditingDescription ? ( +