From 4bdc771cd45b668eece8fc15f65320643a4c8a90 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Mon, 23 Mar 2026 05:39:37 +0000 Subject: [PATCH] feat: synchronize selected certificate IDs with available certificates on update --- frontend/src/components/CertificateList.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/CertificateList.tsx b/frontend/src/components/CertificateList.tsx index cd35e821..8866fa2e 100644 --- a/frontend/src/components/CertificateList.tsx +++ b/frontend/src/components/CertificateList.tsx @@ -1,6 +1,6 @@ import { useMutation, useQueryClient } from '@tanstack/react-query' import { Trash2, ChevronUp, ChevronDown } from 'lucide-react' -import { useState, useMemo } from 'react' +import { useState, useMemo, useEffect } from 'react' import { useTranslation } from 'react-i18next' import BulkDeleteCertificateDialog from './dialogs/BulkDeleteCertificateDialog' @@ -46,6 +46,15 @@ export default function CertificateList() { const [selectedIds, setSelectedIds] = useState>(new Set()) const [showBulkDeleteDialog, setShowBulkDeleteDialog] = useState(false) + useEffect(() => { + setSelectedIds(prev => { + const validIds = new Set(certificates.map(c => c.id).filter((id): id is number => id != null)) + const reconciled = new Set([...prev].filter(id => validIds.has(id))) + if (reconciled.size === prev.size) return prev + return reconciled + }) + }, [certificates]) + const deleteMutation = useMutation({ mutationFn: async (id: number) => { await deleteCertificate(id)