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,
|
||||
codice: data.codice,
|
||||
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})`,
|
||||
});
|
||||
setInputEmail("");
|
||||
|
|
@ -229,7 +229,10 @@ export function SchedaAnnuncio({
|
|||
</span>
|
||||
</h3>
|
||||
<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>}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -292,7 +292,8 @@ const AdminAnnuncioContatti = () => {
|
|||
<>
|
||||
<div>
|
||||
<span className="font-semibold">Locatore/Incaricato: </span>
|
||||
{annuncio?.locatore || "N/A"}
|
||||
{annuncio?.locatore || "N/A"}{" "}
|
||||
{annuncio?.tipo_locatore ? `(${annuncio.tipo_locatore})` : ""}
|
||||
</div>
|
||||
<div>
|
||||
<span className="font-semibold">Email: </span>
|
||||
|
|
|
|||
|
|
@ -40,9 +40,18 @@ import {
|
|||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "~/components/ui/popover";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectGroup,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "~/components/ui/select";
|
||||
import { Switch } from "~/components/ui/switch";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "~/components/ui/tabs";
|
||||
import { VideoPlayer } from "~/components/videoPlayer";
|
||||
import { FieldResetButton } from "~/forms/comps";
|
||||
import { filteredCaratteristiche } from "~/hooks/schedaAnnuncioUtils";
|
||||
import { NullableStringOnChange } from "~/lib/form_utils";
|
||||
import { getStorageUrl } from "~/lib/storage_utils";
|
||||
|
|
@ -86,6 +95,7 @@ export const AnnuncioEditForm = ({ data }: { data: AnnunciWithMedia }) => {
|
|||
|
||||
// DATI LOCATORE
|
||||
locatore: z.string().nullable(),
|
||||
tipo_locatore: z.string().nullable(),
|
||||
lon: z.string().nullable(),
|
||||
lon_secondario: z.string().nullable(),
|
||||
mq: z.number().nullable(),
|
||||
|
|
@ -547,6 +557,8 @@ export const AnnuncioEditForm = ({ data }: { data: AnnunciWithMedia }) => {
|
|||
<CardTitle>Dati di contatto</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<DualInputLayout
|
||||
children1={
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="locatore"
|
||||
|
|
@ -573,6 +585,62 @@ export const AnnuncioEditForm = ({ data }: { data: AnnunciWithMedia }) => {
|
|||
</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
|
||||
children1={
|
||||
<FormField
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ export const comunicazioniRouter = createTRPCRouter({
|
|||
"cap",
|
||||
"provincia",
|
||||
"numero",
|
||||
"tipo_locatore",
|
||||
])
|
||||
.where("id", "=", input.annuncioId)
|
||||
.executeTakeFirstOrThrow(
|
||||
|
|
@ -171,7 +172,7 @@ export const comunicazioniRouter = createTRPCRouter({
|
|||
mailType: "emailContattiConScheda",
|
||||
props: {
|
||||
codice: annuncio.codice,
|
||||
nominativo: annuncio.locatore || "",
|
||||
nominativo: `${annuncio.locatore}${annuncio?.tipo_locatore ? ` (${annuncio.tipo_locatore})` : ""}`,
|
||||
telefono: annuncio.numero || "",
|
||||
indirizzo: `${annuncio.indirizzo || ""}, ${annuncio.civico || ""} ${annuncio.comune || ""} ${annuncio.cap || ""} (${annuncio.provincia || ""})`,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -736,6 +736,7 @@ export const SbloccaContatti = async ({
|
|||
"email",
|
||||
"numero",
|
||||
"locatore",
|
||||
"tipo_locatore",
|
||||
"civico",
|
||||
"comune",
|
||||
])
|
||||
|
|
@ -756,7 +757,7 @@ export const SbloccaContatti = async ({
|
|||
mailType: "emailContattoInteressato",
|
||||
props: {
|
||||
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,
|
||||
sesso: data.anagrafica.sesso,
|
||||
telefono: data.user.telefono,
|
||||
|
|
@ -785,7 +786,7 @@ export const SbloccaContatti = async ({
|
|||
template: {
|
||||
mailType: "emailContattiConScheda",
|
||||
props: {
|
||||
nominativo: data.annuncio.locatore || "",
|
||||
nominativo: `${data.annuncio.locatore}${data.annuncio?.tipo_locatore ? ` (${data.annuncio.tipo_locatore})` : ""}`,
|
||||
telefono: data.annuncio.numero || "",
|
||||
indirizzo: data.annuncio.indirizzo || "",
|
||||
codice: data.annuncio.codice,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue