"use client" import { useLocale, useTranslations } from "next-intl"; import type { Consent } from "@/types"; import { Item, ItemActions, ItemContent, ItemDescription, ItemTitle } from "@/components/ui/item" import { Button } from "@/components/ui/button"; import { localeMap } from "@/types"; import { enUS } from "date-fns/locale"; import { format } from "date-fns"; import { revokeConsent } from "@/actions/consents"; import { useState } from "react"; interface Props { consents: Consent[] | []; setConsents: (consents: Consent[]) => void; } export default function Applications({ consents, setConsents }: Props) { const t = useTranslations("MePage.items.applications"); const [list, setList] = useState(consents); const locale = useLocale(); const dateLocale = localeMap[locale as keyof typeof localeMap] ?? enUS; const handleRevoke = async (clientId: string) => { const result = await revokeConsent(clientId); if (result.success) { const updated = list.filter(c => c.client_id !== clientId); setList(updated); setConsents(updated); } }; return (

{t("title")}

{list.map((consent) => ( {consent.client_name} {t("authorized")} {format(consent.authorized_at, "PPP", { locale: dateLocale })} ))}
); }