@@ -11,7 +11,7 @@ import { linkToLinkCreateArgs } from '../../../../utils/link.utils';
1111interface UsefulLinkFormModalProps {
1212 open : boolean ;
1313 handleClose : ( ) => void ;
14- clickedLink ?: Link ;
14+ defaulValues ?: Link ;
1515 onSubmit : ( data : LinkCreateArgs [ ] ) => void ;
1616 linkTypes : LinkType [ ] ;
1717 currentLinks : Link [ ] ;
@@ -20,7 +20,7 @@ interface UsefulLinkFormModalProps {
2020const UsefulLinkFormModal = ( {
2121 open,
2222 handleClose,
23- clickedLink ,
23+ defaulValues ,
2424 onSubmit,
2525 linkTypes,
2626 currentLinks
@@ -40,16 +40,16 @@ const UsefulLinkFormModal = ({
4040 } = useForm ( {
4141 resolver : yupResolver ( schema ) ,
4242 defaultValues : {
43- linkTypeName : clickedLink ?. linkType . name ?? '' ,
44- url : clickedLink ?. url ?? ''
43+ linkTypeName : defaulValues ?. linkType . name ?? '' ,
44+ url : defaulValues ?. url ?? ''
4545 }
4646 } ) ;
4747
4848 const onFormSubmit = async ( data : LinkCreateArgs ) => {
4949 try {
5050 const previousLinks = linkToLinkCreateArgs ( currentLinks ) ;
51- const newLinks = clickedLink
52- ? [ ...previousLinks . filter ( ( link ) => link . linkId !== clickedLink . linkId ) , data ]
51+ const newLinks = defaulValues
52+ ? [ ...previousLinks . filter ( ( link ) => link . linkId !== defaulValues . linkId ) , data ]
5353 : [ ...previousLinks , data ] ;
5454 onSubmit ( newLinks ) ;
5555 } catch ( error : unknown ) {
@@ -63,11 +63,11 @@ const UsefulLinkFormModal = ({
6363 < NERFormModal
6464 open = { open }
6565 onHide = { handleClose }
66- title = { ! ! clickedLink ? 'Edit Useful Link' : 'Create Useful Link' }
66+ title = { ! ! defaulValues ? 'Edit Useful Link' : 'Create Useful Link' }
6767 reset = { ( ) => reset ( { linkTypeName : '' } ) }
6868 handleUseFormSubmit = { handleSubmit }
6969 onFormSubmit = { onFormSubmit }
70- formId = { ! ! clickedLink ? 'edit-UsefulLink-form' : 'create-UsefulLink-form' }
70+ formId = { ! ! defaulValues ? 'edit-UsefulLink-form' : 'create-UsefulLink-form' }
7171 showCloseButton
7272 >
7373 < Grid container spacing = { 2 } alignItems = "flex-start" >
0 commit comments