Skip to content

Commit 0daa13d

Browse files
committed
Redirecting user on upload ✅✅✅
1 parent 5dac307 commit 0daa13d

File tree

3 files changed

+13
-32
lines changed

3 files changed

+13
-32
lines changed

components/Studio/UploadVideo.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const UploadVideo = () => {
7878
});
7979
const { path } = data;
8080

81-
await supabase.from("videos").insert({
81+
const {data: videoDetails} = await supabase.from("videos").insert({
8282
uid: videoPath,
8383
url: videoUrl,
8484
thumbnail: thumbnailUrl + path,
@@ -91,10 +91,12 @@ const UploadVideo = () => {
9191
dislikes: [],
9292
channelRef: currentChannel?.uid,
9393
views: [],
94-
});
94+
}).select();
95+
96+
console.log(videoDetails)
9597

9698
e.target.value = "";
97-
router.push("/");
99+
router.push(`/studio/video/${videoDetails[0]?.uid}?edit=true`);
98100
window.location.reload();
99101
});
100102
});

components/Studio/Video/Edit.jsx

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ const EditVideo = ({ uid, videoDetails }) => {
157157
const thumbnailRef = useRef(null);
158158
const [editedDetails, setEditedDetails] = useState(videoDetails);
159159
const [key, setKey] = useState("key");
160+
const router = useRouter();
160161

161162
useEffect(() => {
162163
const newKey = GetUid();
@@ -181,6 +182,11 @@ const EditVideo = ({ uid, videoDetails }) => {
181182
setEditedDetails({ ...editedDetails, thumbnail: newThumbnail });
182183
event.target.value = "";
183184
};
185+
186+
const Delete = async () => {
187+
await supabase.from("videos").delete().eq("uid", uid);
188+
router.push("/studio?content=true");
189+
};
184190
return (
185191
<Fragment>
186192
<Header
@@ -236,34 +242,6 @@ const EditVideo = ({ uid, videoDetails }) => {
236242
/>
237243
</div>
238244

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-
267245
<div className="mb-6">
268246
<p className="my-4 flex flex-col text-bold text-lg text-gray-900 dark:text-white">
269247
Thumbnail
@@ -326,6 +304,7 @@ const EditVideo = ({ uid, videoDetails }) => {
326304

327305
<button
328306
type="button"
307+
onClick={() => Delete()}
329308
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"
330309
>
331310
Delete

components/Video.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default function Video({
3636
const timeAgo = new TimeAgo("en-US");
3737

3838
return (
39-
<div className=" cursor-pointer w-full h-64 my-2 hover:scale-105 transition group">
39+
<div className=" cursor-pointer w-full h-64 my-5 mt-14 hover:scale-105 transition group">
4040
<div className="relative">
4141
<img
4242
src={ thumbnail}

0 commit comments

Comments
 (0)