@@ -35,11 +35,31 @@ import { MapContainer, TileLayer, Marker, useMap } from "react-leaflet";
35
35
import "leaflet/dist/leaflet.css" ;
36
36
import L from "leaflet" ;
37
37
import { useApproximateCoordinates } from "@/core/hooks/useSites" ;
38
+ import { AxiosError } from "axios" ;
39
+ import Error from "next/error" ;
38
40
39
41
const siteFormSchema = z . object ( {
40
42
name : z . string ( ) . min ( 2 , {
41
43
message : "Site name must be at least 2 characters." ,
42
44
} ) ,
45
+ latitude : z . string ( ) . refine (
46
+ ( val ) => {
47
+ const num = parseFloat ( val ) ;
48
+ return ! isNaN ( num ) && num >= - 90 && num <= 90 ;
49
+ } ,
50
+ {
51
+ message : "Latitude must be a valid number between -90 and 90" ,
52
+ }
53
+ ) ,
54
+ longitude : z . string ( ) . refine (
55
+ ( val ) => {
56
+ const num = parseFloat ( val ) ;
57
+ return ! isNaN ( num ) && num >= - 180 && num <= 180 ;
58
+ } ,
59
+ {
60
+ message : "Longitude must be a valid number between -180 and 180" ,
61
+ }
62
+ ) ,
43
63
} ) ;
44
64
45
65
type SiteFormValues = z . infer < typeof siteFormSchema > ;
@@ -119,7 +139,6 @@ export function CreateSiteForm() {
119
139
const [ loading , setLoading ] = useState ( false ) ;
120
140
const [ error , setError ] = useState < string | null > ( null ) ;
121
141
const [ currentStep , setCurrentStep ] = useState ( 0 ) ;
122
- const router = useRouter ( ) ;
123
142
const queryClient = useQueryClient ( ) ;
124
143
const activeNetwork = useAppSelector ( ( state ) => state . user . activeNetwork ) ;
125
144
const { getApproximateCoordinates, isPending } = useApproximateCoordinates ( ) ;
@@ -309,7 +328,7 @@ export function CreateSiteForm() {
309
328
Optimizing...
310
329
</ >
311
330
) : (
312
- "⭐ Optimize Location "
331
+ "⭐ Optimize Coordinates "
313
332
) }
314
333
</ Button >
315
334
</ div >
0 commit comments