@@ -31,7 +31,7 @@ const projectSchema = yup
3131 / ^ [ a - z A - Z 0 - 9 _ - ] { 3 , 50 } $ / ,
3232 "Only numbers, letters, '-', and '_' are allowed. Spaces are not allowed."
3333 ) ,
34- orgId : yup . string ( ) . required ( )
34+ org_id : yup . string ( ) . required ( )
3535 } )
3636 . required ( ) ;
3737
@@ -42,6 +42,7 @@ export const AddProject = () => {
4242 reset,
4343 control,
4444 handleSubmit,
45+ setError,
4546 formState : { errors, isSubmitting }
4647 } = useForm ( {
4748 resolver : yupResolver ( projectSchema )
@@ -50,7 +51,7 @@ export const AddProject = () => {
5051 const { client, activeOrganization : organization } = useFrontier ( ) ;
5152
5253 useEffect ( ( ) => {
53- reset ( { orgId : organization ?. id } ) ;
54+ reset ( { org_id : organization ?. id } ) ;
5455 } , [ organization , reset ] ) ;
5556
5657 async function onSubmit ( data : FormData ) {
@@ -60,10 +61,16 @@ export const AddProject = () => {
6061 await client . frontierServiceCreateProject ( data ) ;
6162 toast . success ( 'Project added' ) ;
6263 navigate ( { to : '/projects' } ) ;
63- } catch ( { error } : any ) {
64- toast . error ( 'Something went wrong' , {
65- description : error . message
66- } ) ;
64+ } catch ( err : unknown ) {
65+ if ( err instanceof Response && err ?. status === 409 ) {
66+ setError ( 'name' , {
67+ message : 'Project name already exist, please enter unique name'
68+ } ) ;
69+ } else {
70+ toast . error ( 'Something went wrong' , {
71+ description : ( err as Error ) ?. message
72+ } ) ;
73+ }
6774 }
6875 }
6976
@@ -83,6 +90,7 @@ export const AddProject = () => {
8390 // @ts -ignore
8491 src = { cross }
8592 onClick = { ( ) => navigate ( { to : '/projects' } ) }
93+ data-test-id = "frontier-sdk-new-project-close-btn"
8694 style = { { cursor : 'pointer' } }
8795 />
8896 </ Flex >
0 commit comments