diff --git a/build.zip b/build.zip index dc73e00..a48fb4d 100644 Binary files a/build.zip and b/build.zip differ diff --git a/src/App.tsx b/src/App.tsx index 0337d41..5c87bc2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -26,15 +26,12 @@ const App: React.FC = () => { const { handleCurrentCard } = cardSlice.actions; const { handleChangeLanguage } = languageSlice.actions; const { cards, currentCard } = useAppSelector((state) => state.cardReducer); - const { data } = useAppSelector((state) => state.sessionReducer) - useEffect(() => { dispatch(fetchCards()); dispatch(handleChangeLanguage(cookies.get("i18next"))); }, []); - const handleCards = (card: ICards) => { dispatch(handleCurrentCard(card)); history.push("/connect-page"); @@ -64,8 +61,8 @@ const App: React.FC = () => { - {currentCard ? - (
+ {currentCard ? ( +
@@ -73,14 +70,14 @@ const App: React.FC = () => {
- ) : } + ) : ( + + )} - {data ? ( - ) : } ); diff --git a/src/components/Main/Main.tsx b/src/components/Main/Main.tsx index a8eb1ae..3db74f0 100644 --- a/src/components/Main/Main.tsx +++ b/src/components/Main/Main.tsx @@ -1,5 +1,5 @@ import "./main.css"; -import { useState, useEffect } from "react"; +import { useEffect, useState } from "react"; import { motion, AnimatePresence } from "framer-motion"; import { PopupConnect } from "../popupConnect/popupConnect"; @@ -8,18 +8,27 @@ import { popupAnimation } from "../../utils/animationProps"; import { useAppDispatch, useAppSelector } from "../../hooks/redux"; import { createSession, - connectSession, } from "../../store/reducers/ActionCreator"; -import { useHistory } from "react-router"; export const Main: React.FC = ({ visible, setVisible }) => { const [value, setValue] = useState(""); const dispatch = useAppDispatch(); const { popup1, popup2 } = visible; - const { currentCard, isLoading } = useAppSelector( + const { currentCard } = useAppSelector( (state) => state.cardReducer ); + const { isLoading } = useAppSelector((state) => state.sessionReducer) + + useEffect(() => { + return () => { + setVisible({ + popup1: true, + popup2: false, + }) + } + }, []) + @@ -52,9 +61,7 @@ export const Main: React.FC = ({ visible, setVisible }) => { dispatch(connectSession(value))} visible={visible} setVisible={setVisible} > diff --git a/src/components/PopupShare/PopupShare.tsx b/src/components/PopupShare/PopupShare.tsx index 92fe4ed..3e245b3 100644 --- a/src/components/PopupShare/PopupShare.tsx +++ b/src/components/PopupShare/PopupShare.tsx @@ -2,11 +2,14 @@ import './sharePopup.css' import { useState, useEffect } from 'react' import { TSidebarPopup } from '../../utils/types' import { useTranslation } from 'react-i18next' +import { useAppSelector } from '../../hooks/redux' + +export const PopupShare: React.FC = ({ setClose }) => { + + const { id } = useAppSelector((state) => state.sessionReducer); -export const PopupShare: React.FC = ({ setClose, data }) => { const [copy, setCopy] = useState(false) - console.log(data) function copyLink() { navigator.clipboard.writeText(window.location.href) @@ -20,7 +23,7 @@ export const PopupShare: React.FC = ({ setClose, data }) => { useEffect(() => () => setCopy(false), []); - const {t} = useTranslation(); + const { t } = useTranslation(); return ( @@ -31,7 +34,7 @@ export const PopupShare: React.FC = ({ setClose, data }) => {
{t('popup-control-code')} - +
diff --git a/src/components/playerComponent/playerComponent.tsx b/src/components/playerComponent/playerComponent.tsx index 7f5d987..f9dfc37 100644 --- a/src/components/playerComponent/playerComponent.tsx +++ b/src/components/playerComponent/playerComponent.tsx @@ -1,33 +1,34 @@ import "./playerStyles.css"; import { useParams } from "react-router-dom"; -import React, { } from "react"; +import React, { useEffect } from "react"; import { Sidebar } from "../sidebar/sidebar"; -import { useAppSelector } from "../../hooks/redux"; +import { connectSession } from "../../store/reducers/ActionCreator"; +import { useAppDispatch, useAppSelector } from "../../hooks/redux"; type link = { id: string; }; -export const PlayerComponent: React.FC = ({ closeStream, dispatch }) => { +export const PlayerComponent: React.FC = ({ closeStream }) => { const { id } = useParams(); + const dispatch = useAppDispatch(); + useEffect(() => { + dispatch(connectSession(id)); + }, []); - const { data } = useAppSelector((state) => state.sessionReducer); - + const { url } = useAppSelector((state) => state.sessionReducer); return ( <> - + ); }; diff --git a/src/components/popupConnect/popupConnect.tsx b/src/components/popupConnect/popupConnect.tsx index 4a1cb54..7ac4ffd 100644 --- a/src/components/popupConnect/popupConnect.tsx +++ b/src/components/popupConnect/popupConnect.tsx @@ -14,9 +14,8 @@ export const PopupConnect: React.FC = ({ const handleConnect = () => { onConnect().then((res: any) => { if (!res.error) { - history.push(`/stream/${res.payload.connection_code}`); + history.push(`/stream/${res.payload.session_id}`); } else { - console.log(res) alert(res.payload); } }); diff --git a/src/components/popupConnectEx/popupConnectEx.tsx b/src/components/popupConnectEx/popupConnectEx.tsx index 8ae9c60..cbe0b51 100644 --- a/src/components/popupConnectEx/popupConnectEx.tsx +++ b/src/components/popupConnectEx/popupConnectEx.tsx @@ -5,24 +5,15 @@ import { useTranslation } from "react-i18next"; export const PopupConnectEx: React.FC = ({ setVisible, - onConnect, logo, setValue, value, - isLoading, }) => { const history = useHistory(); const { t } = useTranslation(); const handleConnect = () => { - onConnect().then((res: any) => { - console.log(res); - if (!res.error) { - history.push(`/stream/${res.payload.connection_code}`); - } else { - alert(res.error.message); - } - }); + history.push(`/stream/${value}`); }; return ( @@ -37,10 +28,10 @@ export const PopupConnectEx: React.FC = ({ >