Skip to content

Commit

Permalink
fix shit
Browse files Browse the repository at this point in the history
  • Loading branch information
LinuzJ committed Nov 11, 2023
1 parent b3b32d5 commit e95a22c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dance-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function App() {
>
{auth.token !== "" ? (
<MainDrawerLayout>
<LandingPage />
<LandingPage pb={pb} />
</MainDrawerLayout>
) : (
<Login setAuth={setAuth} pb={pb} />
Expand Down
2 changes: 1 addition & 1 deletion dance-app/src/sections/landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const LandingPage = ({ pb }: LandingProps) => {
)}
</>
) : (
<Leaderboard />
<Leaderboard pb={pb} />
)}
</>
);
Expand Down
21 changes: 10 additions & 11 deletions dance-app/src/sections/recording.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { FC, useRef, useState } from "react";
import { FC, useContext, useRef, useState } from "react";
import { useRecordWebcam } from "react-record-webcam";
import { Recording } from "react-record-webcam/dist/useRecording";
import Drawer from "../components/Drawer";
import Leaderboard from "../components/Leaderboard";
import Submit from "../Submit";
import "../Recording.css";
import { RefVideo } from "./landing";
import Pocketbase from "pocketbase";
import { PageContext } from "../context/PageContext";

enum VideoState {
recording = "recording",
Expand All @@ -16,8 +17,9 @@ const options = {
mimeType: "video/webm;codecs:vp9",
};

const RecordingPage: FC<{ refVideo: RefVideo | undefined }> = ({
const RecordingPage: FC<{ refVideo: RefVideo | undefined; pb: Pocketbase }> = ({
refVideo,
pb,
}) => {
const constraints: { aspectRatio: number; height: number; width: number } = {
aspectRatio: 2.33,
Expand All @@ -35,8 +37,8 @@ const RecordingPage: FC<{ refVideo: RefVideo | undefined }> = ({
recorderOptions: options,
constraints,
});
const page = useContext(PageContext);
const [showVideo, setShowVideo] = useState<VideoState>(VideoState.preview);
const [view, setView] = useState<"record" | "leaderboard">("record");
const recordingRef = useRef<Recording | null>(null);
const hasRecording = recordingRef.current?.previewRef.current?.src;

Expand Down Expand Up @@ -64,10 +66,7 @@ const RecordingPage: FC<{ refVideo: RefVideo | undefined }> = ({
console.log(recordingRef.current);
};
return (
<div className={`App ${view === "leaderboard" ? "view-change" : ""}`}>
<Drawer
onSwitch={() => setView(view === "record" ? "leaderboard" : "record")}
/>
<div className={`App ${page === "leaderboard" ? "view-change" : ""}`}>
<div className="view record-view">
<header
className={`App-header ${showVideo === "recording" ? "hide" : ""}`}
Expand Down Expand Up @@ -110,11 +109,11 @@ const RecordingPage: FC<{ refVideo: RefVideo | undefined }> = ({
</div>
</div>
<div className="view leaderboard-view">
<Leaderboard />
<Leaderboard pb={pb} />
</div>
<footer className="footer">
{recordingRef.current && hasRecording && view === "record" ? (
<Submit tier={1} video={recordingRef.current} />
{recordingRef.current && hasRecording && page === "home" ? (
<Submit tier={1} video={recordingRef.current} pb={pb} />
) : null}
</footer>
</div>
Expand Down

0 comments on commit e95a22c

Please sign in to comment.