diff --git a/messages/en-US.json b/messages/en-US.json index e4d55e4b9..89c6247db 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -3139,5 +3139,6 @@ "idpUnassociateMenu": "Unassociate", "idpDeleteAllOrgsMenu": "Delete", "publicIpEndpoint": "Endpoint", - "lastTriggeredAt": "Last Trigger" + "lastTriggeredAt": "Last Trigger", + "reject": "Reject" } diff --git a/src/components/PendingSitesTable.tsx b/src/components/PendingSitesTable.tsx index a6625037d..d32aee95e 100644 --- a/src/components/PendingSitesTable.tsx +++ b/src/components/PendingSitesTable.tsx @@ -1,5 +1,6 @@ "use client"; +import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog"; import { Badge } from "@app/components/ui/badge"; import { Button } from "@app/components/ui/button"; import { @@ -24,7 +25,8 @@ import { ArrowUpRight, Check, ChevronsUpDownIcon, - MoreHorizontal + MoreHorizontal, + X } from "lucide-react"; import { useTranslations } from "next-intl"; import Link from "next/link"; @@ -62,6 +64,9 @@ export default function PendingSitesTable({ const [isRefreshing, startTransition] = useTransition(); const [approvingIds, setApprovingIds] = useState>(new Set()); + const [rejectingIds, setRejectingIds] = useState>(new Set()); + const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); + const [selectedSite, setSelectedSite] = useState(null); const api = createApiClient(useEnvContext()); const t = useTranslations(); @@ -128,6 +133,33 @@ export default function PendingSitesTable({ } } + async function rejectSite(siteId: number) { + setRejectingIds((prev) => new Set(prev).add(siteId)); + try { + await api.delete(`/site/${siteId}`); + toast({ + title: t("success"), + description: t("siteDeleted"), + variant: "default" + }); + setIsDeleteModalOpen(false); + setSelectedSite(null); + router.refresh(); + } catch (e) { + toast({ + variant: "destructive", + title: t("siteErrorDelete"), + description: formatAxiosError(e, t("siteErrorDelete")) + }); + } finally { + setRejectingIds((prev) => { + const next = new Set(prev); + next.delete(siteId); + return next; + }); + } + } + const columns: ExtendedColumnDef[] = [ { accessorKey: "name", @@ -387,6 +419,7 @@ export default function PendingSitesTable({ cell: ({ row }) => { const siteRow = row.original; const isApproving = approvingIds.has(siteRow.id); + const isRejecting = rejectingIds.has(siteRow.id); return (
@@ -409,7 +442,18 @@ export default function PendingSitesTable({ +