@@ -32,19 +32,25 @@ const BasicInfo = () => {
32
32
const { currentChannel } = useChannelState ( ) ;
33
33
34
34
useEffect ( ( ) => {
35
- const fetchDetails = async ( ) => {
36
- const { data : info1 } = await supabase
37
- . from ( "channels" )
38
- . select ( )
39
- . eq ( "uid" , currentChannel ?. uid ) ;
40
- const { data : info2 } = await supabase
41
- . from ( "channelInfo" )
42
- . select ( )
43
- . eq ( "channelRef" , currentChannel ?. uid ) ;
44
- setChannelDetails ( info1 [ 0 ] ) ;
45
- setChannelInfo ( info2 [ 0 ] ) ;
46
- } ;
47
- fetchDetails ( ) ;
35
+ try {
36
+ const fetchDetails = async ( ) => {
37
+ const { data : info1 } = await supabase
38
+ . from ( "channels" )
39
+ . select ( )
40
+ . eq ( "uid" , currentChannel ?. uid ) ;
41
+ const { data : info2 } = await supabase
42
+ . from ( "channelInfo" )
43
+ . select ( )
44
+ . eq ( "channelRef" , currentChannel ?. uid ) ;
45
+ if ( info1 && info2 ) {
46
+ setChannelDetails ( info1 [ 0 ] ) ;
47
+ setChannelInfo ( info2 [ 0 ] ) ;
48
+ }
49
+ } ;
50
+ fetchDetails ( ) ;
51
+ } catch {
52
+ ( err ) => console . log ( err ) ;
53
+ }
48
54
} , [ ] ) ;
49
55
50
56
const Save = async ( ) => {
@@ -71,6 +77,7 @@ const BasicInfo = () => {
71
77
Name
72
78
</ lable >
73
79
< input
80
+ spellCheck = { false }
74
81
id = "channelName"
75
82
className = "input dark:text-gray-200"
76
83
value = { channelDetails ?. channelName }
@@ -90,6 +97,7 @@ const BasicInfo = () => {
90
97
Display Name
91
98
</ lable >
92
99
< input
100
+ spellCheck = { false }
93
101
id = "channelDisplayName"
94
102
className = "input dark:text-gray-200"
95
103
value = { channelDetails ?. channelDisplayName }
@@ -167,23 +175,29 @@ const BasicInfo = () => {
167
175
) ;
168
176
} ;
169
177
170
- const AddNew = ( { newLink, links, setShowAddDialog, channelRef, setLinks, setNewLink } ) => {
178
+ const AddNew = ( {
179
+ newLink,
180
+ links,
181
+ setShowAddDialog,
182
+ channelRef,
183
+ setLinks,
184
+ setNewLink,
185
+ } ) => {
171
186
const Remove = ( ) => {
172
187
setNewLink ( { name : "" , url : "" } ) ;
173
188
setShowAddDialog ( false ) ;
174
189
} ;
175
190
176
191
const Add = async ( ) => {
177
192
const { name, url } = newLink ;
178
- const isCorrect = name ?. trim ( ) !== '' && url ?. trim ( ) !== '' ;
179
- console . log ( isCorrect )
193
+ const isCorrect = name ?. trim ( ) !== "" && url ?. trim ( ) !== "" ;
180
194
if ( isCorrect ) {
181
195
// adding from the backend
182
- await supabase . from ( ' socialLinks' ) . insert ( {
183
- name : name ,
196
+ await supabase . from ( " socialLinks" ) . insert ( {
197
+ name : name ,
184
198
url : url ,
185
- channelRef : channelRef
186
- } )
199
+ channelRef : channelRef ,
200
+ } ) ;
187
201
setLinks ( [ ...links , newLink ] ) ;
188
202
setNewLink ( { name : "" , url : "" } ) ;
189
203
setShowAddDialog ( false ) ;
@@ -193,12 +207,15 @@ const AddNew = ({ newLink, links, setShowAddDialog, channelRef, setLinks, setNew
193
207
< div className = "flex items-center gap-2 w-full" >
194
208
< Bars2Icon className = "icon" />
195
209
< input
210
+ spellCheck = { false }
196
211
className = "input flex-1 dark:text-gray-200"
197
212
placeholder = "Link title (required)"
198
213
value = { newLink ?. name }
199
214
onChange = { ( e ) => setNewLink ( { ...newLink , name : e . target . value } ) }
200
215
/>
201
216
< input
217
+ type = 'url'
218
+ spellCheck = { false }
202
219
className = "input flex-1 dark:text-gray-200"
203
220
placeholder = "URL (required)"
204
221
value = { newLink ?. url }
@@ -210,14 +227,18 @@ const AddNew = ({ newLink, links, setShowAddDialog, channelRef, setLinks, setNew
210
227
) ;
211
228
} ;
212
229
213
- const Link = ( { name, url, id, setLinks } ) => {
230
+ const Link = ( { name, url, id, setLinks, channelRef } ) => {
214
231
const [ newName , setNewName ] = useState ( name ) ;
215
232
const [ newUrl , setNewUrl ] = useState ( url ) ;
216
233
const Remove = async ( ) => {
217
234
// deleting from the backend
218
- await supabase . from ( "socialLinks" ) . delete ( ) . eq ( "id" , id ) ;
219
- const { data } = await supabase . from ( "socialLinks" ) . select ( ) ;
220
- setLinks ( data ) ;
235
+ const { data } = await supabase . from ( "socialLinks" ) . delete ( ) . eq ( "id" , id ) ;
236
+ const { data : newLinks } = await supabase
237
+ . from ( "socialLinks" )
238
+ . select ( )
239
+ . eq ( "channelRef" , channelRef ) ;
240
+
241
+ setLinks ( newLinks ) ;
221
242
} ;
222
243
223
244
const Update = async ( ) => {
@@ -236,15 +257,18 @@ const Link = ({ name, url, id, setLinks }) => {
236
257
< div className = "flex items-center gap-2 w-full" >
237
258
< Bars2Icon className = "icon" />
238
259
< input
260
+ spellCheck = { false }
239
261
className = "input flex-1 dark:text-gray-200"
240
262
placeholder = "Link title (required)"
241
263
value = { newName }
242
264
onChange = { ( e ) => setNewName ( e . target . value ) }
243
265
/>
244
266
< input
267
+ spellCheck = { false }
245
268
className = "input flex-1 dark:text-gray-200"
246
269
placeholder = "URL (required)"
247
270
value = { newUrl }
271
+ type = 'url'
248
272
onChange = { ( e ) => setNewUrl ( e . target . value ) }
249
273
/>
250
274
< TrashIcon className = "clickable-icon" onClick = { ( ) => Remove ( ) } />
0 commit comments