@@ -25,14 +25,16 @@ export interface EditModalProps {
2525}
2626
2727const EditModal = ( { open, onClose, config } : EditModalProps ) : JSX . Element => {
28- console . log ( "config" , config )
2928 const [ name , setName ] = useState ( config ?. name || "" )
3029 const [ seoTitle , setSeoTitle ] = useState ( config ?. seo ?. title || "" )
3130 const [ seoDescription , setSeoDescription ] = useState ( config ?. seo ?. description || "" )
3231 const [ seoMedia , setSeoMedia ] = useState ( config ?. seo ?. media || "" )
3332 const [ webDestValue , setWebDestValue ] = useState ( config ?. destinations ?. find ( dest => dest . platform === "web" ) ?. value || "" )
33+ const [ webEnabled , setWebEnabled ] = useState ( ! ! config ?. destinations ?. find ( dest => dest . platform === "web" ) ?. value )
3434 const [ iosDestValue , setIosDestValue ] = useState ( config ?. destinations ?. find ( dest => dest . platform === "ios" ) ?. value || "" )
35+ const [ iosEnabled , setIosEnabled ] = useState ( ! ! config ?. destinations ?. find ( dest => dest . platform === "ios" ) ?. value )
3536 const [ androidDestValue , setAndroidDestValue ] = useState ( config ?. destinations ?. find ( dest => dest . platform === "android" ) ?. value || "" )
37+ const [ androidEnabled , setAndroidEnabled ] = useState ( ! ! config ?. destinations ?. find ( dest => dest . platform === "android" ) ?. value )
3638
3739 const [ error , setError ] = useState ( "" )
3840 const [ isLoading , setIsLoading ] = useState ( false )
@@ -152,14 +154,13 @@ const EditModal = ({ open, onClose, config }: EditModalProps): JSX.Element => {
152154
153155 < Box my = { 2 } >
154156 < Typography variant = "subtitle1" > Destinations</ Typography >
155- { /* todo: better check here */ }
156- { ! webDestValue && < IconButton onClick = { ( ) => setWebDestValue ( "https://" ) } > < Public color = "primary" /> </ IconButton > }
157- { ! iosDestValue && < IconButton onClick = { ( ) => setIosDestValue ( "https://" ) } > < PhoneIphone color = "primary" /> </ IconButton > }
158- { ! androidDestValue && < IconButton onClick = { ( ) => setAndroidDestValue ( "https://" ) } > < Android color = "primary" /> </ IconButton > }
159-
160- { webDestValue && < Destination platform = "web" value = { webDestValue } onChange = { val => setWebDestValue ( val ) } /> }
161- { iosDestValue && < Destination platform = "ios" value = { iosDestValue } onChange = { val => setIosDestValue ( val ) } /> }
162- { androidDestValue && < Destination platform = "android" value = { androidDestValue } onChange = { val => setAndroidDestValue ( val ) } /> }
157+ { ! webEnabled && < IconButton onClick = { ( ) => { setWebEnabled ( true ) ; setWebDestValue ( "https://" ) } } > < Public color = "primary" /> </ IconButton > }
158+ { ! iosEnabled && < IconButton onClick = { ( ) => { setIosEnabled ( true ) ; setIosDestValue ( "https://" ) } } > < PhoneIphone color = "primary" /> </ IconButton > }
159+ { ! androidEnabled && < IconButton onClick = { ( ) => { setAndroidEnabled ( true ) ; setAndroidDestValue ( "https://" ) } } > < Android color = "primary" /> </ IconButton > }
160+
161+ { ( webDestValue || webEnabled ) && < Destination platform = "web" value = { webDestValue } onRemove = { ( ) => { setWebEnabled ( false ) ; setWebDestValue ( "" ) } } onChange = { val => setWebDestValue ( val ) } /> }
162+ { ( iosDestValue || iosEnabled ) && < Destination platform = "ios" value = { iosDestValue } onRemove = { ( ) => { setIosEnabled ( false ) ; setIosDestValue ( "" ) } } onChange = { val => setIosDestValue ( val ) } /> }
163+ { ( androidDestValue || androidEnabled ) && < Destination platform = "android" value = { androidDestValue } onRemove = { ( ) => { setAndroidEnabled ( false ) ; setAndroidDestValue ( "" ) } } onChange = { val => setAndroidDestValue ( val ) } /> }
163164
164165 </ Box >
165166
0 commit comments