@@ -18,6 +18,15 @@ export interface CreateDatasetStorageSubscriptionProps {
1818 unit : UnitAllDetail ;
1919}
2020
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+
2130export const CreateDatasetStorageSubscription = ( {
2231 unit,
2332} : CreateDatasetStorageSubscriptionProps ) => {
@@ -26,19 +35,10 @@ export const CreateDatasetStorageSubscription = ({
2635 const queryClient = useQueryClient ( ) ;
2736 const cost = useGetStorageCost ( ) ;
2837
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-
3838 const form = useForm ( {
3939 defaultValues : {
40- allowance : 1000 ,
4140 name : "Dataset Storage" ,
41+ allowance : 1000 ,
4242 } ,
4343 validators : {
4444 onChange : productSchema ,
@@ -70,8 +70,10 @@ export const CreateDatasetStorageSubscription = ({
7070 { ( field ) => (
7171 < TextField
7272 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 ] }
7577 label = "Name"
7678 sx = { { maxWidth : 150 } }
7779 value = { field . state . value }
@@ -84,8 +86,10 @@ export const CreateDatasetStorageSubscription = ({
8486 < form . Field name = "allowance" >
8587 { ( field ) => (
8688 < 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 ] }
8993 label = "Allowance"
9094 slotProps = { { htmlInput : { min : 1 } } }
9195 sx = { { maxWidth : 100 } }
0 commit comments