-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Web2Bizz/dev-da-b1rmuda
refactoring
- Loading branch information
Showing
13 changed files
with
252 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
VITE_API_URL='http://localhost:3000/api' | ||
VITE_API_URL='http://localhost:3000' | ||
VITE_CLIENT_URL='http://localhost:5173' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,43 @@ | ||
import { Button } from "antd"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { roomAPI } from "../../entitys/Room/api/service.js"; | ||
import { Button } from 'antd' | ||
import { useState } from 'react' | ||
import { useNavigate } from 'react-router-dom' | ||
import { roomAPI } from '../../entitys/Room/api/service.js' | ||
import { ModalJoin } from '../../widgets/index.js' | ||
|
||
const HomePage = () => { | ||
const navigate = useNavigate(); | ||
const [createRoom, {}] = roomAPI.useCreateRoomMutation(); | ||
const navigate = useNavigate() | ||
const [createRoom, {}] = roomAPI.useCreateRoomMutation() | ||
const [isModalJoin, setIsModalJoin] = useState(false) | ||
|
||
const onCreateRoomClick = async () => { | ||
try { | ||
const response = await createRoom(); | ||
if (response.error) { | ||
// Обработка ошибки, если она есть | ||
console.error("Ошибка при создании комнаты:", data.roomCode.error); | ||
} else { | ||
// Переходим на страницу лобби с roomCode, если все в порядке | ||
const { roomCode } = response.data; | ||
navigate(`/lobby/${roomCode}`); | ||
} | ||
} catch (error) { | ||
console.error("Ошибка при создании комнаты:", error); | ||
} | ||
}; | ||
const onCreateRoomClick = async () => { | ||
try { | ||
const response = await createRoom() | ||
if (response.error) { | ||
console.error('Ошибка при создании комнаты:', data.roomCode.error) | ||
} else { | ||
const { roomCode } = response.data | ||
navigate(`/lobby/${roomCode}`) | ||
} | ||
} catch (error) { | ||
console.error('Ошибка при создании комнаты:', error) | ||
} | ||
} | ||
|
||
return ( | ||
<div className="flex items-center flex-col gap-5"> | ||
<h1 className="mb-20">Опасные слова</h1> | ||
return ( | ||
<> | ||
<div className='flex items-center flex-col gap-5'> | ||
<h1 className='mb-20'>Опасные слова</h1> | ||
|
||
<Button type="primary" onClick={onCreateRoomClick}> | ||
Создать комнату | ||
</Button> | ||
<Button type="primary">Присоединиться</Button> | ||
<h1>Главный разраб на этой свиноферме⚡</h1> | ||
<img width={300} src="/1.jpg" /> | ||
</div> | ||
); | ||
}; | ||
<Button type='primary' onClick={onCreateRoomClick}> | ||
Создать комнату | ||
</Button> | ||
<Button type='primary' onClick={() => setIsModalJoin(true)}> | ||
Присоединиться | ||
</Button> | ||
<ModalJoin isModalJoin={isModalJoin} setIsModalJoin={setIsModalJoin} /> | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
export default HomePage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Button, Input, Modal } from 'antd' | ||
import { useState } from 'react' | ||
import { useNavigate } from 'react-router-dom' | ||
|
||
export const ModalJoin = ({ isModalJoin, setIsModalJoin }) => { | ||
const [value, setValue] = useState() | ||
const navigate = useNavigate() | ||
|
||
const handleCancel = () => { | ||
setIsModalJoin(false) | ||
} | ||
|
||
const handleConnect = () => { | ||
navigate(`/lobby/${value}`) | ||
setIsModalJoin(false) | ||
} | ||
|
||
return ( | ||
<Modal | ||
title='Введите код комнаты' | ||
open={isModalJoin} | ||
onCancel={handleCancel} | ||
footer={[]} | ||
> | ||
<Input value={value} onChange={e => setValue(e.target.value)} /> | ||
<Button className='text-2xl w-full mt-5' onClick={handleConnect}> | ||
Присоединиться | ||
</Button> | ||
</Modal> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const AbsentPage = () => { | ||
return ( | ||
<div className='flex justify-center items-center text-2xl'> | ||
<p>Данной игры не существует</p> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Button } from 'antd' | ||
|
||
export const InviteButton = ({ setIsModalRefer }) => { | ||
const handleReferPeople = () => { | ||
setIsModalRefer(true) | ||
} | ||
|
||
return ( | ||
<Button className='text-2xl' type='primary' onClick={handleReferPeople}> | ||
Пригласить людей | ||
</Button> | ||
) | ||
} |
Oops, something went wrong.