mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 16:44:48 -07:00
Webatrice: update package.json (#4590)
* update package.json * cleanup Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
This commit is contained in:
parent
533045445a
commit
0d0337f091
17 changed files with 4618 additions and 10629 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import React from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { withRouter, generatePath } from 'react-router-dom';
|
||||
import { useNavigate, useParams, generatePath } from 'react-router-dom';
|
||||
|
||||
import ListItem from '@material-ui/core/ListItem';
|
||||
import Paper from '@material-ui/core/Paper';
|
||||
|
|
@ -17,26 +17,28 @@ import SayMessage from './SayMessage';
|
|||
import './Room.css';
|
||||
|
||||
// @TODO (3)
|
||||
function Room(props) {
|
||||
const Room = (props) => {
|
||||
const { joined, rooms, messages } = props;
|
||||
const navigate = useNavigate();
|
||||
const params = useParams();
|
||||
|
||||
const { joined, match, history, rooms, messages } = props;
|
||||
const roomId = parseInt(match.params.roomId, 0);
|
||||
const roomId = parseInt(params.roomId, 0);
|
||||
const room = rooms[roomId];
|
||||
const roomMessages = messages[roomId];
|
||||
const users = room.userList;
|
||||
|
||||
if (!joined.find(({ roomId: id }) => id === roomId)) {
|
||||
history.push(generatePath(RouteEnum.SERVER));
|
||||
}
|
||||
useEffect(() => {
|
||||
if (!joined.find(({ roomId: id }) => id === roomId)) {
|
||||
navigate(generatePath(RouteEnum.SERVER));
|
||||
}
|
||||
}, [joined]);
|
||||
|
||||
function handleRoomSay({ message }) {
|
||||
const handleRoomSay = ({ message }) => {
|
||||
if (message) {
|
||||
RoomsService.roomSay(roomId, message);
|
||||
}
|
||||
}
|
||||
|
||||
const room = rooms[roomId];
|
||||
|
||||
const roomMessages = messages[roomId];
|
||||
const users = room.userList;
|
||||
|
||||
return (
|
||||
<div className="room-view">
|
||||
<AuthGuard />
|
||||
|
|
@ -98,4 +100,4 @@ const mapStateToProps = state => ({
|
|||
joined: RoomsSelectors.getJoinedRooms(state),
|
||||
});
|
||||
|
||||
export default withRouter(connect(mapStateToProps)(Room));
|
||||
export default connect(mapStateToProps)(Room);
|
||||
|
|
|
|||
|
|
@ -3,22 +3,17 @@ import { Form } from 'react-final-form'
|
|||
|
||||
import { InputAction } from 'components';
|
||||
|
||||
const required = (value) => (value ? undefined : 'Required');
|
||||
|
||||
const SayMessage = (props) => {
|
||||
const { onSubmit } = props
|
||||
return (
|
||||
<Form onSubmit={values => onSubmit(values)}>
|
||||
{({ handleSubmit, form }) => (
|
||||
<form onSubmit={e => {
|
||||
handleSubmit(e)
|
||||
form.restart()
|
||||
}}>
|
||||
<InputAction action="Send" label="Chat" name="message" validate={required}/>
|
||||
</form>
|
||||
)}
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
const SayMessage = ({ onSubmit }) => (
|
||||
<Form onSubmit={onSubmit}>
|
||||
{({ handleSubmit, form }) => (
|
||||
<form onSubmit={e => {
|
||||
handleSubmit(e)
|
||||
form.restart()
|
||||
}}>
|
||||
<InputAction action="Send" label="Chat" name="message" />
|
||||
</form>
|
||||
)}
|
||||
</Form>
|
||||
);
|
||||
|
||||
export default SayMessage;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue