"use client"; import { FC, ReactNode, useState } from "react"; import { BillingLocation } from "../lib/db-types"; import { deleteLocationById } from "../lib/actions/locationActions"; import { useFormState } from "react-dom"; import Link from "next/link"; import { useTranslations } from "next-intl"; export interface LocationDeleteFormProps { /** location which should be deleted */ location: BillingLocation } export const LocationDeleteForm:FC = ({ location }) => { const handleAction = deleteLocationById.bind(null, location._id, location.yearMonth); const [ , dispatch ] = useFormState(handleAction, null); const t = useTranslations("location-delete-form"); const [deleteInSubsequentMonths, setDeleteInSubsequentMonths] = useState(false); return(

{ t.rich("text", { name:location.name, strong: (chunks:ReactNode) => {chunks}, }) }

{deleteInSubsequentMonths && (
⚠️

{t("warning-title")}

{t("warning-message")}
)}
{t("cancel-button")}
); } export const LocationDeleteFormSkeleton:FC = () =>