diff --git a/apps/infoalloggi/TODO b/apps/infoalloggi/TODO index 445b3a5..73db714 100644 --- a/apps/infoalloggi/TODO +++ b/apps/infoalloggi/TODO @@ -1,6 +1,10 @@ TODOS: - Log email fallite e retry + + conferma presa visione deve rimandare a servizio giusto non /ricerrca + + AFTER MVP: - TODO migrazione app router https://nextjs.org/docs/pages/building-your-application/upgrading/app-router-migration#migrating-from-pages-to-app - Sezione "La mia locazione" con i dati della locazione attuale dell'utente diff --git a/apps/infoalloggi/src/components/servizio/servizio_actions.tsx b/apps/infoalloggi/src/components/servizio/servizio_actions.tsx index b3fc943..626280d 100644 --- a/apps/infoalloggi/src/components/servizio/servizio_actions.tsx +++ b/apps/infoalloggi/src/components/servizio/servizio_actions.tsx @@ -51,6 +51,8 @@ import { cn, formatCurrency } from "~/lib/utils"; import { useTranslation } from "~/providers/I18nProvider"; import { useServizio } from "~/providers/ServizioProvider"; import type { AnnunciId } from "~/schemas/public/Annunci"; +import type { Ordini } from "~/schemas/public/Ordini"; +import type { Prezziario } from "~/schemas/public/Prezziario"; import type { ServizioServizioId } from "~/schemas/public/Servizio"; import TipologiaPosizioneEnum from "~/schemas/public/TipologiaPosizioneEnum"; import type { UsersId } from "~/schemas/public/Users"; @@ -215,6 +217,25 @@ const ServizioPrezzo = () => { }; const ServizioOrders = () => { const { isAdmin, servizio } = useServizio(); + return ( + + + + ); +}; + +export const OrdersModal = ({ + children, + isAdmin, + ordini, +}: { + children: React.ReactNode; + isAdmin: boolean; + ordini: (Ordini & Pick)[]; +}) => { const [openOrders, setOpenOrders] = useState(false); const [openEdit, setOpenEdit] = useState(false); @@ -231,12 +252,7 @@ const ServizioOrders = () => { return ( <> - - - + {children} Ordini Servizio @@ -266,14 +282,14 @@ const ServizioOrders = () => { - {servizio.ordini.length === 0 && ( + {ordini.length === 0 && ( Nessun ordine disponibile )} - {servizio.ordini.map((ordine) => ( + {ordini.map((ordine) => ( {ordine.created_at.toLocaleDateString("it-IT")} diff --git a/apps/infoalloggi/src/components/tables/richieste-table.tsx b/apps/infoalloggi/src/components/tables/richieste-table.tsx index 79136a5..14dedcf 100644 --- a/apps/infoalloggi/src/components/tables/richieste-table.tsx +++ b/apps/infoalloggi/src/components/tables/richieste-table.tsx @@ -13,6 +13,7 @@ import { CircleCheckBig, ClockFading, ExternalLink, + Logs, SearchX, UserCog, } from "lucide-react"; @@ -21,6 +22,7 @@ import { useRef } from "react"; import toast from "react-hot-toast"; import { NotePopover } from "~/components/notePopover"; import { AnnuncioCardRichieste } from "~/components/servizio/annuncio_card"; +import { OrdersModal } from "~/components/servizio/servizio_actions"; import { WhatsAppIcon2 } from "~/components/svgs"; import { Badge } from "~/components/ui/badge"; import { Button } from "~/components/ui/button"; @@ -73,6 +75,7 @@ export const RichiesteTable = ({ data }: RichiesteTableProps) => { status: "Status", tipologia: "Tipo", annunci: "Annunci", + ordini: "Ordini", interruzione_expires_at: "Scad. interr.", actions: "Azioni", }; @@ -309,7 +312,7 @@ export const RichiesteTable = ({ data }: RichiesteTableProps) => { contents = ( <> - Attesa pagamento acconto + Attesa pag. acconto ); } @@ -408,7 +411,7 @@ export const RichiesteTable = ({ data }: RichiesteTableProps) => { contents = ( <> - Attesa accettazione conferma + Attesa accett. conferma ); return; @@ -484,6 +487,7 @@ export const RichiesteTable = ({ data }: RichiesteTableProps) => { ); }, + enableSorting: false, header: ({ column }) => ( { size="sm" variant="outline" > - {annunci.length} Annunci + {annunci.length} @@ -529,6 +533,23 @@ export const RichiesteTable = ({ data }: RichiesteTableProps) => { ), enableSorting: false, }, + { + accessorKey: "ordini", + cell: ({ row }) => { + return ( + + + + ); + }, + + header: ({ column }) => ( + + ), + enableSorting: false, + }, { cell: ({ row }) => { return ( diff --git a/apps/infoalloggi/src/forms/FormEditOrdine.tsx b/apps/infoalloggi/src/forms/FormEditOrdine.tsx index 938f2f5..de43f36 100644 --- a/apps/infoalloggi/src/forms/FormEditOrdine.tsx +++ b/apps/infoalloggi/src/forms/FormEditOrdine.tsx @@ -268,9 +268,7 @@ export const FormEditOrder = ({ prezziario, data, close }: FormProps) => { - - Imposta se il servizio è pagato - + Imposta se attivo )} /> diff --git a/apps/infoalloggi/src/forms/FormNewOrdine.tsx b/apps/infoalloggi/src/forms/FormNewOrdine.tsx index 981a22a..31dcb0d 100644 --- a/apps/infoalloggi/src/forms/FormNewOrdine.tsx +++ b/apps/infoalloggi/src/forms/FormNewOrdine.tsx @@ -33,9 +33,11 @@ import { SelectValue, } from "~/components/ui/select"; import { Switch } from "~/components/ui/switch"; +import { PAYMENT_TYPES } from "~/i18n/stripe"; import { cn, formatCurrency } from "~/lib/utils"; import { useZodForm } from "~/lib/zodForm"; import OrderTypeEnum from "~/schemas/public/OrderTypeEnum"; +import PaymentStatusEnum from "~/schemas/public/PaymentStatusEnum"; import type { Prezziario } from "~/schemas/public/Prezziario"; import type { ServizioServizioId } from "~/schemas/public/Servizio"; import type { UsersId } from "~/schemas/public/Users"; @@ -62,6 +64,8 @@ export const FormNewOrder = ({ created_at: z.date(), amount_cent: z.number(), sconto: z.number().min(0).max(100), + paymentmethod: z.enum(PAYMENT_TYPES).nullable(), + paymentstatus: z.enum(PaymentStatusEnum).nullable(), }); type FormValues = z.infer; @@ -72,6 +76,8 @@ export const FormNewOrder = ({ sconto: 0, amount_cent: 0, isActive: false, + paymentmethod: null, + paymentstatus: null, }, }); const utils = api.useUtils(); @@ -244,12 +250,76 @@ export const FormNewOrder = ({ - - Imposta se il servizio è pagato - + Imposta se attivo )} /> +
+ ( + +
+ Stato Pagameto + +
+ + + +
+ )} + /> + ( + +
+ + Metodo di Pagamento + + +
+ + + +
+ )} + /> +