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

Fix/update line exit btn #96

Merged
merged 6 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 additions & 2 deletions src/components/manage-productions/manage-productions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const VerifyButtons = styled.div`
const Button = styled(ActionButton)`
margin: 0 1rem 0 0;
`;

const StyledBackBtnIcon = styled.div`
margin: 0 0 3rem 0;
`;
Expand Down Expand Up @@ -108,12 +109,11 @@ export const ManageProductions = () => {

setRemoveId(parseInt(value.productionId, 10));
};
// TODO return button

return (
<Container>
<StyledBackBtnIcon>
<NavigateToRootButton />
<NavigateToRootButton resetOnExit={() => null} />
</StyledBackBtnIcon>
<DisplayContainerHeader>Remove Production</DisplayContainerHeader>
<FormLabel>
Expand Down
14 changes: 12 additions & 2 deletions src/components/navigate-to-root-button/navigate-to-root-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ const StyledBackBtn = styled(ActionButton)`
width: 4rem;
`;

export const NavigateToRootButton = () => {
export const NavigateToRootButton = ({
resetOnExit,
}: {
resetOnExit: () => void | null;
malmen237 marked this conversation as resolved.
Show resolved Hide resolved
}) => {
const navigate = useNavigate();

return (
<StyledBackBtn type="button" onClick={() => navigate("/")}>
<StyledBackBtn
type="button"
onClick={() => {
navigate("/");
resetOnExit();
}}
>
<BackArrow />
</StyledBackBtn>
);
Expand Down
21 changes: 10 additions & 11 deletions src/components/production-line/production-line.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from "@emotion/styled";
import { FC, useCallback, useEffect, useState } from "react";
import { useNavigate, useParams } from "react-router-dom";
import { useParams } from "react-router-dom";
import { useGlobalState } from "../../global-state/context-provider.tsx";
import { useAudioInput } from "./use-audio-input.ts";
import { useRtcConnection } from "./use-rtc-connection.ts";
Expand All @@ -26,6 +26,7 @@ import { useLinePolling } from "./use-line-polling.ts";
import { useFetchProduction } from "../landing-page/use-fetch-production.ts";
import { useIsLoading } from "./use-is-loading.ts";
import { useCheckBadLineData } from "./use-check-bad-line-data.ts";
import { NavigateToRootButton } from "../navigate-to-root-button/navigate-to-root-button.tsx";

const TempDiv = styled.div`
padding: 1rem 0;
Expand All @@ -41,10 +42,6 @@ const SmallText = styled.span`
font-size: 1.6rem;
`;

const ButtonWrapper = styled.span`
margin: 0 2rem 0 0;
`;

const ButtonIcon = styled.div`
width: 2.5rem;
display: inline-block;
Expand All @@ -58,10 +55,13 @@ const UserControlBtn = styled(ActionButton)`
text-align: left;
`;

const StyledBackBtnIcon = styled.span`
malmen237 marked this conversation as resolved.
Show resolved Hide resolved
margin: 0 2rem 0 0;
`;

export const ProductionLine: FC = () => {
const { productionId: paramProductionId, lineId: paramLineId } = useParams();
const [{ joinProductionOptions }, dispatch] = useGlobalState();
const navigate = useNavigate();
const [isInputMuted, setIsInputMuted] = useState(true);
const [isOutputMuted, setIsOutputMuted] = useState(false);

Expand All @@ -87,8 +87,7 @@ export const ProductionLine: FC = () => {
type: "UPDATE_JOIN_PRODUCTION_OPTIONS",
payload: null,
});
navigate("/");
}, [dispatch, navigate]);
}, [dispatch]);

useLineHotkeys({
muteInput,
Expand Down Expand Up @@ -153,9 +152,9 @@ export const ProductionLine: FC = () => {
return (
<>
<HeaderWrapper>
<ButtonWrapper>
<ActionButton onClick={exit}>Exit</ActionButton>
</ButtonWrapper>
<StyledBackBtnIcon>
<NavigateToRootButton resetOnExit={exit} />
</StyledBackBtnIcon>
{!loading && production && line && (
<DisplayContainerHeader>
<SmallText>Production:</SmallText> {production.name}{" "}
Expand Down
Loading