feat: add tipo_locatore field to various components and update related logic for improved locatore display
This commit is contained in:
parent
5327cc86c6
commit
57cd55d2d8
5 changed files with 104 additions and 30 deletions
|
|
@ -51,7 +51,7 @@ export function SchedaAnnuncioStampabile({ data }: { data: Annunci }) {
|
||||||
to: inputEmail,
|
to: inputEmail,
|
||||||
codice: data.codice,
|
codice: data.codice,
|
||||||
numero: data.numero,
|
numero: data.numero,
|
||||||
nominativo: data.locatore,
|
nominativo: `${data.locatore}${data.tipo_locatore ? ` (${data.tipo_locatore})` : ""}`,
|
||||||
indirizzo: `${data.indirizzo}, ${data.civico} ${data.comune} ${data.cap} (${data.provincia})`,
|
indirizzo: `${data.indirizzo}, ${data.civico} ${data.comune} ${data.cap} (${data.provincia})`,
|
||||||
});
|
});
|
||||||
setInputEmail("");
|
setInputEmail("");
|
||||||
|
|
@ -229,7 +229,10 @@ export function SchedaAnnuncio({
|
||||||
</span>
|
</span>
|
||||||
</h3>
|
</h3>
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<p>{data.locatore}</p>
|
<p>
|
||||||
|
{data.locatore}{" "}
|
||||||
|
{data.tipo_locatore ? `(${data.tipo_locatore})` : ""}
|
||||||
|
</p>
|
||||||
{data.numero && <p className="font-semibold">Tel. {data.numero}</p>}
|
{data.numero && <p className="font-semibold">Tel. {data.numero}</p>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,8 @@ const AdminAnnuncioContatti = () => {
|
||||||
<>
|
<>
|
||||||
<div>
|
<div>
|
||||||
<span className="font-semibold">Locatore/Incaricato: </span>
|
<span className="font-semibold">Locatore/Incaricato: </span>
|
||||||
{annuncio?.locatore || "N/A"}
|
{annuncio?.locatore || "N/A"}{" "}
|
||||||
|
{annuncio?.tipo_locatore ? `(${annuncio.tipo_locatore})` : ""}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span className="font-semibold">Email: </span>
|
<span className="font-semibold">Email: </span>
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,18 @@ import {
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
PopoverTrigger,
|
PopoverTrigger,
|
||||||
} from "~/components/ui/popover";
|
} from "~/components/ui/popover";
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectGroup,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "~/components/ui/select";
|
||||||
import { Switch } from "~/components/ui/switch";
|
import { Switch } from "~/components/ui/switch";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "~/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "~/components/ui/tabs";
|
||||||
import { VideoPlayer } from "~/components/videoPlayer";
|
import { VideoPlayer } from "~/components/videoPlayer";
|
||||||
|
import { FieldResetButton } from "~/forms/comps";
|
||||||
import { filteredCaratteristiche } from "~/hooks/schedaAnnuncioUtils";
|
import { filteredCaratteristiche } from "~/hooks/schedaAnnuncioUtils";
|
||||||
import { NullableStringOnChange } from "~/lib/form_utils";
|
import { NullableStringOnChange } from "~/lib/form_utils";
|
||||||
import { getStorageUrl } from "~/lib/storage_utils";
|
import { getStorageUrl } from "~/lib/storage_utils";
|
||||||
|
|
@ -86,6 +95,7 @@ export const AnnuncioEditForm = ({ data }: { data: AnnunciWithMedia }) => {
|
||||||
|
|
||||||
// DATI LOCATORE
|
// DATI LOCATORE
|
||||||
locatore: z.string().nullable(),
|
locatore: z.string().nullable(),
|
||||||
|
tipo_locatore: z.string().nullable(),
|
||||||
lon: z.string().nullable(),
|
lon: z.string().nullable(),
|
||||||
lon_secondario: z.string().nullable(),
|
lon_secondario: z.string().nullable(),
|
||||||
mq: z.number().nullable(),
|
mq: z.number().nullable(),
|
||||||
|
|
@ -547,31 +557,89 @@ export const AnnuncioEditForm = ({ data }: { data: AnnunciWithMedia }) => {
|
||||||
<CardTitle>Dati di contatto</CardTitle>
|
<CardTitle>Dati di contatto</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-4">
|
<CardContent className="space-y-4">
|
||||||
<FormField
|
<DualInputLayout
|
||||||
control={form.control}
|
children1={
|
||||||
name="locatore"
|
<FormField
|
||||||
render={({ field }) => (
|
control={form.control}
|
||||||
<FormItem>
|
name="locatore"
|
||||||
<div className="flex flex-wrap items-center gap-x-2">
|
render={({ field }) => (
|
||||||
<FormLabel htmlFor="locatore">
|
<FormItem>
|
||||||
Locatore o incaricato
|
<div className="flex flex-wrap items-center gap-x-2">
|
||||||
</FormLabel>
|
<FormLabel htmlFor="locatore">
|
||||||
<FormMessage />
|
Locatore o incaricato
|
||||||
</div>
|
</FormLabel>
|
||||||
|
<FormMessage />
|
||||||
|
</div>
|
||||||
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
placeholder=""
|
placeholder=""
|
||||||
{...field}
|
{...field}
|
||||||
id="locatore"
|
id="locatore"
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
NullableStringOnChange(e, field.onChange)
|
NullableStringOnChange(e, field.onChange)
|
||||||
}
|
}
|
||||||
value={field.value || ""}
|
value={field.value || ""}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
children2={
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="tipo_locatore"
|
||||||
|
render={({ field }) => {
|
||||||
|
const { value, onChange, ...rest } = field;
|
||||||
|
return (
|
||||||
|
<FormItem>
|
||||||
|
<div className="flex flex-wrap items-center gap-x-2">
|
||||||
|
<FormLabel htmlFor="tipo_locatore">
|
||||||
|
Tipo locatore
|
||||||
|
</FormLabel>
|
||||||
|
{value !== null && (
|
||||||
|
<FieldResetButton
|
||||||
|
onClick={() =>
|
||||||
|
form.setValue("tipo_locatore", null)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<FormMessage />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<FormControl>
|
||||||
|
<Select
|
||||||
|
{...rest}
|
||||||
|
defaultValue={value || undefined}
|
||||||
|
onValueChange={onChange}
|
||||||
|
>
|
||||||
|
<SelectTrigger
|
||||||
|
className="mb-0 w-full"
|
||||||
|
id="tipo_locatore"
|
||||||
|
>
|
||||||
|
<SelectValue placeholder="seleziona" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectGroup>
|
||||||
|
<SelectItem value="proprietario">
|
||||||
|
Proprietario
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="inquilino">
|
||||||
|
Inquilino
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="delegato">
|
||||||
|
Delegato
|
||||||
|
</SelectItem>
|
||||||
|
</SelectGroup>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
</FormItem>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<DualInputLayout
|
<DualInputLayout
|
||||||
children1={
|
children1={
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,7 @@ export const comunicazioniRouter = createTRPCRouter({
|
||||||
"cap",
|
"cap",
|
||||||
"provincia",
|
"provincia",
|
||||||
"numero",
|
"numero",
|
||||||
|
"tipo_locatore",
|
||||||
])
|
])
|
||||||
.where("id", "=", input.annuncioId)
|
.where("id", "=", input.annuncioId)
|
||||||
.executeTakeFirstOrThrow(
|
.executeTakeFirstOrThrow(
|
||||||
|
|
@ -171,7 +172,7 @@ export const comunicazioniRouter = createTRPCRouter({
|
||||||
mailType: "emailContattiConScheda",
|
mailType: "emailContattiConScheda",
|
||||||
props: {
|
props: {
|
||||||
codice: annuncio.codice,
|
codice: annuncio.codice,
|
||||||
nominativo: annuncio.locatore || "",
|
nominativo: `${annuncio.locatore}${annuncio?.tipo_locatore ? ` (${annuncio.tipo_locatore})` : ""}`,
|
||||||
telefono: annuncio.numero || "",
|
telefono: annuncio.numero || "",
|
||||||
indirizzo: `${annuncio.indirizzo || ""}, ${annuncio.civico || ""} ${annuncio.comune || ""} ${annuncio.cap || ""} (${annuncio.provincia || ""})`,
|
indirizzo: `${annuncio.indirizzo || ""}, ${annuncio.civico || ""} ${annuncio.comune || ""} ${annuncio.cap || ""} (${annuncio.provincia || ""})`,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -736,6 +736,7 @@ export const SbloccaContatti = async ({
|
||||||
"email",
|
"email",
|
||||||
"numero",
|
"numero",
|
||||||
"locatore",
|
"locatore",
|
||||||
|
"tipo_locatore",
|
||||||
"civico",
|
"civico",
|
||||||
"comune",
|
"comune",
|
||||||
])
|
])
|
||||||
|
|
@ -756,7 +757,7 @@ export const SbloccaContatti = async ({
|
||||||
mailType: "emailContattoInteressato",
|
mailType: "emailContattoInteressato",
|
||||||
props: {
|
props: {
|
||||||
indirizzo: data.annuncio.indirizzo,
|
indirizzo: data.annuncio.indirizzo,
|
||||||
nome_cognome: data.annuncio.locatore || "",
|
nome_cognome: `${data.annuncio.locatore}${data.annuncio?.tipo_locatore ? ` (${data.annuncio.tipo_locatore})` : ""}`,
|
||||||
nome_cognome_utente: data.user.username,
|
nome_cognome_utente: data.user.username,
|
||||||
sesso: data.anagrafica.sesso,
|
sesso: data.anagrafica.sesso,
|
||||||
telefono: data.user.telefono,
|
telefono: data.user.telefono,
|
||||||
|
|
@ -785,7 +786,7 @@ export const SbloccaContatti = async ({
|
||||||
template: {
|
template: {
|
||||||
mailType: "emailContattiConScheda",
|
mailType: "emailContattiConScheda",
|
||||||
props: {
|
props: {
|
||||||
nominativo: data.annuncio.locatore || "",
|
nominativo: `${data.annuncio.locatore}${data.annuncio?.tipo_locatore ? ` (${data.annuncio.tipo_locatore})` : ""}`,
|
||||||
telefono: data.annuncio.numero || "",
|
telefono: data.annuncio.numero || "",
|
||||||
indirizzo: data.annuncio.indirizzo || "",
|
indirizzo: data.annuncio.indirizzo || "",
|
||||||
codice: data.annuncio.codice,
|
codice: data.annuncio.codice,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue