@@ -18,6 +18,15 @@ export interface CreateDatasetStorageSubscriptionProps {
18
18
unit : UnitAllDetail ;
19
19
}
20
20
21
+ // Define Zod schema for validation
22
+ const productSchema = z . object ( {
23
+ name : z . string ( ) . min ( 1 , "A name is required" ) ,
24
+ allowance : z
25
+ . number ( )
26
+ . min ( 1 , "Allowance must be at least 1" )
27
+ . int ( "Allowance must be an integer" ) ,
28
+ } ) ;
29
+
21
30
export const CreateDatasetStorageSubscription = ( {
22
31
unit,
23
32
} : CreateDatasetStorageSubscriptionProps ) => {
@@ -26,19 +35,10 @@ export const CreateDatasetStorageSubscription = ({
26
35
const queryClient = useQueryClient ( ) ;
27
36
const cost = useGetStorageCost ( ) ;
28
37
29
- // Define Zod schema for validation
30
- const productSchema = z . object ( {
31
- name : z . string ( ) . min ( 1 , "A name is required" ) ,
32
- allowance : z
33
- . number ( )
34
- . min ( 1 , "Allowance must be at least 1" )
35
- . int ( "Allowance must be an integer" ) ,
36
- } ) ;
37
-
38
38
const form = useForm ( {
39
39
defaultValues : {
40
- allowance : 1000 ,
41
40
name : "Dataset Storage" ,
41
+ allowance : 1000 ,
42
42
} ,
43
43
validators : {
44
44
onChange : productSchema ,
@@ -70,8 +70,10 @@ export const CreateDatasetStorageSubscription = ({
70
70
{ ( field ) => (
71
71
< TextField
72
72
autoFocus
73
- error = { field . state . meta . errors . length > 0 }
74
- helperText = { field . state . meta . errors . map ( ( error ) => error ?. message ) [ 0 ] }
73
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
74
+ error = { field . state . meta . errors ?. length > 0 }
75
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
76
+ helperText = { field . state . meta . errors ?. map ( ( error ) => error ?. message ) [ 0 ] }
75
77
label = "Name"
76
78
sx = { { maxWidth : 150 } }
77
79
value = { field . state . value }
@@ -84,8 +86,10 @@ export const CreateDatasetStorageSubscription = ({
84
86
< form . Field name = "allowance" >
85
87
{ ( field ) => (
86
88
< TextField
87
- error = { field . state . meta . errors . length > 0 }
88
- helperText = { field . state . meta . errors . map ( ( error ) => error ?. message ) [ 0 ] }
89
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
90
+ error = { field . state . meta . errors ?. length > 0 }
91
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
92
+ helperText = { field . state . meta . errors ?. map ( ( error ) => error ?. message ) [ 0 ] }
89
93
label = "Allowance"
90
94
slotProps = { { htmlInput : { min : 1 } } }
91
95
sx = { { maxWidth : 100 } }
0 commit comments