Skip to content

Commit cad73f7

Browse files
committed
Bug fixing...
1 parent 97c954f commit cad73f7

File tree

4 files changed

+41
-17
lines changed

4 files changed

+41
-17
lines changed

components/Studio/Dashboard.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const VideoPerformance = () => {
5050
const fetchLatestVideo = async () => {
5151
const {data} = await supabase.from('videos').select().eq('channelRef', currentChannel?.uid).order('timestamp', {ascending: false})
5252
const videos = data;
53+
console.log(videos)
5354
setLatestVideo(videos[data?.length -1 ]);
5455
}
5556
fetchLatestVideo();

components/Studio/Header.jsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ import { useChannelState } from "../../context/ChannelState";
2222
const Header = () => {
2323
const { isSidebar, setIsSidebar, user, videos } = useStateContext();
2424
const { fetchChannelVideos } = useChannelState();
25-
const channelVideos = fetchChannelVideos(videos);
25+
const [channelVideos, setChannelVideos] = useState([]);
26+
useEffect(() => {
27+
const getChannelVideos = async () => {
28+
const videos = await fetchChannelVideos();
29+
console.log(videos)
30+
await setChannelVideos(videos);
31+
};
32+
getChannelVideos();
33+
}, []);
2634
const [hasFocused, setHasFocused] = useState(false);
2735
const [searchString, setSearchString] = useState("");
2836
const router = useRouter();
@@ -106,9 +114,14 @@ const Header = () => {
106114
</div>
107115
<div className="flex items-center">
108116
<Tooltip
109-
element={<VideoCameraIcon onClick={() => {
110-
router.push('/studio/?create=true')
111-
}} className="clickable-icon" />}
117+
element={
118+
<VideoCameraIcon
119+
onClick={() => {
120+
router.push("/studio/?create=true");
121+
}}
122+
className="clickable-icon"
123+
/>
124+
}
112125
hoverText="Create"
113126
/>
114127
<Tooltip

components/Studio/Video/Edit.jsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,26 @@ import Tooltip from "../../Tooltip";
1414
import copy from "clipboard-copy";
1515
import { supabase } from "../../../SupabaseClient";
1616

17-
const Header = ({ uid, setEditedDetails, videoDetails, editedDetails }) => {
17+
const Header = ({
18+
uid,
19+
setEditedDetails,
20+
videoDetails,
21+
url,
22+
editedDetails,
23+
}) => {
1824
const router = useRouter();
1925
const { editDialog, setEditDialog, startLoadingBar } = useChannelState();
2026
const { setLoading, setLoadingProgress } = useStateContext();
21-
const Delete = () => {
22-
console.log("deleted the video ...");
27+
const Delete = async () => {
28+
await supabase.from("videos").delete().eq("uid", uid);
2329
setEditDialog(false);
2430
router.push("/studio?content=true");
2531
};
2632

2733
const resetEditedDetails = () => {
2834
const getPreviousDetails = async () => {
2935
const { data } = await supabase.from("videos").select().eq("uid", uid);
30-
console.log(data)
36+
console.log(data);
3137
setEditedDetails(data[0]);
3238
};
3339
startLoadingBar(setLoading, setLoadingProgress, () => getPreviousDetails());
@@ -37,7 +43,8 @@ const Header = ({ uid, setEditedDetails, videoDetails, editedDetails }) => {
3743
const updateNewDetails = async () => {
3844
const { data } = await supabase
3945
.from("videos")
40-
.update({ ...editedDetails }).select()
46+
.update({ ...editedDetails })
47+
.select()
4148
.eq("uid", uid);
4249
setEditedDetails(data);
4350
};
@@ -88,12 +95,12 @@ const Header = ({ uid, setEditedDetails, videoDetails, editedDetails }) => {
8895
className="flex items-center gap-4 click-show cursor-pointer hover:bg-gray-100 rounded-xl px-2 py-1 dark:hover:bg-white/10"
8996
>
9097
<ArrowDownTrayIcon className="icon" />
91-
<a download href={`${process.env.NEXT_PUBLIC_BASE_URL}`}>
98+
<a href={`${url}`} download>
9299
<span className="lg:block hidden">Download</span>
93100
</a>
94101
</p>
95102
<p
96-
onClick={Delete}
103+
onClick={() => Delete()}
97104
className="flex items-center gap-4 click-show cursor-pointer hover:bg-gray-100 rounded-xl px-2 py-1 dark:hover:bg-white/10"
98105
>
99106
<TrashIcon className="icon" />
@@ -149,12 +156,12 @@ const EditVideo = ({ uid, videoDetails }) => {
149156
const { thumbnailDialog, setThumbnailDialog, GetUid } = useChannelState();
150157
const thumbnailRef = useRef(null);
151158
const [editedDetails, setEditedDetails] = useState(videoDetails);
152-
const [key, setKey] = useState('key');
159+
const [key, setKey] = useState("key");
153160

154161
useEffect(() => {
155162
const newKey = GetUid();
156163
setKey(newKey);
157-
}, [editedDetails])
164+
}, [editedDetails]);
158165

159166
useEffect(() => {
160167
setEditedDetails(videoDetails);
@@ -172,11 +179,12 @@ const EditVideo = ({ uid, videoDetails }) => {
172179
const path = data?.path;
173180
const newThumbnail = `https://lumsrpmlumtfpbbafpug.supabase.co/storage/v1/object/public/thumbnails/${path}`;
174181
setEditedDetails({ ...editedDetails, thumbnail: newThumbnail });
175-
event.target.value = ''
182+
event.target.value = "";
176183
};
177184
return (
178185
<Fragment>
179186
<Header
187+
url={editedDetails?.url}
180188
uid={uid}
181189
setEditedDetails={setEditedDetails}
182190
editedDetails={editedDetails}
@@ -262,7 +270,7 @@ const EditVideo = ({ uid, videoDetails }) => {
262270
</p>
263271
<div className="relative w-80 h-60">
264272
<img
265-
key={key}
273+
key={key}
266274
src={editedDetails?.thumbnail}
267275
className="object-cover rounded-xl w-80 h-44"
268276
alt="thumbnail image"

components/Studio/VideoAutoComplete.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ import {
77
} from "@heroicons/react/24/outline";
88
import { useEffect, useState } from "react";
99
import { useChannelState } from "../../context/ChannelState";
10+
import { useRouter } from "next/router";
1011

1112
export default function VideoAutoComplete({
1213
searchString,
1314
setSearchString,
1415
channelVideos,
1516
}) {
17+
const router = useRouter();
1618
const [filteredVideos, setFilteredVideos] = useState([]);
1719
const getFilteredVideos = () => {
1820
setFilteredVideos(
19-
channelVideos.filter((video) =>
21+
channelVideos?.filter((video) =>
2022
video?.title?.toLowerCase().includes(searchString?.toLowerCase())
2123
)
2224
);
@@ -74,7 +76,7 @@ export default function VideoAutoComplete({
7476
</div>
7577
<p className="flex flex-col">
7678
<span className="text-bold text-[10px]">
77-
{timestamp?.toDateString()}
79+
{new Date(timestamp)?.toDateString()}
7880
</span>
7981
<span className="text-[10px] dark:text-gray-300 text-gray-900">
8082
Published

0 commit comments

Comments
 (0)