Skip to content

Commit

Permalink
refactor: room create and join validation schema
Browse files Browse the repository at this point in the history
  • Loading branch information
adarshaacharya committed Oct 13, 2021
1 parent 5736eb0 commit 82c05ff
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
2 changes: 2 additions & 0 deletions client/src/_context/room/room.state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ const RoomState: React.FC = ({ children }) => {
type: JOIN_ROOM,
payload: room,
});
message.success('You have joined the room. 🥳');

history.push(`/room/${roomID}`);
});
} catch (error) {
Expand Down
10 changes: 3 additions & 7 deletions client/src/components/CreateRoom/CreateRoom.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Button, Card, Form, Input, message } from 'antd';
import { useSfx } from 'hooks';
import { Button, Card, Form, Input } from 'antd';
import React from 'react';
import { useRoomContext } from '_context/room/room.context';
import styles from './style.module.css';
Expand All @@ -16,12 +15,9 @@ const layout = {

const CreateRoom = () => {
const { createRoom } = useRoomContext();
const { playIpl } = useSfx();

const onFormSubmit = (values: IVal) => {
createRoom(values);
// playIpl();
// message.success('New room created ! 🔥 ');
};

const [form] = Form.useForm();
Expand All @@ -35,7 +31,7 @@ const CreateRoom = () => {
label='Username'
rules={[
{ required: true, message: "Username can't be empty" },
{ max: 8, message: 'Username must be maximum 8 characters.' },
{ max: 20, message: 'Username must be maximum 20 characters.' },
]}
className='py'
>
Expand All @@ -46,7 +42,7 @@ const CreateRoom = () => {
label='Room Name'
rules={[
{ required: true, message: "Room name can't be empty" },
{ max: 8, message: 'Room name must be maximum 8 characters.' },
{ max: 15, message: 'Room name must be maximum 15 characters.' },
]}
className='py'
>
Expand Down
8 changes: 2 additions & 6 deletions client/src/components/JoinRoom/JoinRoom.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Button, Card, Form, Input, message } from 'antd';
import { useSfx } from 'hooks';
import { Button, Card, Form, Input } from 'antd';
import React from 'react';
import { useRoomContext } from '_context/room/room.context';
import styles from './style.module.css';
Expand All @@ -15,12 +14,9 @@ const layout = {

const JoinRoom = () => {
const { joinRoom } = useRoomContext();
const { playIpl } = useSfx();

const onFormSubmit = (values: IVal) => {
joinRoom(values);
message.success('You have joined the room. 🥳');
playIpl();
};

const [form] = Form.useForm();
Expand All @@ -41,7 +37,7 @@ const JoinRoom = () => {
label='Username'
rules={[
{ required: true, message: "Username can't be empty" },
{ max: 8, message: 'Username must be maximum 8 characters.' },
{ max: 20, message: 'Username must be maximum 20 characters.' },
]}
className='py'
>
Expand Down
1 change: 1 addition & 0 deletions server/controllers/code.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const SubmitCode = async (req: Request, res: Response): Promise<void> =>
const output = await Axios.post(uri, data, axiosConfig);
res.status(201).json(output.data);
} catch (err) {
// @ts-ignore
console.log(err.message);
res.status(500).json({ msg: 'Server error' });
}
Expand Down

0 comments on commit 82c05ff

Please sign in to comment.