diff --git a/src/app/[locale]/(main)/zones/components/ZoneForm.tsx b/src/app/[locale]/(main)/zones/components/ZoneForm.tsx index 654bba8..cadff0c 100644 --- a/src/app/[locale]/(main)/zones/components/ZoneForm.tsx +++ b/src/app/[locale]/(main)/zones/components/ZoneForm.tsx @@ -10,12 +10,13 @@ import { Label } from "@/components/form/Label"; import { TextField } from "@/components/form/TextField"; import { ZoneEditorField } from "@/components/form/ZoneEditorField"; import { zoneSchema } from "@/schemas"; +import { Zone } from "@/server/myZones"; import { TimeControl } from "@/types"; export type ZoneFormValues = z.infer; type ZoneFormProps = { - zone?: ZoneFormValues; + zone?: Zone; onSubmit: (data: ZoneFormValues) => Promise; onCancel: () => void; submitTitle?: string; @@ -35,15 +36,23 @@ export const ZoneForm = ({ // @ts-ignore - Type instantiation is excessively deep and possibly infinite const form = useForm({ resolver: zodResolver(zoneSchema), - defaultValues: zone ?? { - classicNotifications: false, - rapidNotifications: false, - blitzNotifications: false, - features: { - type: "FeatureCollection", - features: [], - }, - }, + defaultValues: zone + ? { + name: zone.name, + classicNotifications: zone.classicNotifications, + rapidNotifications: zone.rapidNotifications, + blitzNotifications: zone.blitzNotifications, + features: zone.features as ZoneFormValues["features"], + } + : { + classicNotifications: false, + rapidNotifications: false, + blitzNotifications: false, + features: { + type: "FeatureCollection", + features: [], + }, + }, }); return ( diff --git a/src/app/[locale]/(main)/zones/components/ZoneThumbnail.tsx b/src/app/[locale]/(main)/zones/components/ZoneThumbnail.tsx index 1ef82a1..36dd4eb 100644 --- a/src/app/[locale]/(main)/zones/components/ZoneThumbnail.tsx +++ b/src/app/[locale]/(main)/zones/components/ZoneThumbnail.tsx @@ -4,16 +4,16 @@ import L, { LatLngLiteral } from "leaflet"; import "leaflet-defaulticon-compatibility"; import "leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.css"; import "leaflet/dist/leaflet.css"; -import { FeatureGroup, GeoJSON, MapContainer, TileLayer } from "react-leaflet"; +import { GeoJSON, MapContainer, TileLayer } from "react-leaflet"; import { twMerge } from "tailwind-merge"; import { MapEvents } from "@/components/MapEvents"; -import type { ZoneModel } from "@/server/models/zoneModel"; +import { Zone } from "@/server/myZones"; const center: LatLngLiteral = { lat: 47.0844, lng: 2.3964 }; export type ZoneThumbnailProps = { - features: ZoneModel["features"]; + features: Zone["features"]; className?: string; };