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

Added styles to project + rewrote some logic

parent 8f7518e4
...@@ -5,10 +5,11 @@ import shortid from 'shortid'; ...@@ -5,10 +5,11 @@ import shortid from 'shortid';
const router = express.Router(); const router = express.Router();
router.post('/', async (req, res) => { router.post('/', async (req, res) => {
const {username, password} = req.body
try{ try{
const user = new User({ const user = new User({
username: req.body.username, username,
password: req.body.password password
}); });
user.generateToken(); user.generateToken();
await user.save(); await user.save();
......
VITE_BASE_URL=http://localhost:8000/
\ No newline at end of file
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
"@testing-library/react": "^13.4.0", "@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",
"axios": "^1.1.2", "axios": "^1.1.2",
"dotenv": "^16.0.3",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-redux": "^8.0.4", "react-redux": "^8.0.4",
...@@ -7201,11 +7202,11 @@ ...@@ -7201,11 +7202,11 @@
} }
}, },
"node_modules/dotenv": { "node_modules/dotenv": {
"version": "10.0.0", "version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
"integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==",
"engines": { "engines": {
"node": ">=10" "node": ">=12"
} }
}, },
"node_modules/dotenv-expand": { "node_modules/dotenv-expand": {
...@@ -14731,6 +14732,14 @@ ...@@ -14731,6 +14732,14 @@
} }
} }
}, },
"node_modules/react-scripts/node_modules/dotenv": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
"integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==",
"engines": {
"node": ">=10"
}
},
"node_modules/react-transition-group": { "node_modules/react-transition-group": {
"version": "4.4.5", "version": "4.4.5",
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz",
...@@ -22602,9 +22611,9 @@ ...@@ -22602,9 +22611,9 @@
} }
}, },
"dotenv": { "dotenv": {
"version": "10.0.0", "version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
"integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==" "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ=="
}, },
"dotenv-expand": { "dotenv-expand": {
"version": "5.1.0", "version": "5.1.0",
...@@ -27857,6 +27866,13 @@ ...@@ -27857,6 +27866,13 @@
"webpack-dev-server": "^4.6.0", "webpack-dev-server": "^4.6.0",
"webpack-manifest-plugin": "^4.0.2", "webpack-manifest-plugin": "^4.0.2",
"workbox-webpack-plugin": "^6.4.1" "workbox-webpack-plugin": "^6.4.1"
},
"dependencies": {
"dotenv": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
"integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q=="
}
} }
}, },
"react-transition-group": { "react-transition-group": {
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
"@testing-library/react": "^13.4.0", "@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",
"axios": "^1.1.2", "axios": "^1.1.2",
"dotenv": "^16.0.3",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-redux": "^8.0.4", "react-redux": "^8.0.4",
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
.ChatWindow { .ChatWindow {
width: 100%; width: 100%;
height: 87%; height: 87%;
border: 1px solid blueviolet; border: 2px solid rgb(0, 0, 0);
background: rgba(66, 66, 66, 0.527);
border-radius: 20px; border-radius: 20px;
padding: 20px; padding: 20px;
box-sizing: border-box; box-sizing: border-box;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
height: 5vh; height: 5vh;
padding: 15px 0; padding: 15px 0;
background-color: rgba(18, 18, 18, 0.7); background-color: rgba(18, 18, 18, 0.7);
transition: 0.2s;
} }
.headerTitle { .headerTitle {
......
...@@ -10,7 +10,6 @@ import './Register.css'; ...@@ -10,7 +10,6 @@ import './Register.css';
const Register = (props) => { 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();
const [state, setState] = useState({ const [state, setState] = useState({
username: '', username: '',
password: '' password: ''
...@@ -21,9 +20,9 @@ const Register = (props) => { ...@@ -21,9 +20,9 @@ const Register = (props) => {
setState(prevState => ({...prevState, [name]: value})); setState(prevState => ({...prevState, [name]: value}));
}; };
const submitHandler = (e) => { const submitHandler = async (e) => {
e.preventDefault(); e.preventDefault();
dispatch(registerUser({ await dispatch(registerUser({
userData: {...state} userData: {...state}
})); }));
}; };
......
...@@ -20,10 +20,6 @@ ...@@ -20,10 +20,6 @@
animation: pulsate 1.2s linear infinite; animation: pulsate 1.2s linear infinite;
} }
@keyframes pulsate {
50% {color:#fff; text-shadow:0 -1px rgba(0,0,0,.3), 0 0 5px #f03000, 0 0 8px #f80000;}
}
.register_form { .register_form {
display: flex; display: flex;
height: 100%; height: 100%;
......
.Authentication{
padding: 20px;
border-radius: 5px;
background: rgba(0, 0, 0, 0.516)
}
\ No newline at end of file
...@@ -10,31 +10,31 @@ import './Authentication.css'; ...@@ -10,31 +10,31 @@ import './Authentication.css';
const Authentication = () => { const Authentication = () => {
const [state, setState] = useState({ const [authState, setAuthState] = useState({
isRegister: 'active', isRegister: 'active',
isLogin: 'no-active' isLogin: 'no-active'
}); });
const handleChange = (e) => { const handleChange = (e) => {
if(e.target.value === 'register') { if(e.target.value === 'register') {
setState(prevState => ({...prevState, isLogin: 'no-active', isRegister: 'active'})); setAuthState(prevState => ({...prevState, isLogin: 'no-active', isRegister: 'active'}));
} else { } else {
setState(prevState => ({...prevState, isLogin: 'active', isRegister: 'no-active'})); setAuthState(prevState => ({...prevState, isLogin: 'active', isRegister: 'no-active'}));
}; };
}; };
return( return(
<div className="Authentication"> <div className="Authentication">
<div className="Authentication_pagination"> <div className="Authentication_pagination">
</div>
<FormControl> <FormControl>
<RadioGroup aria-labelledby="demo-radio-buttons-group-label" defaultValue="register" name="radio-buttons-group"> <RadioGroup aria-labelledby="demo-radio-buttons-group-label" defaultValue="register" name="radio-buttons-group">
<FormControlLabel onClick={handleChange} sx={{color: 'blueviolet', textShadow: '0px 0px 20px blueviolet'}} value="register" control={<Radio color="secondary"/>} label="Register" /> <FormControlLabel onClick={handleChange} sx={{color: 'white', textShadow: '0px 0px 20px blueviolet'}} value="register" control={<Radio color="secondary"/>} label="Register" />
<FormControlLabel onClick={handleChange} sx={{color: 'blueviolet', textShadow: '0px 0px 20px blueviolet'}} value="login" control={<Radio color="secondary"/>} label="Login" /> <FormControlLabel onClick={handleChange} sx={{color: 'white', textShadow: '0px 0px 20px blueviolet'}} value="login" control={<Radio color="secondary"/>} label="Login" />
</RadioGroup> </RadioGroup>
</FormControl> </FormControl>
</div> <Register registerState={authState.isRegister}/>
<Register registerState={state.isRegister}/> <Login loginState={authState.isLogin}/>
<Login loginState={state.isLogin}/>
</div> </div>
); );
}; };
......
...@@ -22,8 +22,7 @@ const messagesSlice = createSlice({ ...@@ -22,8 +22,7 @@ const messagesSlice = createSlice({
state.users = action.payload; state.users = action.payload;
}, },
deleteOfflineUser: (state, action) => { deleteOfflineUser: (state, action) => {
const index = state.users.findIndex(user => user._id === action.payload); state.users = state.users.filter((user) => user._id !== action.payload)
state.users.splice(index, 1);
} }
} }
}); });
......
...@@ -72,6 +72,7 @@ const usersSlice = createSlice({ ...@@ -72,6 +72,7 @@ const usersSlice = createSlice({
state.registerError = action.payload; state.registerError = action.payload;
}, },
catchLoginError: (state, action) => { catchLoginError: (state, action) => {
console.log(action.payload);
state.loginError = action.payload; state.loginError = action.payload;
}, },
globalError: (state, action) => { globalError: (state, action) => {
......
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