From 1ca466a311fe3c24f5c70c39d28a380b45df1f33 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 21 Aug 2023 23:56:40 +0600 Subject: [PATCH 1/6] fix safari routing --- package-lock.json | 16 ++++++++++++++++ package.json | 4 +++- src/features/Function/ui/FunctionBlock.tsx | 2 ++ src/main.tsx | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 1b882d4..e0ab024 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,6 +34,7 @@ "eslint": "^8.38.0", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.3.4", + "husky": "^8.0.3", "jsdom": "^22.1.0", "typescript": "^5.0.2", "vite": "^4.3.9", @@ -5401,6 +5402,21 @@ "node": ">=10.17.0" } }, + "node_modules/husky": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", + "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", + "dev": true, + "bin": { + "husky": "lib/bin.js" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/iconv-lite": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", diff --git a/package.json b/package.json index 50524cb..6c07279 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "dev": "vite", "build": "tsc && vite build", "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", - "preview": "vite preview" + "preview": "vite preview", + "prepare": "husky install" }, "dependencies": { "@auth0/auth0-react": "^2.1.1", @@ -36,6 +37,7 @@ "eslint": "^8.38.0", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.3.4", + "husky": "^8.0.3", "jsdom": "^22.1.0", "typescript": "^5.0.2", "vite": "^4.3.9", diff --git a/src/features/Function/ui/FunctionBlock.tsx b/src/features/Function/ui/FunctionBlock.tsx index c795b7b..2f0de96 100644 --- a/src/features/Function/ui/FunctionBlock.tsx +++ b/src/features/Function/ui/FunctionBlock.tsx @@ -56,6 +56,8 @@ export const FunctionBlock: React.FC = ({ func }) => { : setCurrentIcon(func.icon); } + console.log(func.link); + return ( From e3cff6a9b0fec639ef530594c114fbe52c3f19d3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Aug 2023 14:15:14 +0600 Subject: [PATCH 2/6] fix correct fetching rooms --- src/entities/room/api/useAccessRooms.tsx | 33 ++++++++ src/entities/room/api/useMyRooms.tsx | 33 ++++++++ src/pages/Lobby/Lobby.tsx | 4 +- src/widgets/RoomsList.tsx | 103 +++++++++++++++-------- 4 files changed, 133 insertions(+), 40 deletions(-) create mode 100644 src/entities/room/api/useAccessRooms.tsx create mode 100644 src/entities/room/api/useMyRooms.tsx diff --git a/src/entities/room/api/useAccessRooms.tsx b/src/entities/room/api/useAccessRooms.tsx new file mode 100644 index 0000000..838d474 --- /dev/null +++ b/src/entities/room/api/useAccessRooms.tsx @@ -0,0 +1,33 @@ +import { useState, useEffect } from 'react'; +import axios, { AxiosError } from 'axios'; +import type { IRoom } from './models'; +import { useAuth0 } from "@auth0/auth0-react"; + +export const useAccessRooms = () => { + const [accessRooms, setAccessRooms] = useState([]); + const [accessLoading, setAccessLoading] = useState(false); + const [accessError, setAccessError] = useState(''); + const { user } = useAuth0(); + + const API = String(import.meta.env.VITE_API); + + async function getRooms() { + try { + setAccessError(''); + setAccessLoading(true); + const response = await axios.get(`${API}/user_channels/available/${user?.email}`); + setAccessRooms(response.data as any); + setAccessLoading(false); + } catch (e: unknown) { + const error = e as AxiosError; + setAccessLoading(false); + setAccessError(error.message); + } + } + + useEffect(() => { + getRooms(); + }, []); + + return { accessRooms, accessLoading, accessError } +} diff --git a/src/entities/room/api/useMyRooms.tsx b/src/entities/room/api/useMyRooms.tsx new file mode 100644 index 0000000..9db1a16 --- /dev/null +++ b/src/entities/room/api/useMyRooms.tsx @@ -0,0 +1,33 @@ +import { useState, useEffect } from 'react'; +import axios, { AxiosError } from 'axios'; +import type { IRoom } from './models'; +import { useAuth0 } from "@auth0/auth0-react"; + +export const useMyRooms = () => { + const [myRooms, setMyRooms] = useState([]); + const [myLoading, setMyLoading] = useState(false); + const [myError, setMyError] = useState(''); + const { user } = useAuth0(); + + const API = String(import.meta.env.VITE_API); + + async function getRooms() { + try { + setMyError(''); + setMyLoading(true); + const response = await axios.get(`${API}/user_channels/my/${user?.email}`); + setMyRooms(response.data as any); + setMyLoading(false); + } catch (e: unknown) { + const error = e as AxiosError; + setMyLoading(false); + setMyError(error.message); + } + } + + useEffect(() => { + getRooms(); + }, []); + + return { myRooms, myLoading, myError } +} diff --git a/src/pages/Lobby/Lobby.tsx b/src/pages/Lobby/Lobby.tsx index 1e3b49a..2ace995 100644 --- a/src/pages/Lobby/Lobby.tsx +++ b/src/pages/Lobby/Lobby.tsx @@ -2,14 +2,12 @@ import React from 'react'; import { observer } from 'mobx-react-lite'; import navbarState from './store/navbarState'; import roomsFormState from './store/roomsFormState'; -import { useRoomsList } from '../../entities/room/api/useRoomsList'; import Header from '../../widgets/layout/Header'; import Navbar from '../../widgets/layout/Navbar'; import { CreateRoomForm } from '../../features/createRoom'; import RoomsList from '../../widgets/RoomsList'; const Lobby: React.FC = observer(() => { - const { rooms, loading, error } = useRoomsList(); const roomsFormStateLS = localStorage.getItem("trigger"); @@ -18,7 +16,7 @@ const Lobby: React.FC = observer(() => {
{roomsFormState.state || roomsFormStateLS === 'create' && navbarState.state === 'my' ? : null} - + ) }) diff --git a/src/widgets/RoomsList.tsx b/src/widgets/RoomsList.tsx index 30a0582..799071e 100644 --- a/src/widgets/RoomsList.tsx +++ b/src/widgets/RoomsList.tsx @@ -1,5 +1,9 @@ import React, { useState, useEffect } from 'react'; import { IRoom } from '../entities/room/api/models'; +import { useRoomsList } from '../entities/room/api/useRoomsList'; +import { useMyRooms } from '../entities/room/api/useMyRooms'; +import { useAccessRooms } from '../entities/room/api/useAccessRooms'; +import navbarState from '../pages/Lobby/store/navbarState'; import socket from '../pages/Lobby/store/socket'; import styled from 'styled-components'; import { observer } from 'mobx-react-lite'; @@ -52,14 +56,11 @@ const Head = styled.h3` color: var(--grey_2); ` -interface Props { - rooms: IRoom[], - loading?: boolean, - error?: string, -} - -const RoomsList: React.FC = observer(({ rooms, loading, error }) => { +const RoomsList: React.FC = observer(() => { const [searchedRooms, setSearchedRooms] = useState([]); + const { rooms, loading, error } = useRoomsList(); + const { myRooms, myLoading, myError } = useMyRooms(); + const { accessRooms, accessLoading, accessError } = useAccessRooms(); const st = socket.state; @@ -83,42 +84,70 @@ const RoomsList: React.FC = observer(({ rooms, loading, error }) => { Статус Доступ
- {searchedRooms.length > 0 ? - <> - {searchedRooms.map((room: IRoom) => - - )} - - : - <> - {loading ?

loading...

: + {navbarState.state === 'all' ? <> + {searchedRooms.length > 0 ? + <> + {searchedRooms.map((room: IRoom) => + + )} + + : <> - {error ? {error} : + {loading &&

loading...

} + {error && {error}} + {rooms.length > 0 ? <> - {rooms.length > 0 ? + {rooms.map(room => + + )} + : + У Вас пока нет созданных классов + } + + } : + navbarState.state === 'access' ? <> + {searchedRooms.length > 0 ? + <> + {searchedRooms.map((room: IRoom) => + + )} + + : + <> + {accessLoading &&

loading...

} + {accessError && {accessError}} + {accessRooms.length > 0 ? + <> + {accessRooms.map(room => + + )} + : + У Вас пока нет созданных классов + } + + } : + navbarState.state === 'my' ? <> + {searchedRooms.length > 0 ? <> + {searchedRooms.map((room: IRoom) => + + )} : + <> + {myLoading &&

loading...

} + {myError && {myError}} + {myRooms.length > 0 ? <> - {roomsState.state === 'edit' ? - <> - {rooms.map(room => - - )} - - : - <> - {rooms.map(room => - - )} - - } - - : + {roomsState.state === 'edit' ? <> + {myRooms.map(room => + + )} : <> + {myRooms.map(room => + + )} + } : У Вас пока нет созданных классов } - - } - } - + } : null } ) From 0acd073abd72177c6530941f6b65d20d5230e1e3 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 Aug 2023 19:30:23 +0600 Subject: [PATCH 3/6] fix search --- src/features/Search/ui/SearchInput.tsx | 11 ++++++++++- src/widgets/RoomsList.tsx | 16 ++++++++++------ src/widgets/layout/Navbar.tsx | 4 ++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/features/Search/ui/SearchInput.tsx b/src/features/Search/ui/SearchInput.tsx index 178cb9e..016a724 100644 --- a/src/features/Search/ui/SearchInput.tsx +++ b/src/features/Search/ui/SearchInput.tsx @@ -2,6 +2,8 @@ import React, { useRef } from 'react'; import styled from 'styled-components'; import searchIcon from '../../../../public/icons/search.svg'; import socket from '../../../pages/Lobby/store/socket'; +import navbarState from '../../../pages/Lobby/store/navbarState'; +import { useAuth0 } from "@auth0/auth0-react"; const Container = styled.div` display: flex; @@ -27,10 +29,17 @@ const Input = styled.input` export const SearchInput: React.FC = () => { const dataRef = useRef(null); + const { user } = useAuth0(); const st = socket.state; function inputData(data: any) { - st.send(data); + const message = { + filter: navbarState.state, + search_string: data, + user_email: user?.email + } + console.log(message); + st.send(JSON.stringify(message)); st.close(1, "closed"); } diff --git a/src/widgets/RoomsList.tsx b/src/widgets/RoomsList.tsx index 799071e..fc20a22 100644 --- a/src/widgets/RoomsList.tsx +++ b/src/widgets/RoomsList.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import { IRoom } from '../entities/room/api/models'; import { useRoomsList } from '../entities/room/api/useRoomsList'; import { useMyRooms } from '../entities/room/api/useMyRooms'; @@ -64,11 +64,11 @@ const RoomsList: React.FC = observer(() => { const st = socket.state; - useEffect(() => { - st.onopen = function() { - st.send('connected'); - }; - }, []); + // useEffect(() => { + // st.onopen = function() { + // st.send('connected'); + // }; + // }, []); st.onmessage = function(event) { const response = event.data; @@ -76,6 +76,10 @@ const RoomsList: React.FC = observer(() => { console.log(searchedRooms); }; + useEffect(() => { + setSearchedRooms([]); + }, [navbarState.state]) + return (
diff --git a/src/widgets/layout/Navbar.tsx b/src/widgets/layout/Navbar.tsx index c7d9036..4ce7e97 100644 --- a/src/widgets/layout/Navbar.tsx +++ b/src/widgets/layout/Navbar.tsx @@ -7,6 +7,8 @@ import roomsFormState from '../../pages/Lobby/store/roomsFormState.ts'; import roomsState from '../../pages/Lobby/store/roomsState.ts'; import editIcon from '../../../public/icons/edit.svg'; import navbarState from '../../pages/Lobby/store/navbarState.ts'; +import socket from '../../pages/Lobby/store/socket.ts'; +import { useAuth0 } from "@auth0/auth0-react"; const Container = styled.div` display: flex; @@ -70,6 +72,7 @@ const Navbar: React.FC = observer(() => { } function addRoom() { + navbarState.openMy(); if (roomsFormState.state === '' && navbarState.state === 'my') { roomsFormState.openCreateForm(); return 0; @@ -81,6 +84,7 @@ const Navbar: React.FC = observer(() => { } function editRooms() { + navbarState.openMy(); if (navbarState.state === 'my') { if (roomsState.state === '') { roomsState.openEditForm(); From d4381ebdb3f3ac8118eae956054997c75b494e6d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 Aug 2023 19:32:07 +0600 Subject: [PATCH 4/6] fix errors --- src/widgets/layout/Navbar.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/widgets/layout/Navbar.tsx b/src/widgets/layout/Navbar.tsx index 4ce7e97..a41784e 100644 --- a/src/widgets/layout/Navbar.tsx +++ b/src/widgets/layout/Navbar.tsx @@ -7,8 +7,6 @@ import roomsFormState from '../../pages/Lobby/store/roomsFormState.ts'; import roomsState from '../../pages/Lobby/store/roomsState.ts'; import editIcon from '../../../public/icons/edit.svg'; import navbarState from '../../pages/Lobby/store/navbarState.ts'; -import socket from '../../pages/Lobby/store/socket.ts'; -import { useAuth0 } from "@auth0/auth0-react"; const Container = styled.div` display: flex; From a64dec0c83f97883276facaa06540e81ccfb254b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 25 Aug 2023 02:17:24 +0600 Subject: [PATCH 5/6] update readme --- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aeb88aa..47ebc9b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,42 @@ -"#create repo network-class-frontend" -"#review_code" +# Запуск проекта + +git clone https://github.com/Student-Labs-2023/network-class-frontend + +cd network-class-frontend + +npm install + +npm run dev + +Приложение состоит из микрофронтендов, +для корректной требуется после запуска кода из этого репозитория + +перейти по ссылке для клонирования и запуска проекта, который отвечает +за работу видеозвонков + +P.S инструкция для запуска также находится по сслыке + +https://github.com/Student-Labs-2023/network-class-videosdk-client + +# Аккаунты для тестирования +Владелец канала "Кабинет 304" + +email: +test-owner@gmail.com +Password: +Qwe123___ + +Участник канала "Кабинет 304" + +email: +test-student@gmail.com +Password: +Qwe123___ + +примечание: +test-student@gmail.com, test-owner@gmail.com могут искать, подключаться, создавать, редактировать(созданые), удалять каналы + +примечания к комнате 304 +test-student@gmail.com, test-owner@gmail.com могут менять свое имя в канале + +test-owner@gmail.com мождет менять настройки класса \ No newline at end of file From b7a0de2e6d45fc832aa2820922090ab30bc0cf3a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 25 Aug 2023 02:19:51 +0600 Subject: [PATCH 6/6] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 47ebc9b..0c5491e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Запуск проекта -git clone https://github.com/Student-Labs-2023/network-class-frontend +git clone -b main https://github.com/Student-Labs-2023/network-class-frontend cd network-class-frontend