Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/frontend clean up #62

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions packages/frontend/src/routes/dashboard/projects/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "react-calendar/dist/Calendar.css";
import "react-clock/dist/Clock.css";
import LivestreamCard from "../../../../lib/components/LivestreamCard";
import {
fetchPlatforms,
FetchProjectById,
getAccessToken,
sendPeerInvite,
Expand Down Expand Up @@ -59,6 +60,7 @@ const ProjectPage = () => {
const [selectedPlatform, setSelectedPlatform] = useState<
("Twitch" | "Youtube")[]
>([]);
const [platforms, setPlatforms] = useState([]);
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());
const [loading, setLoading] = useState({
project: false,
Expand All @@ -79,16 +81,20 @@ const ProjectPage = () => {
},
};

const UserResponseData = JSON.parse(getDataInCookie("userDataResponse"));

const platforms =
UserResponseData?.data?.platforms?.map(
(platform: "Twitch" | "Youtube") => ({
label: platformStyles[platform]?.label || platform,
value: platform,
icon: platformStyles[platform]?.icon || null,
})
) || [];
const fetchPlatformsData = async () => {
try {
const response = await fetchPlatforms();
response?.data?.platforms
? setPlatforms(response?.data?.platforms)
: setPlatforms([]);
} catch (err: any) {
if (err?.response?.data?.message) {
toast.error(err?.response?.data?.message);
} else {
toast.error(err?.message);
}
}
};

// Fetch project details
const fetchProjectDetails = async () => {
Expand Down Expand Up @@ -140,8 +146,6 @@ const ProjectPage = () => {
}
};

useEffect(() => {}, [livestreamData]);

// Handle livestream creation
const handleCreateLiveStream = async () => {
setLoading((prev) => ({ ...prev, createStream: true }));
Expand Down Expand Up @@ -178,6 +182,7 @@ const ProjectPage = () => {
useEffect(() => {
fetchProjectDetails();
fetchStreams();
fetchPlatformsData();
}, []);

// Helpers
Expand Down