"use client"; import { useState } from "react"; import { toast } from "sonner"; import { Loader2, ShieldCheck } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { AccountAvatar } from "@/components/profile/account-avatar"; import { unblockAccountLinkRequests } from "@/lib/actions/account-links"; import type { BlockedRequesterDTO } from "@/types/profile"; /** * Accounts this account blocked from sending link requests (via "Deny and * Block Account Link"). Lifting a block lets that account request again -- * the block is permanent for them otherwise, so it must be reversible * here. */ export function BlockedLinkRequests({ blocks }: { blocks: BlockedRequesterDTO[] }) { const [busyId, setBusyId] = useState(null); async function handleAllow(block: BlockedRequesterDTO) { if (busyId) return; setBusyId(block.blockId); try { const result = await unblockAccountLinkRequests(block.blockId); if (result?.error) { toast.error(result.error); return; } toast.success(`${block.email} can send link requests to you again.`); } catch { toast.error("Couldn't allow requests from that account. Try again."); } finally { setBusyId(null); } } return ( Blocked Account Link Requests These accounts can't send link requests to this one. {blocks.map((block) => { const busy = busyId === block.blockId; return (

{block.email}

{block.name ? `${block.name} ยท ` : ""} blocked {block.blockedAtLabel}

); })}
); }