diff --git a/src/client/components/CandidateForm.tsx b/src/client/components/CandidateForm.tsx index 0365979..71c6677 100644 --- a/src/client/components/CandidateForm.tsx +++ b/src/client/components/CandidateForm.tsx @@ -1,7 +1,6 @@ import { useEffect, useState } from "react"; import { useCreateCandidate, useUpdateCandidate } from "../hooks/useCandidates"; import { useThread } from "../hooks/useThreads"; -import { useUIStore } from "../stores/uiStore"; import { CategoryPicker } from "./CategoryPicker"; import { ImageUpload } from "./ImageUpload"; @@ -9,6 +8,7 @@ interface CandidateFormProps { mode: "add" | "edit"; threadId: number; candidateId?: number | null; + onClose?: () => void; } interface FormData { @@ -39,11 +39,11 @@ export function CandidateForm({ mode, threadId, candidateId, + onClose, }: CandidateFormProps) { const { data: thread } = useThread(threadId); const createCandidate = useCreateCandidate(threadId); const updateCandidate = useUpdateCandidate(threadId); - const closeCandidatePanel = useUIStore((s) => s.closeCandidatePanel); const [form, setForm] = useState(INITIAL_FORM); const [errors, setErrors] = useState>({}); @@ -124,13 +124,13 @@ export function CandidateForm({ createCandidate.mutate(payload, { onSuccess: () => { setForm(INITIAL_FORM); - closeCandidatePanel(); + onClose?.(); }, }); } else if (candidateId != null) { updateCandidate.mutate( { candidateId, ...payload }, - { onSuccess: () => closeCandidatePanel() }, + { onSuccess: () => onClose?.() }, ); } } diff --git a/src/client/components/CollectionView.tsx b/src/client/components/CollectionView.tsx index eb1290c..126676c 100644 --- a/src/client/components/CollectionView.tsx +++ b/src/client/components/CollectionView.tsx @@ -14,7 +14,7 @@ export function CollectionView() { const { data: totals } = useTotals(); const { data: categories } = useCategories(); const { weight, price } = useFormatters(); - const openAddPanel = useUIStore((s) => s.openAddPanel); + const openCatalogSearch = useUIStore((s) => s.openCatalogSearch); const [searchText, setSearchText] = useState(""); const [categoryFilter, setCategoryFilter] = useState(null); @@ -66,7 +66,7 @@ export function CollectionView() {