Skip to content

Commit

Permalink
fix errors lobbyaccess & lobbymy
Browse files Browse the repository at this point in the history
  • Loading branch information
Emil307 committed Aug 3, 2023
1 parent ba850a2 commit a4a6f8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 181 deletions.
86 changes: 2 additions & 84 deletions src/pages/Lobby/LobbyAccess.tsx
Original file line number Diff line number Diff line change
@@ -1,96 +1,14 @@
import React from 'react';
import type { IRoom } from '../../shared/api/models';
import Header from '../../widgets/layout/Header';
import Navbar from '../../widgets/layout/Navbar';
import RoomsList from '../../widgets/RoomsList';

const LobbyAccess: React.FC = () => {
const rooms: IRoom[] = [
{
id: 1,
title: 'Информатика 5 класс',
owner: 'Иванов Иван Иванович',
isActive: true,
},
{
id: 2,
title: 'Математика 7 класс',
owner: 'Морозов Антон Дмитри...',
isActive: true,
},
{
id: 3,
title: 'Английский и язык 7 кла... ',
owner: 'Иванова Мария Ивановна',
isActive: false,
},
{
id: 4,
title: 'Математика 8 класс',
owner: 'Иванова Мария Ивановна',
isActive: false,
},
{
id: 5,
title: 'Математика 8 класс',
owner: 'Иванова Мария Ивановна',
isActive: false,
},
{
id: 6,
title: 'Математика 8 класс',
owner: 'Иванова Мария Ивановна',
isActive: false,
},
{
id: 7,
title: 'Информатика 5 класс',
owner: 'Иванов Иван Иванович',
isActive: true,
},
{
id: 8,
title: 'Математика 7 класс',
owner: 'Морозов Антон Дмитри...',
isActive: true,
},
{
id: 9,
title: 'Английский и язык 7 кла... ',
owner: 'Иванова Мария Ивановна',
isActive: false,
},
{
id: 10,
title: 'Математика 8 класс',
owner: 'Иванова Мария Ивановна',
isActive: false,
},
{
id: 11,
title: 'Математика 8 класс',
owner: 'Иванова Мария Ивановна',
isActive: false,
},
{
id: 12,
title: 'Математика 8 класс',
owner: 'Иванова Мария Ивановна',
isActive: false,
},
{
id: 13,
title: 'Математика 8 класс',
owner: '[email protected]',
isActive: false,
},
];

const LobbyAccess: React.FC = () => {
return (
<>
<Header/>
<Navbar activeLink='access' accessLength={5}/>
<RoomsList rooms={rooms}/>
<RoomsList/>
</>
)
}
Expand Down
100 changes: 3 additions & 97 deletions src/pages/Lobby/LobbyMy.tsx
Original file line number Diff line number Diff line change
@@ -1,107 +1,13 @@
import React, { useEffect } from "react";
import type { IRoom } from "../../shared/api/models";
import Header from "../../widgets/layout/Header";
import Navbar from "../../widgets/layout/Navbar";
import { CreateRoomForm } from "../../features/createRoom/index.ts";
import RoomsList from "../../widgets/RoomsList";
import { observer } from "mobx-react-lite";
import roomsFormState from "./store/roomsFormState.ts";
import { useAuth0 } from "@auth0/auth0-react";
// import { useAuth0 } from "@auth0/auth0-react";

const LobbyMy: React.FC = observer(() => {
const rooms: IRoom[] = [
{
id: 1,
title: "Информатика 5 класс",
owner: "Иванов Иван Иванович",
isActive: true,
},
{
id: 2,
title: "Математика 7 класс",
owner: "Морозов Антон Дмитри...",
isActive: true,
},
{
id: 3,
title: "Английский и язык 7 кла... ",
owner: "Иванова Мария Ивановна",
isActive: false,
},
{
id: 4,
title: "Математика 8 класс",
owner: "Иванова Мария Ивановна",
isActive: false,
},
{
id: 5,
title: "Математика 8 класс",
owner: "Иванова Мария Ивановна",
isActive: false,
},
{
id: 6,
title: "Математика 8 класс",
owner: "Иванова Мария Ивановна",
isActive: false,
},
{
id: 7,
title: "Информатика 5 класс",
owner: "Иванов Иван Иванович",
isActive: true,
},
{
id: 8,
title: "Математика 7 класс",
owner: "Морозов Антон Дмитри...",
isActive: true,
},
{
id: 9,
title: "Английский и язык 7 кла... ",
owner: "Иванова Мария Ивановна",
isActive: false,
},
{
id: 10,
title: "Математика 8 класс",
owner: "Иванова Мария Ивановна",
isActive: false,
},
{
id: 11,
title: "Математика 8 класс",
owner: "Иванова Мария Ивановна",
isActive: false,
},
{
id: 12,
title: "Математика 8 класс",
owner: "Иванова Мария Ивановна",
isActive: false,
},
{
id: 13,
title: "Математика 8 класс",
owner: "[email protected]",
isActive: false,
},
];

const { user, isAuthenticated } = useAuth0();

function filterRooms() {
if (isAuthenticated) {
const myRooms: IRoom[] = rooms.filter((room) => {
return room.owner == user?.name;
});
return myRooms;
}
}

const myRooms: any = filterRooms();

useEffect(() => {
if (localStorage.getItem("trigger") === "create") {
Expand All @@ -113,9 +19,9 @@ const LobbyMy: React.FC = observer(() => {
return (
<>
<Header />
<Navbar activeLink="my" myLength={myRooms?.length} />
<Navbar activeLink="my" />
{roomsFormState.state === "create" ? <CreateRoomForm /> : <></>}
{myRooms ? <RoomsList rooms={myRooms} /> : <>Loading...</>}
<RoomsList />
</>
);
});
Expand Down

0 comments on commit a4a6f8c

Please sign in to comment.