-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
134 additions
and
154 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
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
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 |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { Container, Typography, Button, Grid } from "@mui/material"; | ||
import RecordingPage from "./recording"; | ||
import { useEffect, useState } from "react"; | ||
import pb from "../pocketBase"; | ||
|
||
export interface RefVideo { | ||
id: string; | ||
collectionId: string; | ||
tier: string; | ||
video: string; | ||
} | ||
|
||
// eslint-disable-next-line react-refresh/only-export-components | ||
export enum Tier { | ||
Tier1 = 1, | ||
Tier2 = 2, | ||
Tier3 = 3, | ||
Tier4 = 4, | ||
Tier5 = 5, | ||
} | ||
|
||
const HomeSection = () => { | ||
const [selectedTier, setSelectedTier] = useState<Tier | null>(null); | ||
const handleButtonClick = (tier: Tier) => setSelectedTier(tier); | ||
const [refVideos, setRefVideos] = useState<RefVideo[]>([]); | ||
|
||
useEffect(() => { | ||
pb.collection("source_videos") | ||
.getFullList<RefVideo>() | ||
.then((videos) => setRefVideos(videos)); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
{selectedTier ? ( | ||
<RecordingPage | ||
refVideo={refVideos.find( | ||
(video) => video.tier === selectedTier.toString(), | ||
)} | ||
pb={pb} | ||
goBack={setSelectedTier} | ||
/> | ||
) : ( | ||
<Container maxWidth="md"> | ||
<Grid | ||
container | ||
spacing={3} | ||
alignItems="center" | ||
justifyContent="center" | ||
style={{ height: "100vh" }} | ||
> | ||
<Grid item xs={12}> | ||
<Typography variant="h2" color="info" gutterBottom> | ||
Ur fat! | ||
</Typography> | ||
<Typography variant="subtitle1" color="info"> | ||
Explore our amazing features! | ||
</Typography> | ||
</Grid> | ||
<Grid item xs={12} md={4}> | ||
<Button | ||
variant="contained" | ||
color="primary" | ||
fullWidth | ||
onClick={() => handleButtonClick(Tier.Tier1)} | ||
> | ||
Tier 1 | ||
</Button> | ||
</Grid> | ||
<Grid item xs={12} md={4}> | ||
<Button | ||
variant="contained" | ||
color="secondary" | ||
fullWidth | ||
onClick={() => handleButtonClick(Tier.Tier2)} | ||
> | ||
Tier 2 | ||
</Button> | ||
</Grid> | ||
<Grid item xs={12} md={4}> | ||
<Button | ||
variant="contained" | ||
color="info" | ||
fullWidth | ||
onClick={() => handleButtonClick(Tier.Tier3)} | ||
> | ||
Tier 3 | ||
</Button> | ||
</Grid> | ||
</Grid> | ||
</Container> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default HomeSection; |
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,124 +1,11 @@ | ||
import { useContext, useEffect, useState } from "react"; | ||
import { Container, Typography, Button, Grid } from "@mui/material"; | ||
import PocketBase from "pocketbase"; | ||
import RecordingPage from "./recording"; | ||
import { useContext } from "react"; | ||
import { PageContext } from "../context/PageContext"; | ||
import Leaderboard from "../components/Leaderboard"; | ||
import { AuthContext } from "../context/AuthContext"; | ||
import HomeSection from "./home"; | ||
|
||
interface LandingProps { | ||
pb: PocketBase; | ||
} | ||
|
||
export interface RefVideo { | ||
id: string; | ||
collectionId: string; | ||
tier: string; | ||
video: string; | ||
} | ||
|
||
// eslint-disable-next-line react-refresh/only-export-components | ||
export enum Tier { | ||
Tier1 = 1, | ||
Tier2 = 2, | ||
Tier3 = 3, | ||
Tier4 = 4, | ||
Tier5 = 5, | ||
} | ||
|
||
const LandingPage = ({ pb }: LandingProps) => { | ||
const LandingPage = () => { | ||
const page = useContext(PageContext); | ||
const [selectedTier, setSelectedTier] = useState<Tier | null>(null); | ||
const [refVideos, setRefVideos] = useState<RefVideo[]>([]); | ||
const { user } = useContext(AuthContext); | ||
|
||
useEffect(() => { | ||
if (user?.token !== "") { | ||
} | ||
}, [user]); | ||
|
||
useEffect(() => { | ||
const getRefVideos = async () => { | ||
const videos = await pb | ||
.collection("source_videos") | ||
.getFullList<RefVideo>(); | ||
setRefVideos(videos); | ||
}; | ||
getRefVideos(); | ||
}, []); | ||
|
||
const handleButtonClick = (tier: Tier) => { | ||
setSelectedTier(tier); | ||
}; | ||
|
||
return ( | ||
<> | ||
{page === "home" ? ( | ||
<> | ||
{selectedTier ? ( | ||
<RecordingPage | ||
refVideo={refVideos.find( | ||
(video) => video.tier === selectedTier.toString(), | ||
)} | ||
pb={pb} | ||
goBack={setSelectedTier} | ||
/> | ||
) : ( | ||
<Container maxWidth="md"> | ||
<Grid | ||
container | ||
spacing={3} | ||
alignItems="center" | ||
justifyContent="center" | ||
style={{ height: "100vh" }} | ||
> | ||
<Grid item xs={12}> | ||
<Typography variant="h2" color="info" gutterBottom> | ||
Ur fat! | ||
</Typography> | ||
<Typography variant="subtitle1" color="info"> | ||
Explore our amazing features! | ||
</Typography> | ||
</Grid> | ||
<Grid item xs={12} md={4}> | ||
<Button | ||
variant="contained" | ||
color="primary" | ||
fullWidth | ||
onClick={() => handleButtonClick(Tier.Tier1)} | ||
> | ||
Tier 1 | ||
</Button> | ||
</Grid> | ||
<Grid item xs={12} md={4}> | ||
<Button | ||
variant="contained" | ||
color="secondary" | ||
fullWidth | ||
onClick={() => handleButtonClick(Tier.Tier2)} | ||
> | ||
Tier 2 | ||
</Button> | ||
</Grid> | ||
<Grid item xs={12} md={4}> | ||
<Button | ||
variant="contained" | ||
color="info" | ||
fullWidth | ||
onClick={() => handleButtonClick(Tier.Tier3)} | ||
> | ||
Tier 3 | ||
</Button> | ||
</Grid> | ||
</Grid> | ||
</Container> | ||
)} | ||
</> | ||
) : ( | ||
<Leaderboard pb={pb} /> | ||
)} | ||
</> | ||
); | ||
return page === "home" ? <HomeSection /> : <Leaderboard />; | ||
}; | ||
|
||
export default LandingPage; |