"use client"; import { FC, ReactNode, useState } from "react"; import { Bill, BillingLocation } from '@evidencija-rezija/shared-code'; import { useFormState } from "react-dom"; import { Main } from "./Main"; import { deleteBillById } from "../lib/actions/billActions"; import Link from "next/link"; import { useTranslations } from "next-intl"; export interface BillDeleteFormProps { bill: Bill, location: BillingLocation } export const BillDeleteForm:FC = ({ bill, location }) => { const { year, month } = location.yearMonth; const handleAction = deleteBillById.bind(null, location._id, bill._id, year, month); const [ state, dispatch ] = useFormState(handleAction, null); const t = useTranslations("bill-delete-form"); const [deleteInSubsequentMonths, setDeleteInSubsequentMonths] = useState(false); return(

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

{deleteInSubsequentMonths && (
⚠️

{t("warning-title")}

{t("warning-message")}
)}
{t("cancel-button")}
) }