Commit 8869621f authored by Цой Данил's avatar Цой Данил 💬

Added props and their values

parent e4d04c8a
...@@ -3,7 +3,6 @@ import Button from '@mui/material/Button'; ...@@ -3,7 +3,6 @@ import Button from '@mui/material/Button';
import Message from '../Message/Message'; import Message from '../Message/Message';
import './ChatWindow.css'; import './ChatWindow.css';
const ChatWindow = (props) => { const ChatWindow = (props) => {
return ( return (
<div className='window'> <div className='window'>
......
...@@ -8,7 +8,7 @@ import Spinner from "../UI/Spinner/Spinner"; ...@@ -8,7 +8,7 @@ import Spinner from "../UI/Spinner/Spinner";
import './Login.css'; import './Login.css';
const Login = ({loginState}) => { const Login = (props) => {
const {loginError, isLoading} = useSelector(state => state.users, shallowEqual); const {loginError, isLoading} = useSelector(state => state.users, shallowEqual);
const navigate = useNavigate('/'); const navigate = useNavigate('/');
const dispatch = useDispatch(); const dispatch = useDispatch();
...@@ -32,7 +32,7 @@ const Login = ({loginState}) => { ...@@ -32,7 +32,7 @@ const Login = ({loginState}) => {
}; };
return( return(
<div className={loginState}> <div className={props.loginState}>
{isLoading ? <Spinner/> : null} {isLoading ? <Spinner/> : null}
{loginError && <MyAlert alertText={loginError.error}/>} {loginError && <MyAlert alertText={loginError.error}/>}
<Form <Form
......
...@@ -2,11 +2,11 @@ import React from "react"; ...@@ -2,11 +2,11 @@ import React from "react";
import './Message.css'; import './Message.css';
const Message = ({author, message}) => { const Message = (props) => {
return ( return (
<div className="Message"> <div className="Message">
<h3 className="author">{author}:</h3> <h3 className="author">{props.author}:</h3>
<p className="authorMessage">{message}</p> <p className="authorMessage">{props.message}</p>
</div> </div>
); );
}; };
......
...@@ -3,10 +3,10 @@ import { NavLink } from "react-router-dom"; ...@@ -3,10 +3,10 @@ import { NavLink } from "react-router-dom";
import './Navigation.css'; import './Navigation.css';
const Navigation = ({to, end, children}) => { const Navigation = (props) => {
return ( return (
<span className="NavLink"> <span className="NavLink">
<NavLink to={to} end={end}>{children}</NavLink> <NavLink to={props.to} end={props.end}>{props.children}</NavLink>
</span> </span>
); );
}; };
......
import React from 'react'; import React from 'react';
import { Navigate, Outlet } from 'react-router-dom'; import { Navigate, Outlet } from 'react-router-dom';
const ProtectedRoute = ({ isAllowed, redirectedPath, children }) => { const ProtectedRoute = (props) => {
if(!isAllowed) { if(!props.isAllowed) {
return <Navigate to={redirectedPath} replace /> return <Navigate to={props.redirectedPath} replace />
} }
return ( return (
<> <>
{children || <Outlet/>} {props.children || <Outlet/>}
</> </>
); );
}; };
......
...@@ -7,7 +7,7 @@ import Spinner from "../UI/Spinner/Spinner"; ...@@ -7,7 +7,7 @@ import Spinner from "../UI/Spinner/Spinner";
import './Register.css'; import './Register.css';
const Register = ({registerState}) => { const Register = (props) => {
const {registerError, isLoading} = useSelector(state => state.users, shallowEqual); const {registerError, isLoading} = useSelector(state => state.users, shallowEqual);
const dispatch = useDispatch(); const dispatch = useDispatch();
...@@ -21,15 +21,15 @@ const Register = ({registerState}) => { ...@@ -21,15 +21,15 @@ const Register = ({registerState}) => {
setState(prevState => ({...prevState, [name]: value})); setState(prevState => ({...prevState, [name]: value}));
}; };
const submitHandler = async (e) => { const submitHandler = (e) => {
e.preventDefault(); e.preventDefault();
await dispatch(registerUser({ dispatch(registerUser({
userData: {...state} userData: {...state}
})); }));
}; };
return( return(
<div className={registerState}> <div className={props.registerState}>
{isLoading ? <Spinner/> : null} {isLoading ? <Spinner/> : null}
{registerError && <MyAlert alertText={registerError.errors['username'].message}/>} {registerError && <MyAlert alertText={registerError.errors['username'].message}/>}
<Form <Form
......
...@@ -5,7 +5,7 @@ import Avatar from '@mui/material/Avatar'; ...@@ -5,7 +5,7 @@ import Avatar from '@mui/material/Avatar';
import './User.css'; import './User.css';
const User = ({user}) => { const User = (props) => {
const StyledBadge = styled(Badge)(({ theme }) => ({ const StyledBadge = styled(Badge)(({ theme }) => ({
'& .MuiBadge-badge': { '& .MuiBadge-badge': {
backgroundColor: '#44b700', backgroundColor: '#44b700',
...@@ -42,9 +42,9 @@ const User = ({user}) => { ...@@ -42,9 +42,9 @@ const User = ({user}) => {
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }} anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
variant="dot" variant="dot"
> >
<Avatar sx={{ bgcolor: 'blueviolet'}}>{user}</Avatar> <Avatar sx={{ bgcolor: 'blueviolet'}}>{props.user}</Avatar>
</StyledBadge> </StyledBadge>
<p className="username">{user}</p> <p className="username">{props.user}</p>
</div> </div>
); );
}; };
......
...@@ -3,12 +3,12 @@ import User from "../User/User"; ...@@ -3,12 +3,12 @@ import User from "../User/User";
import './UserList.css'; import './UserList.css';
const UserList = ({users}) => { const UserList = (props) => {
return ( return (
<div className="UserList"> <div className="UserList">
<p className="onlineUser">Online users</p> <p className="onlineUser">Online users</p>
{ {
users.map((user, idx) => { props.users.length && props.users.map((user, idx) => {
return ( return (
<User key={user._id + idx} user={user.username}/> <User key={user._id + idx} user={user.username}/>
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment