This repository has been archived by the owner on Feb 11, 2024. It is now read-only.
forked from thgrund/muxy-frontend
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from toplap/fix/non-uniform-streams
fix: Show streams with non-uniform lengths
- Loading branch information
Showing
2 changed files
with
98 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,54 @@ | ||
import React, { ReactElement, useEffect, useState } from 'react'; | ||
import React, { ReactElement, useEffect, useState } from "react"; | ||
import PerformanceList from "../components/PerformanceList"; | ||
import { MuxyEvents } from "../types"; | ||
import EventHeader from "./EventHeader"; | ||
|
||
function EventPage(): ReactElement { | ||
const [muxyEvents, setMuxyEvents] = useState<MuxyEvents | null>(null); | ||
const [reservedStreamCount, setReservedStreamCount] = useState<number | null>(null); | ||
const [totalStreamCount, setTotalStreamCount] = useState<number | null>(null); | ||
const [muxyEvents, setMuxyEvents] = useState<MuxyEvents | null>(null); | ||
const [reservedStreamCount, setReservedStreamCount] = useState<number | null>( | ||
null | ||
); | ||
const [totalStreamCount, setTotalStreamCount] = useState<number | null>(null); | ||
|
||
const muxyApiKey: string = (process.env.REACT_APP_MUXY_API_KEY as string); | ||
const muxyUrl: string = (process.env.REACT_APP_MUXY_URL as string); | ||
const eventSlug: string = (process.env.REACT_APP_EVENT_SLUG as string); | ||
const muxyApiKey: string = process.env.REACT_APP_MUXY_API_KEY as string; | ||
const muxyUrl: string = process.env.REACT_APP_MUXY_URL as string; | ||
const eventSlug: string = process.env.REACT_APP_EVENT_SLUG as string; | ||
|
||
useEffect(() => { | ||
fetch(`${muxyUrl}/events/?slug=${eventSlug}`, { | ||
method: "get", | ||
headers: new Headers({ | ||
Authorization: `Api-Key ${muxyApiKey}`, | ||
}), | ||
useEffect(() => { | ||
fetch(`${muxyUrl}/events/?slug=${eventSlug}`, { | ||
method: "get", | ||
headers: new Headers({ | ||
Authorization: `Api-Key ${muxyApiKey}`, | ||
}), | ||
}) | ||
.then((res) => res.json()) | ||
.then((data) => { | ||
setMuxyEvents(data); | ||
}) | ||
.then((res) => res.json()) | ||
.then((data) => { | ||
setMuxyEvents(data); | ||
}) | ||
.catch(console.error); | ||
}, [eventSlug]); | ||
.catch(console.error); | ||
}, [eventSlug]); | ||
|
||
const event = muxyEvents?.results[0]; | ||
const event = muxyEvents?.results[0]; | ||
|
||
return ( | ||
<main className="App"> | ||
<EventHeader event={event} reservedStreamCount={reservedStreamCount} totalStreamCount={totalStreamCount}/> | ||
{event && ( | ||
<PerformanceList | ||
slug={event.slug} | ||
eventUrl={event.url} | ||
startsAt={event.starts_at} | ||
endsAt={event.ends_at} | ||
setReservedStreamCount={setReservedStreamCount} | ||
setTotalStreamCount={setTotalStreamCount} | ||
/> | ||
)} | ||
</main> | ||
); | ||
return ( | ||
<main className="App"> | ||
<EventHeader | ||
event={event} | ||
reservedStreamCount={reservedStreamCount} | ||
totalStreamCount={totalStreamCount} | ||
/> | ||
{event && ( | ||
<PerformanceList | ||
slug={event.slug} | ||
eventUrl={event.url} | ||
startsAt={event.starts_at} | ||
endsAt={event.ends_at} | ||
setReservedStreamCount={setReservedStreamCount} | ||
setTotalStreamCount={setTotalStreamCount} | ||
/> | ||
)} | ||
</main> | ||
); | ||
} | ||
|
||
export default EventPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters