2026-01-16 15:47:38 +01:00
|
|
|
import {
|
|
|
|
|
ExternalLink,
|
|
|
|
|
Eye,
|
|
|
|
|
FileBadge,
|
|
|
|
|
FileText,
|
|
|
|
|
FolderKanban,
|
2026-03-04 16:39:27 +01:00
|
|
|
Mail,
|
2026-01-16 15:47:38 +01:00
|
|
|
PackageCheck,
|
|
|
|
|
Pointer,
|
|
|
|
|
Printer,
|
|
|
|
|
Trash2,
|
|
|
|
|
} from "lucide-react";
|
2025-08-28 18:27:07 +02:00
|
|
|
import Link from "next/link";
|
2026-01-16 15:47:38 +01:00
|
|
|
import { useRouter } from "next/router";
|
2025-08-28 18:27:07 +02:00
|
|
|
import toast from "react-hot-toast";
|
2026-01-16 15:47:38 +01:00
|
|
|
import { Button, type ButtonConfigs } from "~/components/ui/button";
|
2025-08-28 18:27:07 +02:00
|
|
|
import {
|
2026-01-16 15:47:38 +01:00
|
|
|
Tooltip,
|
|
|
|
|
TooltipContent,
|
|
|
|
|
TooltipProvider,
|
|
|
|
|
TooltipTrigger,
|
|
|
|
|
} from "~/components/ui/tooltip";
|
|
|
|
|
import { cn } from "~/lib/utils";
|
2026-02-25 15:30:53 +01:00
|
|
|
import { useTranslation } from "~/providers/I18nProvider";
|
2025-08-04 17:45:44 +02:00
|
|
|
import { useServizio, useServizioAnnuncio } from "~/providers/ServizioProvider";
|
2026-01-16 15:47:38 +01:00
|
|
|
import type { AnnunciId } from "~/schemas/public/Annunci";
|
2025-08-28 18:27:07 +02:00
|
|
|
import { api } from "~/utils/api";
|
2026-01-16 15:47:38 +01:00
|
|
|
import { Confirm } from "../confirm";
|
2025-11-06 17:03:42 +01:00
|
|
|
import { AdminLavoraConferma } from "./admin_conferma";
|
|
|
|
|
import { AdminContratto } from "./admin_contratto";
|
2026-01-16 15:47:38 +01:00
|
|
|
import { ConfermaAnnuncioModal, ConfermaInLavorazioneModal } from "./conferma";
|
|
|
|
|
import { ContattiProprietarioModal } from "./modale_contatti";
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2026-01-16 15:47:38 +01:00
|
|
|
export const AdminActions = () => {
|
2025-08-28 18:27:07 +02:00
|
|
|
const { servizioId, userId, isAdmin } = useServizio();
|
|
|
|
|
const { data, annuncioId } = useServizioAnnuncio();
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2025-08-28 18:27:07 +02:00
|
|
|
const utils = api.useUtils();
|
|
|
|
|
const { mutate } = api.servizio.removeAnnuncioServizio.useMutation({
|
2025-08-29 16:18:32 +02:00
|
|
|
onError: (error) => {
|
|
|
|
|
console.error(error);
|
|
|
|
|
toast.error("Errore durante la rimozione dell'annuncio");
|
|
|
|
|
},
|
2025-08-28 18:27:07 +02:00
|
|
|
onSuccess: async () => {
|
|
|
|
|
await utils.servizio.getAllServizioAnnunci.invalidate({ userId });
|
2026-03-06 16:15:47 +01:00
|
|
|
await utils.servizio.getServizioData.invalidate({ servizioId });
|
2025-08-28 18:27:07 +02:00
|
|
|
await utils.servizio.getCompatibileAnnunci.invalidate({
|
|
|
|
|
servizioId,
|
|
|
|
|
});
|
|
|
|
|
toast.success("Annuncio rimosso");
|
|
|
|
|
},
|
|
|
|
|
});
|
2026-01-16 15:47:38 +01:00
|
|
|
if (!isAdmin) return null;
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2026-01-16 15:47:38 +01:00
|
|
|
return (
|
2026-03-04 16:39:27 +01:00
|
|
|
<div className="flex w-full max-w-fit flex-wrap justify-start gap-3">
|
|
|
|
|
{data.open_contatti_at != null && <AdminSendScheda />}
|
2026-01-16 15:47:38 +01:00
|
|
|
{data.user_confirmed_at != null && <AdminLavoraConferma />}
|
|
|
|
|
{data.accettato_conferma_at != null && (
|
|
|
|
|
<>
|
|
|
|
|
<AdminContratto />
|
|
|
|
|
{data.gestionale_id && (
|
|
|
|
|
<Link
|
|
|
|
|
aria-label="Open Gestionale"
|
|
|
|
|
href={`https://win-jk822fggr6b:480/id/${data.gestionale_id}`}
|
|
|
|
|
target="_blank"
|
2025-08-28 18:27:07 +02:00
|
|
|
>
|
2026-01-16 15:47:38 +01:00
|
|
|
<Button size="sm">
|
|
|
|
|
<FolderKanban /> Gestionale
|
|
|
|
|
</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
<Link href={`/annuncio/${data.codice}`} target="_blank">
|
|
|
|
|
<Button size="sm" type="button" variant="outline">
|
|
|
|
|
<Eye /> pubblica
|
|
|
|
|
</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
<Link
|
|
|
|
|
href={`/area-riservata/admin/edit-annuncio/${annuncioId}`}
|
|
|
|
|
target="_blank"
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
aria-label="Edit Annuncio"
|
|
|
|
|
className="w-fit"
|
|
|
|
|
size="sm"
|
|
|
|
|
variant="secondary"
|
|
|
|
|
>
|
|
|
|
|
<ExternalLink />
|
|
|
|
|
<span>Modifica</span>
|
|
|
|
|
</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
|
|
<Link
|
|
|
|
|
href={`/area-riservata/admin/scheda-annuncio-stampa/${data.id}`}
|
|
|
|
|
target="_blank"
|
|
|
|
|
>
|
|
|
|
|
<Button size="sm" type="button" variant="outline">
|
|
|
|
|
<Printer /> Scheda
|
|
|
|
|
</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
|
|
<Confirm
|
|
|
|
|
description="Sei sicuro di voler eliminare l'annuncio?"
|
|
|
|
|
onConfirm={() => {
|
|
|
|
|
mutate({
|
|
|
|
|
annuncioId,
|
|
|
|
|
servizioId,
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
title="Elimina annuncio"
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
aria-label="Delete Annuncio"
|
|
|
|
|
className="w-fit"
|
|
|
|
|
size="sm"
|
|
|
|
|
variant="destructive"
|
|
|
|
|
>
|
|
|
|
|
<Trash2 />
|
|
|
|
|
<span>Elimina</span>
|
|
|
|
|
</Button>
|
|
|
|
|
</Confirm>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-04 16:39:27 +01:00
|
|
|
const AdminSendScheda = () => {
|
|
|
|
|
const { userId } = useServizio();
|
|
|
|
|
const { annuncioId } = useServizioAnnuncio();
|
|
|
|
|
|
|
|
|
|
const { mutate } = api.comunicazioni.sendSchedaAnnuncioServizio.useMutation({
|
|
|
|
|
onMutate: () => {
|
|
|
|
|
toast.loading("Invio email in corso...", {
|
|
|
|
|
id: "send-scheda-annuncio-email",
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onSuccess: () => {
|
|
|
|
|
toast.success("Email inviata con successo!", {
|
|
|
|
|
id: "send-scheda-annuncio-email",
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onError: (error) => {
|
|
|
|
|
toast.error(`Errore durante l'invio dell'email: ${error.message}`, {
|
|
|
|
|
id: "send-scheda-annuncio-email",
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Button
|
|
|
|
|
aria-label="Invia scheda annuncio via email"
|
|
|
|
|
className="w-fit"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
mutate({
|
|
|
|
|
annuncioId,
|
|
|
|
|
userId,
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
variant="outline"
|
|
|
|
|
>
|
|
|
|
|
<Mail />
|
|
|
|
|
<span>Re-Invia email contatti</span>
|
|
|
|
|
</Button>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-16 15:47:38 +01:00
|
|
|
export const UserActions = () => {
|
|
|
|
|
const { servizioId } = useServizio();
|
|
|
|
|
const { data, annuncioId } = useServizioAnnuncio();
|
2026-02-25 15:30:53 +01:00
|
|
|
const { locale } = useTranslation();
|
2026-01-16 15:47:38 +01:00
|
|
|
const ContattiSbloccati = data.open_contatti_at !== null;
|
|
|
|
|
const ConfermaUtente = data.user_confirmed_at !== null;
|
|
|
|
|
const ConfermaLavorata = data.doc_conferma_added && data.hasConfermaAdmin;
|
|
|
|
|
const AccettatoConferma = data.accettato_conferma_at !== null;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<div className="flex w-full flex-col flex-wrap gap-2 sm:flex-row">
|
|
|
|
|
<ContattiProprietarioModal />
|
2026-01-16 17:11:53 +01:00
|
|
|
{ConfermaUtente
|
|
|
|
|
? !data.hasConfermaAdmin && <ConfermaInLavorazioneModal />
|
|
|
|
|
: ContattiSbloccati && <ConfermaAnnuncioModal />}
|
2026-01-16 15:47:38 +01:00
|
|
|
|
2026-01-16 17:11:53 +01:00
|
|
|
{AccettatoConferma ? (
|
2026-01-16 15:47:38 +01:00
|
|
|
<Link
|
2026-02-25 15:30:53 +01:00
|
|
|
aria-label={
|
|
|
|
|
locale === "it" ? "Rivedi la conferma" : "Review the confirmation"
|
|
|
|
|
}
|
2026-01-16 15:47:38 +01:00
|
|
|
href={`/servizio/riapri-conferma/${servizioId}/${annuncioId}`}
|
|
|
|
|
>
|
|
|
|
|
<Button className="w-full sm:w-fit" variant="success">
|
|
|
|
|
<Pointer />
|
2026-02-25 15:30:53 +01:00
|
|
|
{locale === "it"
|
|
|
|
|
? "Rivedi la conferma"
|
|
|
|
|
: "Review the confirmation"}
|
2026-01-16 15:47:38 +01:00
|
|
|
</Button>
|
|
|
|
|
</Link>
|
2026-01-16 17:11:53 +01:00
|
|
|
) : (
|
|
|
|
|
ConfermaLavorata &&
|
2026-01-16 15:47:38 +01:00
|
|
|
(data.doc_conferma_ref ? (
|
|
|
|
|
<Link
|
2026-02-25 15:30:53 +01:00
|
|
|
aria-label={locale === "it" ? "Confermato" : "Confirmed"}
|
2026-01-16 15:47:38 +01:00
|
|
|
href={`/servizio/conferma-immobile/${servizioId}/${annuncioId}`}
|
|
|
|
|
>
|
|
|
|
|
<Button className="w-full sm:w-fit" variant="success">
|
|
|
|
|
<Pointer />
|
2026-02-25 15:30:53 +01:00
|
|
|
{locale === "it"
|
|
|
|
|
? "Confermato - Procedi ora"
|
|
|
|
|
: "Confirmed - Proceed now"}
|
2026-01-16 15:47:38 +01:00
|
|
|
</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
) : (
|
|
|
|
|
<TooltipProvider delayDuration={0}>
|
|
|
|
|
<Tooltip>
|
|
|
|
|
<TooltipTrigger asChild>
|
|
|
|
|
<Button
|
|
|
|
|
className="w-full cursor-not-allowed opacity-50 sm:w-fit"
|
|
|
|
|
variant="success"
|
|
|
|
|
>
|
|
|
|
|
<Pointer />
|
2026-02-25 15:30:53 +01:00
|
|
|
{locale === "it"
|
|
|
|
|
? "Confermato - Procedi ora"
|
|
|
|
|
: "Confirmed - Proceed now"}
|
2026-01-16 15:47:38 +01:00
|
|
|
</Button>
|
|
|
|
|
</TooltipTrigger>
|
|
|
|
|
<TooltipContent>
|
|
|
|
|
<p>
|
2026-02-25 15:30:53 +01:00
|
|
|
{locale === "it"
|
|
|
|
|
? "Il documento non è più disponibile"
|
|
|
|
|
: "The document is no longer available"}
|
|
|
|
|
</p>
|
|
|
|
|
<p>
|
|
|
|
|
{locale === "it"
|
|
|
|
|
? "Se hai bisogno di una copia, contattaci via email o chat."
|
|
|
|
|
: "If you need a copy, contact us via email or chat."}
|
2026-01-16 15:47:38 +01:00
|
|
|
</p>
|
|
|
|
|
</TooltipContent>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</TooltipProvider>
|
2026-01-16 17:11:53 +01:00
|
|
|
))
|
|
|
|
|
)}
|
2026-01-16 15:47:38 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{data.accettato_conferma_at != null && <PostConfermaSection />}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const PostConfermaSection = () => {
|
|
|
|
|
const { servizio, servizioId } = useServizio();
|
|
|
|
|
const { data, annuncioId } = useServizioAnnuncio();
|
2026-02-25 15:30:53 +01:00
|
|
|
const { locale } = useTranslation();
|
2026-01-16 15:47:38 +01:00
|
|
|
const saldoPaid = servizio.isOkSaldo;
|
|
|
|
|
const consulenzaPaid = servizio.isOkConsulenza;
|
|
|
|
|
|
2026-02-25 15:30:53 +01:00
|
|
|
const doc_non_disponibile =
|
|
|
|
|
locale === "it"
|
|
|
|
|
? "Il documento non è più disponibile"
|
|
|
|
|
: "The document is no longer available";
|
|
|
|
|
const contatta_supporto =
|
|
|
|
|
locale === "it"
|
|
|
|
|
? "Se hai bisogno di una copia, contattaci via email o chat."
|
|
|
|
|
: "If you need a copy, contact us via email or chat.";
|
|
|
|
|
|
2026-01-16 15:47:38 +01:00
|
|
|
if (!saldoPaid) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex flex-col gap-1">
|
|
|
|
|
<h3 className="font-semibold">
|
2026-02-25 15:30:53 +01:00
|
|
|
{locale === "it"
|
|
|
|
|
? "Questo annuncio è stato confermato, procedi al saldo:"
|
|
|
|
|
: "This listing has been confirmed, proceed to payment:"}
|
2026-01-16 15:47:38 +01:00
|
|
|
</h3>
|
|
|
|
|
<SaldoButton annuncioId={annuncioId} />
|
2025-08-28 18:27:07 +02:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-01-16 15:47:38 +01:00
|
|
|
if (!data.doc_contratto_added) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex flex-col gap-1">
|
|
|
|
|
<h3 className="font-semibold text-green-500">
|
2026-02-25 15:30:53 +01:00
|
|
|
{locale === "it"
|
|
|
|
|
? "Ci siamo quasi! Stiamo preparando il contratto per te."
|
|
|
|
|
: "Almost there! We are preparing the contract for you."}
|
2026-01-16 15:47:38 +01:00
|
|
|
</h3>
|
|
|
|
|
<h3 className="font-semibold">
|
2026-02-25 15:30:53 +01:00
|
|
|
{locale === "it"
|
|
|
|
|
? "Una volta pronto, riceverai una notifica via email."
|
|
|
|
|
: "Once ready, you will receive a notification via email."}
|
2026-01-16 15:47:38 +01:00
|
|
|
</h3>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex flex-col gap-2">
|
|
|
|
|
<h3 className="font-semibold">
|
|
|
|
|
{consulenzaPaid
|
2026-02-25 15:30:53 +01:00
|
|
|
? locale === "it"
|
|
|
|
|
? "Il contratto è pronto, puoi visualizzarlo:"
|
|
|
|
|
: "The contract is ready, you can view it:"
|
|
|
|
|
: locale === "it"
|
|
|
|
|
? "Il contratto è pronto, puoi visualizzarlo e procedere al saldo:"
|
|
|
|
|
: "The contract is ready, you can view it and proceed to payment:"}
|
2026-01-16 15:47:38 +01:00
|
|
|
</h3>
|
|
|
|
|
<div className="flex flex-wrap gap-2">
|
|
|
|
|
{data.doc_contratto_ref ? (
|
|
|
|
|
<Link
|
2026-02-25 15:30:53 +01:00
|
|
|
aria-label={
|
|
|
|
|
locale === "it" ? "Visualizza contratto" : "View contract"
|
|
|
|
|
}
|
2026-01-16 15:47:38 +01:00
|
|
|
href={`/servizio/contratto/${servizioId}/${annuncioId}`}
|
|
|
|
|
target="_blank"
|
|
|
|
|
>
|
|
|
|
|
<Button className="w-full sm:w-fit">
|
|
|
|
|
<FileText />
|
2026-02-25 15:30:53 +01:00
|
|
|
{locale === "it"
|
|
|
|
|
? "Visualizza il contratto"
|
|
|
|
|
: "View the contract"}
|
2026-01-16 15:47:38 +01:00
|
|
|
</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
) : (
|
|
|
|
|
<TooltipProvider delayDuration={0}>
|
|
|
|
|
<Tooltip>
|
|
|
|
|
<TooltipTrigger asChild>
|
|
|
|
|
<Button className="w-fit cursor-not-allowed opacity-50">
|
|
|
|
|
<FileText />
|
2026-02-25 15:30:53 +01:00
|
|
|
{locale === "it"
|
|
|
|
|
? "Visualizza il contratto"
|
|
|
|
|
: "View the contract"}
|
2026-01-16 15:47:38 +01:00
|
|
|
</Button>
|
|
|
|
|
</TooltipTrigger>
|
|
|
|
|
<TooltipContent>
|
2026-02-25 15:30:53 +01:00
|
|
|
<p>{doc_non_disponibile}</p>
|
|
|
|
|
<p>{contatta_supporto}</p>
|
2026-01-16 15:47:38 +01:00
|
|
|
</TooltipContent>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</TooltipProvider>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{!consulenzaPaid && data.contratto_tipo && <SaldoConsulenzaButton />}
|
|
|
|
|
|
|
|
|
|
{data.doc_registrazione_added &&
|
|
|
|
|
(data.doc_registrazione_ref ? (
|
|
|
|
|
<Link
|
2026-02-25 15:30:53 +01:00
|
|
|
aria-label={
|
|
|
|
|
locale === "it" ? "Visualizza registrazione" : "View recording"
|
|
|
|
|
}
|
2026-01-16 15:47:38 +01:00
|
|
|
href={`/servizio/contratto-registrazione/${servizioId}/${annuncioId}`}
|
|
|
|
|
target="_blank"
|
|
|
|
|
>
|
|
|
|
|
<Button className="w-fit">
|
|
|
|
|
<FileBadge />
|
2026-02-25 15:30:53 +01:00
|
|
|
{locale === "it"
|
|
|
|
|
? "Visualizza la registrazione"
|
|
|
|
|
: "View the recording"}
|
2026-01-16 15:47:38 +01:00
|
|
|
</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
) : (
|
|
|
|
|
<TooltipProvider delayDuration={0}>
|
|
|
|
|
<Tooltip>
|
|
|
|
|
<TooltipTrigger asChild>
|
|
|
|
|
<Button className="w-fit cursor-not-allowed opacity-50">
|
|
|
|
|
<FileBadge />
|
2026-02-25 15:30:53 +01:00
|
|
|
{locale === "it"
|
|
|
|
|
? "Visualizza la registrazione"
|
|
|
|
|
: "View the recording"}
|
2026-01-16 15:47:38 +01:00
|
|
|
</Button>
|
|
|
|
|
</TooltipTrigger>
|
|
|
|
|
<TooltipContent>
|
2026-02-25 15:30:53 +01:00
|
|
|
<p>{doc_non_disponibile}</p>
|
|
|
|
|
<p>{contatta_supporto}</p>
|
2026-01-16 15:47:38 +01:00
|
|
|
</TooltipContent>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</TooltipProvider>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const SaldoButton = ({
|
|
|
|
|
annuncioId,
|
|
|
|
|
variant = "info",
|
|
|
|
|
className,
|
|
|
|
|
}: {
|
|
|
|
|
annuncioId: AnnunciId;
|
|
|
|
|
variant?: ButtonConfigs["variant"];
|
|
|
|
|
className?: string;
|
|
|
|
|
}) => {
|
2026-02-25 15:30:53 +01:00
|
|
|
const { locale } = useTranslation();
|
2026-01-16 15:47:38 +01:00
|
|
|
const { servizioId } = useServizio();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
|
|
const { mutate } = api.servizio.setupSaldoServizio.useMutation({
|
|
|
|
|
onMutate: () => {
|
2026-02-25 15:30:53 +01:00
|
|
|
toast.loading(locale === "it" ? "Caricamento ..." : "Loading ...", {
|
2026-01-16 15:47:38 +01:00
|
|
|
id: "preparazioneSaldo",
|
|
|
|
|
});
|
2026-02-25 15:30:53 +01:00
|
|
|
},
|
|
|
|
|
onSuccess: async (data) => {
|
|
|
|
|
toast.success(
|
|
|
|
|
locale === "it" ? "Pagamento saldo preparato" : "Payment prepared",
|
|
|
|
|
{
|
|
|
|
|
id: "preparazioneSaldo",
|
|
|
|
|
},
|
|
|
|
|
);
|
2026-01-16 15:47:38 +01:00
|
|
|
|
|
|
|
|
await router.push(`/servizio/pagamento/${data}`);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
return (
|
|
|
|
|
<Button
|
2026-02-25 15:30:53 +01:00
|
|
|
aria-label={locale === "it" ? "Procedi al saldo" : "Proceed to payment"}
|
2026-01-16 15:47:38 +01:00
|
|
|
className={cn("w-fit", className)}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
mutate({
|
|
|
|
|
annuncioId,
|
|
|
|
|
servizioId,
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
variant={variant}
|
|
|
|
|
>
|
|
|
|
|
<PackageCheck />
|
2026-02-25 15:30:53 +01:00
|
|
|
{locale === "it" ? "Procedi al saldo" : "Proceed to payment"}
|
2026-01-16 15:47:38 +01:00
|
|
|
</Button>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const SaldoConsulenzaButton = ({
|
|
|
|
|
variant = "info",
|
|
|
|
|
className,
|
|
|
|
|
}: {
|
|
|
|
|
variant?: ButtonConfigs["variant"];
|
|
|
|
|
className?: string;
|
|
|
|
|
}) => {
|
2026-02-25 15:30:53 +01:00
|
|
|
const { locale } = useTranslation();
|
2026-01-16 15:47:38 +01:00
|
|
|
const { annuncioId } = useServizioAnnuncio();
|
|
|
|
|
const { servizioId } = useServizio();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
|
|
const { mutate } = api.servizio.setupSaldoConsulenzaServizio.useMutation({
|
|
|
|
|
onMutate: () => {
|
2026-02-25 15:30:53 +01:00
|
|
|
toast.loading(locale === "it" ? "Caricamento ..." : "Loading ...", {
|
2026-01-16 15:47:38 +01:00
|
|
|
id: "preparazioneSaldo",
|
|
|
|
|
});
|
2026-02-25 15:30:53 +01:00
|
|
|
},
|
|
|
|
|
onSuccess: async (data) => {
|
|
|
|
|
toast.success(
|
|
|
|
|
locale === "it" ? "Pagamento saldo preparato" : "Payment prepared",
|
|
|
|
|
{
|
|
|
|
|
id: "preparazioneSaldo",
|
|
|
|
|
},
|
|
|
|
|
);
|
2026-01-16 15:47:38 +01:00
|
|
|
|
|
|
|
|
await router.push(`/servizio/pagamento/${data}`);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
return (
|
|
|
|
|
<Button
|
2026-02-25 15:30:53 +01:00
|
|
|
aria-label={
|
|
|
|
|
locale === "it"
|
|
|
|
|
? "Procedi al saldo consulenza"
|
|
|
|
|
: "Proceed to payment for the consultation"
|
|
|
|
|
}
|
2026-01-16 15:47:38 +01:00
|
|
|
className={cn("w-fit", className)}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
mutate({
|
|
|
|
|
annuncioId,
|
|
|
|
|
servizioId,
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
variant={variant}
|
|
|
|
|
>
|
|
|
|
|
<PackageCheck />
|
2026-02-25 15:30:53 +01:00
|
|
|
{locale === "it"
|
|
|
|
|
? "Procedi al saldo della consulenza"
|
|
|
|
|
: "Proceed to payment for the consultation"}
|
2026-01-16 15:47:38 +01:00
|
|
|
</Button>
|
|
|
|
|
);
|
2025-08-04 17:45:44 +02:00
|
|
|
};
|