fix: fixed dialogs and db structure

This commit is contained in:
Mouad Lahlal 2025-11-11 17:56:56 +01:00
parent 8e4c9db75a
commit fc729c6b77
26 changed files with 921 additions and 329 deletions

313
package-lock.json generated
View file

@ -202,6 +202,111 @@
"integrity": "sha512-2Zhvss36s/yL+YSxD5ZL5dz5pI6ki1OLxYlh6O77VJ68sBnlUrl5YqhBgCy7FkdMsp9RBeGFwpuDCdpJOqdKeQ==",
"license": "MIT"
},
"node_modules/@next/swc-darwin-arm64": {
"version": "15.5.5",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-15.5.5.tgz",
"integrity": "sha512-lYExGHuFIHeOxf40mRLWoA84iY2sLELB23BV5FIDHhdJkN1LpRTPc1MDOawgTo5ifbM5dvAwnGuHyNm60G1+jw==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-darwin-x64": {
"version": "15.5.5",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-15.5.5.tgz",
"integrity": "sha512-cacs/WQqa96IhqUm+7CY+z/0j9sW6X80KE07v3IAJuv+z0UNvJtKSlT/T1w1SpaQRa9l0wCYYZlRZUhUOvEVmg==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-arm64-gnu": {
"version": "15.5.5",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-15.5.5.tgz",
"integrity": "sha512-tLd90SvkRFik6LSfuYjcJEmwqcNEnVYVOyKTacSazya/SLlSwy/VYKsDE4GIzOBd+h3gW+FXqShc2XBavccHCg==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-arm64-musl": {
"version": "15.5.5",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-15.5.5.tgz",
"integrity": "sha512-ekV76G2R/l3nkvylkfy9jBSYHeB4QcJ7LdDseT6INnn1p51bmDS1eGoSoq+RxfQ7B1wt+Qa0pIl5aqcx0GLpbw==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-x64-gnu": {
"version": "15.5.5",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-15.5.5.tgz",
"integrity": "sha512-tI+sBu+3FmWtqlqD4xKJcj3KJtqbniLombKTE7/UWyyoHmOyAo3aZ7QcEHIOgInXOG1nt0rwh0KGmNbvSB0Djg==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-x64-musl": {
"version": "15.5.5",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-15.5.5.tgz",
"integrity": "sha512-kDRh+epN/ulroNJLr+toDjN+/JClY5L+OAWjOrrKCI0qcKvTw9GBx7CU/rdA2bgi4WpZN3l0rf/3+b8rduEwrQ==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-win32-arm64-msvc": {
"version": "15.5.5",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-15.5.5.tgz",
"integrity": "sha512-GDgdNPFFqiKjTrmfw01sMMRWhVN5wOCmFzPloxa7ksDfX6TZt62tAK986f0ZYqWpvDFqeBCLAzmgTURvtQBdgw==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-win32-x64-msvc": {
"version": "15.5.5",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.5.5.tgz",
@ -1341,6 +1446,206 @@
"@tailwindcss/oxide-win32-x64-msvc": "4.1.14"
}
},
"node_modules/@tailwindcss/oxide-android-arm64": {
"version": "4.1.14",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.1.14.tgz",
"integrity": "sha512-a94ifZrGwMvbdeAxWoSuGcIl6/DOP5cdxagid7xJv6bwFp3oebp7y2ImYsnZBMTwjn5Ev5xESvS3FFYUGgPODQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tailwindcss/oxide-darwin-arm64": {
"version": "4.1.14",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.1.14.tgz",
"integrity": "sha512-HkFP/CqfSh09xCnrPJA7jud7hij5ahKyWomrC3oiO2U9i0UjP17o9pJbxUN0IJ471GTQQmzwhp0DEcpbp4MZTA==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tailwindcss/oxide-darwin-x64": {
"version": "4.1.14",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.1.14.tgz",
"integrity": "sha512-eVNaWmCgdLf5iv6Qd3s7JI5SEFBFRtfm6W0mphJYXgvnDEAZ5sZzqmI06bK6xo0IErDHdTA5/t7d4eTfWbWOFw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tailwindcss/oxide-freebsd-x64": {
"version": "4.1.14",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.1.14.tgz",
"integrity": "sha512-QWLoRXNikEuqtNb0dhQN6wsSVVjX6dmUFzuuiL09ZeXju25dsei2uIPl71y2Ic6QbNBsB4scwBoFnlBfabHkEw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tailwindcss/oxide-linux-arm-gnueabihf": {
"version": "4.1.14",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.1.14.tgz",
"integrity": "sha512-VB4gjQni9+F0VCASU+L8zSIyjrLLsy03sjcR3bM0V2g4SNamo0FakZFKyUQ96ZVwGK4CaJsc9zd/obQy74o0Fw==",
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tailwindcss/oxide-linux-arm64-gnu": {
"version": "4.1.14",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.1.14.tgz",
"integrity": "sha512-qaEy0dIZ6d9vyLnmeg24yzA8XuEAD9WjpM5nIM1sUgQ/Zv7cVkharPDQcmm/t/TvXoKo/0knI3me3AGfdx6w1w==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tailwindcss/oxide-linux-arm64-musl": {
"version": "4.1.14",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.1.14.tgz",
"integrity": "sha512-ISZjT44s59O8xKsPEIesiIydMG/sCXoMBCqsphDm/WcbnuWLxxb+GcvSIIA5NjUw6F8Tex7s5/LM2yDy8RqYBQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tailwindcss/oxide-linux-x64-gnu": {
"version": "4.1.14",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.1.14.tgz",
"integrity": "sha512-02c6JhLPJj10L2caH4U0zF8Hji4dOeahmuMl23stk0MU1wfd1OraE7rOloidSF8W5JTHkFdVo/O7uRUJJnUAJg==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tailwindcss/oxide-linux-x64-musl": {
"version": "4.1.14",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.1.14.tgz",
"integrity": "sha512-TNGeLiN1XS66kQhxHG/7wMeQDOoL0S33x9BgmydbrWAb9Qw0KYdd8o1ifx4HOGDWhVmJ+Ul+JQ7lyknQFilO3Q==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tailwindcss/oxide-wasm32-wasi": {
"version": "4.1.14",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-wasm32-wasi/-/oxide-wasm32-wasi-4.1.14.tgz",
"integrity": "sha512-uZYAsaW/jS/IYkd6EWPJKW/NlPNSkWkBlaeVBi/WsFQNP05/bzkebUL8FH1pdsqx4f2fH/bWFcUABOM9nfiJkQ==",
"bundleDependencies": [
"@napi-rs/wasm-runtime",
"@emnapi/core",
"@emnapi/runtime",
"@tybys/wasm-util",
"@emnapi/wasi-threads",
"tslib"
],
"cpu": [
"wasm32"
],
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
"@emnapi/core": "^1.5.0",
"@emnapi/runtime": "^1.5.0",
"@emnapi/wasi-threads": "^1.1.0",
"@napi-rs/wasm-runtime": "^1.0.5",
"@tybys/wasm-util": "^0.10.1",
"tslib": "^2.4.0"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@tailwindcss/oxide-win32-arm64-msvc": {
"version": "4.1.14",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.1.14.tgz",
"integrity": "sha512-Az0RnnkcvRqsuoLH2Z4n3JfAef0wElgzHD5Aky/e+0tBUxUhIeIqFBTMNQvmMRSP15fWwmvjBxZ3Q8RhsDnxAA==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tailwindcss/oxide-win32-x64-msvc": {
"version": "4.1.14",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.1.14.tgz",
@ -2377,11 +2682,11 @@
}
},
"node_modules/tar": {
"version": "7.5.1",
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.1.tgz",
"integrity": "sha512-nlGpxf+hv0v7GkWBK2V9spgactGOp0qvfWRxUMjqHyzrt3SgwE48DIv/FhqPHJYLHpgW1opq3nERbz5Anq7n1g==",
"version": "7.5.2",
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.2.tgz",
"integrity": "sha512-7NyxrTE4Anh8km8iEy7o0QYPs+0JKBTj5ZaqHg6B39erLg0qYXN3BijtShwbsNSvQ+LN75+KV+C4QR/f6Gwnpg==",
"dev": true,
"license": "ISC",
"license": "BlueOak-1.0.0",
"dependencies": {
"@isaacs/fs-minipass": "^4.0.0",
"chownr": "^3.0.0",

View file

@ -0,0 +1,21 @@
/*
Warnings:
- The primary key for the `Registratore` table will be changed. If it partially fails, the table could be left without primary key constraint.
*/
-- DropForeignKey
ALTER TABLE "public"."Intervento" DROP CONSTRAINT "Intervento_id_registratore_fkey";
-- AlterTable
ALTER TABLE "Intervento" ALTER COLUMN "id_registratore" SET DATA TYPE TEXT;
-- AlterTable
ALTER TABLE "Registratore" DROP CONSTRAINT "Registratore_pkey",
ALTER COLUMN "id" DROP DEFAULT,
ALTER COLUMN "id" SET DATA TYPE TEXT,
ADD CONSTRAINT "Registratore_pkey" PRIMARY KEY ("id");
DROP SEQUENCE "Registratore_id_seq";
-- AddForeignKey
ALTER TABLE "Intervento" ADD CONSTRAINT "Intervento_id_registratore_fkey" FOREIGN KEY ("id_registratore") REFERENCES "Registratore"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View file

@ -0,0 +1,8 @@
/*
Warnings:
- You are about to drop the column `seriale` on the `Registratore` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "Registratore" DROP COLUMN "seriale";

View file

@ -0,0 +1,5 @@
-- CreateEnum
CREATE TYPE "Modello" AS ENUM ('FORM100', 'FORM200', 'FORM500');
-- AlterTable
ALTER TABLE "Registratore" ADD COLUMN "modello" "Modello";

View file

@ -0,0 +1,2 @@
-- AlterEnum
ALTER TYPE "Modello" ADD VALUE 'FORM200PLUS';

View file

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Cliente" ADD COLUMN "coordinate" DOUBLE PRECISION[];

View file

@ -0,0 +1,10 @@
/*
Warnings:
- You are about to drop the column `coordinate` on the `Cliente` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "Cliente" DROP COLUMN "coordinate",
ADD COLUMN "lat" DOUBLE PRECISION,
ADD COLUMN "lon" DOUBLE PRECISION;

View file

@ -0,0 +1,10 @@
/*
Warnings:
- Made the column `lat` on table `Cliente` required. This step will fail if there are existing NULL values in that column.
- Made the column `lon` on table `Cliente` required. This step will fail if there are existing NULL values in that column.
*/
-- AlterTable
ALTER TABLE "Cliente" ALTER COLUMN "lat" SET NOT NULL,
ALTER COLUMN "lon" SET NOT NULL;

View file

@ -8,9 +8,16 @@ datasource db {
url = env("DATABASE_URL")
}
enum Modello {
FORM100
FORM200
FORM200PLUS
FORM500
}
model Intervento {
id Int @id @default(autoincrement())
id_registratore Int
id_registratore String
data DateTime @db.Date
lavoro String @db.Text
fattura Boolean @db.Boolean
@ -18,9 +25,9 @@ model Intervento {
}
model Registratore {
id Int @id @default(autoincrement())
id String @id
id_cliente Int
seriale String? @db.VarChar(255)
modello Modello?
data_acquisto DateTime? @db.Date
ultima_verifica DateTime? @db.Date
prossima_verifica DateTime? @db.Date
@ -37,5 +44,7 @@ model Cliente {
sede String @db.VarChar(255)
sede_url String @db.VarChar(255)
contratto String @db.VarChar(255)
lat Float
lon Float
registratori Registratore[]
}

View file

@ -0,0 +1,24 @@
import { Modello, PrismaClient } from "@/generated/prisma";
export async function POST(request: Request) {
const prisma = new PrismaClient();
const data = await request.json();
await prisma.registratore.create({
data: {
id: data.seriale,
id_cliente: data.id,
data_acquisto: new Date(data.data),
modello:
data.modello === "FORM100"
? Modello.FORM100
: data.modello === "FORM200"
? Modello.FORM200
: data.modello === "FORM200PLUS"
? Modello.FORM200PLUS
: Modello.FORM500,
},
});
return Response.json({ message: "fatto bastardo" });
}

View file

@ -108,7 +108,7 @@ export default function Page() {
{cliente ? <ClientCard cliente={cliente} /> : <></>}
{registratori ? (
registratori.map((registratore) => (
<DeviceCard registratore={registratore} />
<DeviceCard registratore={registratore} key={registratore.id} />
))
) : (
<></>

View file

@ -2,18 +2,31 @@
import dynamic from "next/dynamic";
import { useSearchParams } from "next/navigation";
import { useEffect, useState } from "react";
import { Cliente } from "@/generated/prisma";
export default function Page() {
const MapWithNoSSR = dynamic(() => import("../../components/map"), {
ssr: false,
});
const [clienti, setClienti] = useState<Array<Cliente>>();
const searchParams = useSearchParams();
const client = searchParams.get("client");
useEffect(() => {
async function getClienti() {
const req = await fetch(`/api/clienti`);
const data = await req.json();
console.log(data.clients);
setClienti(data.clients);
}
getClienti();
}, []);
return (
<div id="map" className="w-full h-full border rounded-md m-0 p-0">
<MapWithNoSSR highlight={client} />
<MapWithNoSSR highlight={client} clienti={clienti} />
</div>
);
}

View file

@ -18,16 +18,16 @@ import { Plus } from "lucide-react";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Button } from "@/components/ui/button";
import { useState } from "react";
import { useEffect, useState } from "react";
import DatePicker from "./date-picker";
import { Checkbox } from "@/components/ui/checkbox";
const AddInterventoDialog = ({ id }: { id: Number }) => {
const AddInterventoDialog = ({ id }: { id: string }) => {
//const [nome, setNome] = useState("");
const [open, setOpen] = useState(false);
const [data, setData] = useState<Date | undefined>();
const [data, setData] = useState<Date | undefined>(new Date());
const [lavoro, setLavoro] = useState<string>("");
const [fattura, setFattura] = useState<Boolean>();
const [fattura, setFattura] = useState<Boolean>(false);
return (
<div>
@ -75,15 +75,13 @@ const AddInterventoDialog = ({ id }: { id: Number }) => {
<div className="gap-3 flex items-center mt-2">
<Checkbox
id="fattura"
onCheckedChange={(checked) =>
setFattura(
onCheckedChange={(checked) => {
checked === "indeterminate"
? false
? setFattura(false)
: checked
? true
: true,
)
}
? setFattura(true)
: setFattura(false);
}}
/>
<Label htmlFor="fattura">Fattura</Label>
</div>

View file

@ -28,25 +28,25 @@ const AddRegistratoreDialog = ({ id }: { id: Number }) => {
const [openData, setOpenData] = useState(false);
const [openModello, setOpenModello] = useState(false);
const [data, setData] = useState<Date | undefined>();
const [seriale, setSeriale] = useState<string>("");
const [modello, setModello] = useState<Date | undefined>();
const [lavoro, setLavoro] = useState<string>("");
const [fattura, setFattura] = useState<Boolean>();
const modelli = [
{
value: "Form 100",
value: "FORM100",
label: "Form 100",
},
{
value: "Form 200",
value: "FORM200",
label: "Form 200",
},
{
value: "Form 200 Plus",
value: "FORM200PLUS",
label: "Form 200 Plus",
},
{
value: "Form 500",
value: "FORM500",
label: "Form 500",
},
];
@ -73,12 +73,12 @@ const AddRegistratoreDialog = ({ id }: { id: Number }) => {
</DialogHeader>
<div className="grid gap-4">
<div className="grid gap-3">
<Label htmlFor="lavoro">Seriale</Label>
<Label htmlFor="seriale">Seriale</Label>
<Input
id="seriale"
name="seriale"
placeholder="Seriale"
onChange={(e) => setLavoro(e.target.value)}
onChange={(e) => setSeriale(e.target.value)}
/>
</div>
<div className="grid gap-3">
@ -100,21 +100,6 @@ const AddRegistratoreDialog = ({ id }: { id: Number }) => {
modelli={modelli}
/>
</div>
<div className="gap-3 flex items-center mt-2">
<Checkbox
id="fattura"
onCheckedChange={(checked) =>
setFattura(
checked === "indeterminate"
? false
: checked
? true
: true,
)
}
/>
<Label htmlFor="fattura">Fattura</Label>
</div>
</div>
<DialogFooter>
<DialogClose asChild>
@ -122,13 +107,13 @@ const AddRegistratoreDialog = ({ id }: { id: Number }) => {
</DialogClose>
<Button
onClick={async () =>
await fetch("/api/interventi", {
await fetch("/api/registratori", {
method: "POST",
body: JSON.stringify({
id: id,
seriale: seriale,
data: data,
fattura: fattura,
lavoro: lavoro,
modello: modello,
}),
})
}

View file

@ -35,7 +35,7 @@ const DeviceCard = ({ registratore }: { registratore: Registratore }) => {
<Card className="@container/card">
<CardHeader>
<CardTitle className="text-xl font-semibold tabular-nums @[250px]/card:text-2xl">
FORM 100
{registratore.modello}
</CardTitle>
<CardAction className="flex items-center gap-4">
<Tooltip>
@ -102,7 +102,19 @@ const DeviceCard = ({ registratore }: { registratore: Registratore }) => {
<TableHead className="text-right">Fattura</TableHead>
</TableRow>
</TableHeader>
<TableBody></TableBody>
<TableBody>
{registratore.interventi.map((intervento) => (
<TableRow key={intervento.id}>
<TableCell className="font-medium">
{new Date(intervento.data).toLocaleDateString("it-IT")}
</TableCell>
<TableCell>{intervento.lavoro}</TableCell>
<TableCell className="text-right">
<Checkbox checked={intervento.fattura} />
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
</CardContent>

View file

@ -8,8 +8,15 @@ import {
} from "@/components/ui/tooltip";
import { Button } from "@/components/ui/button";
import { Map as MapIcon } from "lucide-react";
import { Cliente } from "@/generated/prisma";
const Map = ({highlight}: {highlight?: string}) => {
const Map = ({
highlight,
clienti,
}: {
highlight?: string;
clienti: Array<Cliente>;
}) => {
const positions = [
{
name: "Autogeneral",
@ -38,9 +45,6 @@ const Map = ({highlight}: {highlight?: string}) => {
},
];
console.log(highlight);
console.log(positions.find((client) => client.name == highlight));
const customMarker = new Icon({
iconUrl: "marker-icon-red.png",
iconAnchor: [10, 20],
@ -49,7 +53,11 @@ const Map = ({highlight}: {highlight?: string}) => {
return (
<MapContainer
center={highlight ? positions.find((client) => client.name == highlight)?.position : [45.54157745559809, 10.211896906975962]}
center={
highlight
? positions.find((client) => client.name == highlight)?.position
: [45.54157745559809, 10.211896906975962]
}
zoom={13}
scrollWheelZoom={true}
className="m-0 p-0 h-[99%] w-[99%] mx-[0.5%] my-[0.5%] rounded-md z-0"
@ -58,9 +66,11 @@ const Map = ({highlight}: {highlight?: string}) => {
attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
url={`https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png`}
/>
{ highlight == null ? positions.map((client) => (
{highlight == null ? (
clienti ? (
clienti.map((client) => (
<Marker
position={client.position}
position={[client.lat, client.lon]}
draggable={false}
animate={false}
icon={customMarker}
@ -68,10 +78,12 @@ const Map = ({highlight}: {highlight?: string}) => {
<Popup className="">
<div className="flex flex-row gap-5">
<div>
<span className="block text-sm font-bold">{client.name}</span>
<span className="block text-sm font-bold">
{client.ragione_sociale}
</span>
<div className="flex gap-2">
<span className="text-xs font-semibold">P.IVA</span>
<span className="text-xs">03417520172</span>
<span className="text-xs">{client.partita_iva}</span>
</div>
</div>
@ -90,9 +102,15 @@ const Map = ({highlight}: {highlight?: string}) => {
</div>
</Popup>
</Marker>
)) :
))
) : (
<></>
)
) : (
<Marker
position={positions.find((client) => client.name == highlight)?.position}
position={
positions.find((client) => client.name == highlight)?.position
}
draggable={false}
animate={false}
icon={customMarker}
@ -100,7 +118,9 @@ const Map = ({highlight}: {highlight?: string}) => {
<Popup className="">
<div className="flex flex-row gap-5">
<div>
<span className="block text-sm font-bold">{positions.find((client) => client.name == highlight)?.name}</span>
<span className="block text-sm font-bold">
{positions.find((client) => client.name == highlight)?.name}
</span>
<div className="flex gap-2">
<span className="text-xs font-semibold">P.IVA</span>
<span className="text-xs">03417520172</span>
@ -109,7 +129,13 @@ const Map = ({highlight}: {highlight?: string}) => {
<Tooltip>
<TooltipTrigger asChild>
<a href={positions.find((client) => client.name == highlight)?.sede_url} target="blank">
<a
href={
positions.find((client) => client.name == highlight)
?.sede_url
}
target="blank"
>
<Button variant="outline">
<MapIcon className="size-4" />
</Button>
@ -122,7 +148,7 @@ const Map = ({highlight}: {highlight?: string}) => {
</div>
</Popup>
</Marker>
}
)}
</MapContainer>
);
};

File diff suppressed because one or more lines are too long

View file

@ -131,7 +131,7 @@ exports.Prisma.InterventoScalarFieldEnum = {
exports.Prisma.RegistratoreScalarFieldEnum = {
id: 'id',
id_cliente: 'id_cliente',
seriale: 'seriale',
modello: 'modello',
data_acquisto: 'data_acquisto',
ultima_verifica: 'ultima_verifica',
prossima_verifica: 'prossima_verifica'
@ -145,7 +145,9 @@ exports.Prisma.ClienteScalarFieldEnum = {
telefono: 'telefono',
sede: 'sede',
sede_url: 'sede_url',
contratto: 'contratto'
contratto: 'contratto',
lat: 'lat',
lon: 'lon'
};
exports.Prisma.SortOrder = {
@ -162,7 +164,12 @@ exports.Prisma.NullsOrder = {
first: 'first',
last: 'last'
};
exports.Modello = exports.$Enums.Modello = {
FORM100: 'FORM100',
FORM200: 'FORM200',
FORM200PLUS: 'FORM200PLUS',
FORM500: 'FORM500'
};
exports.Prisma.ModelName = {
Intervento: 'Intervento',

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
{
"name": "prisma-client-a0a80ba0555f8568703a32f3b3a8d9358801f7fa1dcdf09b6f9e9540596b839b",
"name": "prisma-client-58455549b989c60e3bedecbaad5fb747da20ec4980d09c51c40211ff854da52b",
"main": "index.js",
"types": "index.d.ts",
"browser": "default.js",

View file

@ -8,9 +8,16 @@ datasource db {
url = env("DATABASE_URL")
}
enum Modello {
FORM100
FORM200
FORM200PLUS
FORM500
}
model Intervento {
id Int @id @default(autoincrement())
id_registratore Int
id_registratore String
data DateTime @db.Date
lavoro String @db.Text
fattura Boolean @db.Boolean
@ -18,9 +25,9 @@ model Intervento {
}
model Registratore {
id Int @id @default(autoincrement())
id String @id
id_cliente Int
seriale String? @db.VarChar(255)
modello Modello?
data_acquisto DateTime? @db.Date
ultima_verifica DateTime? @db.Date
prossima_verifica DateTime? @db.Date

View file

@ -103,7 +103,7 @@ exports.Prisma.InterventoScalarFieldEnum = {
exports.Prisma.RegistratoreScalarFieldEnum = {
id: 'id',
id_cliente: 'id_cliente',
seriale: 'seriale',
modello: 'modello',
data_acquisto: 'data_acquisto',
ultima_verifica: 'ultima_verifica',
prossima_verifica: 'prossima_verifica'
@ -117,7 +117,9 @@ exports.Prisma.ClienteScalarFieldEnum = {
telefono: 'telefono',
sede: 'sede',
sede_url: 'sede_url',
contratto: 'contratto'
contratto: 'contratto',
lat: 'lat',
lon: 'lon'
};
exports.Prisma.SortOrder = {
@ -134,7 +136,12 @@ exports.Prisma.NullsOrder = {
first: 'first',
last: 'last'
};
exports.Modello = exports.$Enums.Modello = {
FORM100: 'FORM100',
FORM200: 'FORM200',
FORM200PLUS: 'FORM200PLUS',
FORM500: 'FORM500'
};
exports.Prisma.ModelName = {
Intervento: 'Intervento',
@ -188,13 +195,13 @@ const config = {
}
}
},
"inlineSchema": "generator client {\n provider = \"prisma-client-js\"\n output = \"../src/generated/prisma\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_URL\")\n}\n\nmodel Intervento {\n id Int @id @default(autoincrement())\n id_registratore Int\n data DateTime @db.Date\n lavoro String @db.Text\n fattura Boolean @db.Boolean\n registratore Registratore @relation(fields: [id_registratore], references: [id])\n}\n\nmodel Registratore {\n id Int @id @default(autoincrement())\n id_cliente Int\n seriale String? @db.VarChar(255)\n data_acquisto DateTime? @db.Date\n ultima_verifica DateTime? @db.Date\n prossima_verifica DateTime? @db.Date\n cliente Cliente @relation(fields: [id_cliente], references: [id])\n interventi Intervento[]\n}\n\nmodel Cliente {\n id Int @id @default(autoincrement())\n ragione_sociale String @unique @db.VarChar(255)\n email String @db.VarChar(255)\n partita_iva String @db.VarChar(255)\n telefono String @db.VarChar(255)\n sede String @db.VarChar(255)\n sede_url String @db.VarChar(255)\n contratto String @db.VarChar(255)\n registratori Registratore[]\n}\n",
"inlineSchemaHash": "70d19759fda92cfa8dfe96db3ee01c6cf89b508717f745431bdaf7866ae6512a",
"inlineSchema": "generator client {\n provider = \"prisma-client-js\"\n output = \"../src/generated/prisma\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_URL\")\n}\n\nenum Modello {\n FORM100\n FORM200\n FORM200PLUS\n FORM500\n}\n\nmodel Intervento {\n id Int @id @default(autoincrement())\n id_registratore String\n data DateTime @db.Date\n lavoro String @db.Text\n fattura Boolean @db.Boolean\n registratore Registratore @relation(fields: [id_registratore], references: [id])\n}\n\nmodel Registratore {\n id String @id\n id_cliente Int\n modello Modello?\n data_acquisto DateTime? @db.Date\n ultima_verifica DateTime? @db.Date\n prossima_verifica DateTime? @db.Date\n cliente Cliente @relation(fields: [id_cliente], references: [id])\n interventi Intervento[]\n}\n\nmodel Cliente {\n id Int @id @default(autoincrement())\n ragione_sociale String @unique @db.VarChar(255)\n email String @db.VarChar(255)\n partita_iva String @db.VarChar(255)\n telefono String @db.VarChar(255)\n sede String @db.VarChar(255)\n sede_url String @db.VarChar(255)\n contratto String @db.VarChar(255)\n lat Float\n lon Float\n registratori Registratore[]\n}\n",
"inlineSchemaHash": "3424ce1a172605bbf2b32e4c6ada582172d780cc98a6e12f826a26c0cc5b9555",
"copyEngine": true
}
config.dirname = '/'
config.runtimeDataModel = JSON.parse("{\"models\":{\"Intervento\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"id_registratore\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"data\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"lavoro\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"fattura\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"registratore\",\"kind\":\"object\",\"type\":\"Registratore\",\"relationName\":\"InterventoToRegistratore\"}],\"dbName\":null},\"Registratore\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"id_cliente\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"seriale\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"data_acquisto\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"ultima_verifica\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"prossima_verifica\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"cliente\",\"kind\":\"object\",\"type\":\"Cliente\",\"relationName\":\"ClienteToRegistratore\"},{\"name\":\"interventi\",\"kind\":\"object\",\"type\":\"Intervento\",\"relationName\":\"InterventoToRegistratore\"}],\"dbName\":null},\"Cliente\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"ragione_sociale\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"partita_iva\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"telefono\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"sede\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"sede_url\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"contratto\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"registratori\",\"kind\":\"object\",\"type\":\"Registratore\",\"relationName\":\"ClienteToRegistratore\"}],\"dbName\":null}},\"enums\":{},\"types\":{}}")
config.runtimeDataModel = JSON.parse("{\"models\":{\"Intervento\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"id_registratore\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"data\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"lavoro\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"fattura\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"registratore\",\"kind\":\"object\",\"type\":\"Registratore\",\"relationName\":\"InterventoToRegistratore\"}],\"dbName\":null},\"Registratore\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"id_cliente\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"modello\",\"kind\":\"enum\",\"type\":\"Modello\"},{\"name\":\"data_acquisto\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"ultima_verifica\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"prossima_verifica\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"cliente\",\"kind\":\"object\",\"type\":\"Cliente\",\"relationName\":\"ClienteToRegistratore\"},{\"name\":\"interventi\",\"kind\":\"object\",\"type\":\"Intervento\",\"relationName\":\"InterventoToRegistratore\"}],\"dbName\":null},\"Cliente\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"ragione_sociale\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"partita_iva\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"telefono\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"sede\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"sede_url\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"contratto\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"lat\",\"kind\":\"scalar\",\"type\":\"Float\"},{\"name\":\"lon\",\"kind\":\"scalar\",\"type\":\"Float\"},{\"name\":\"registratori\",\"kind\":\"object\",\"type\":\"Registratore\",\"relationName\":\"ClienteToRegistratore\"}],\"dbName\":null}},\"enums\":{},\"types\":{}}")
defineDmmfProperty(exports.Prisma, config.runtimeDataModel)
config.engineWasm = {
getRuntime: async () => require('./query_engine_bg.js'),