@@ -157,6 +157,7 @@ const EditVideo = ({ uid, videoDetails }) => {
157
157
const thumbnailRef = useRef ( null ) ;
158
158
const [ editedDetails , setEditedDetails ] = useState ( videoDetails ) ;
159
159
const [ key , setKey ] = useState ( "key" ) ;
160
+ const router = useRouter ( ) ;
160
161
161
162
useEffect ( ( ) => {
162
163
const newKey = GetUid ( ) ;
@@ -181,6 +182,11 @@ const EditVideo = ({ uid, videoDetails }) => {
181
182
setEditedDetails ( { ...editedDetails , thumbnail : newThumbnail } ) ;
182
183
event . target . value = "" ;
183
184
} ;
185
+
186
+ const Delete = async ( ) => {
187
+ await supabase . from ( "videos" ) . delete ( ) . eq ( "uid" , uid ) ;
188
+ router . push ( "/studio?content=true" ) ;
189
+ } ;
184
190
return (
185
191
< Fragment >
186
192
< Header
@@ -236,34 +242,6 @@ const EditVideo = ({ uid, videoDetails }) => {
236
242
/>
237
243
</ div >
238
244
239
- { /* <div>
240
- <label
241
- htmlFor="playlist"
242
- className="block my-4 text-xl font-medium text-gray-900 dark:text-white"
243
- >
244
- Choose a playlist
245
- </label>
246
- <select
247
- onChange={(e) => {
248
- setVideoPlaylist(e.target.value);
249
- }}
250
- id="playlist"
251
- className="ring-1 bg-transparent text-lg rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full py-3 px-4 text-blue-400 dark:focus:ring-blue-500 outline-none"
252
- >
253
- {userPlaylists?.map((playlist) =>
254
- playlist?.name === videoPlaylist ? (
255
- <option value={playlist?.name} selected key={GetUid()}>
256
- {playlist?.name}
257
- </option>
258
- ) : (
259
- <option value={playlist?.name} key={GetUid()}>
260
- {playlist?.name}
261
- </option>
262
- )
263
- )}
264
- </select>
265
- </div> */ }
266
-
267
245
< div className = "mb-6" >
268
246
< p className = "my-4 flex flex-col text-bold text-lg text-gray-900 dark:text-white" >
269
247
Thumbnail
@@ -326,6 +304,7 @@ const EditVideo = ({ uid, videoDetails }) => {
326
304
327
305
< button
328
306
type = "button"
307
+ onClick = { ( ) => Delete ( ) }
329
308
className = "focus:outline-none text-white bg-red-500 hover:bg-red-600 focus:ring-4 focus:ring-red-300 font-medium rounded-lg w-20 transition px-5 py-2.5 mr-2 mb-2 dark:bg-red-500 dark:hover:bg-red-400 dark:focus:ring-red-900"
330
309
>
331
310
Delete
0 commit comments