-
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.
- Loading branch information
1 parent
a41e456
commit 796c363
Showing
12 changed files
with
127 additions
and
46 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
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,21 @@ | ||
import { useState } from 'react'; | ||
import AuthContext from '../context/index.jsx'; | ||
|
||
// eslint-disable-next-line react/prop-types | ||
const AuthProvider = ({ children }) => { | ||
const [loggedIn, setLoggedIn] = useState(false); | ||
|
||
const logIn = () => setLoggedIn(true); | ||
const logOut = () => { | ||
localStorage.removeItem('username'); | ||
setLoggedIn(false); | ||
}; | ||
|
||
return ( | ||
<AuthContext.Provider value={{ loggedIn, logIn, logOut }}> | ||
{children} | ||
</AuthContext.Provider> | ||
); | ||
}; | ||
|
||
export default AuthProvider; |
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,5 @@ | ||
import { createContext } from 'react'; | ||
|
||
const AuthContext = createContext({}); | ||
|
||
export default AuthContext; |
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 @@ | ||
import { useContext } from 'react'; | ||
|
||
import authContext from '../context/index.jsx'; | ||
|
||
const useAuth = () => useContext(authContext); | ||
|
||
export default useAuth; |
File renamed without changes.
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,14 @@ | ||
export default {}; | ||
export default { | ||
translation: { | ||
loginForm: { | ||
title: 'Войти', | ||
username: 'Ваш ник', | ||
password: 'Пароль', | ||
span: 'Нет аккаунта?', | ||
signUp: 'Регистрация', | ||
}, | ||
// singUpForm: { | ||
// username: '' | ||
// } | ||
} | ||
}; |
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,17 +1,17 @@ | ||
import { createSlice } from '@reduxjs/toolkit'; | ||
// import { createSlice } from '@reduxjs/toolkit'; | ||
|
||
const initialState = { | ||
channels: [], | ||
activeChannel: 1, | ||
}; | ||
// const initialState = { | ||
// channels: [], | ||
// activeChannel: 1, | ||
// }; | ||
|
||
const channelsSlice = createSlice({ | ||
name: 'channels', | ||
initialState, | ||
reducers: { | ||
// const channelsSlice = createSlice({ | ||
// name: 'channels', | ||
// initialState, | ||
// reducers: { | ||
|
||
} | ||
}); | ||
// } | ||
// }); | ||
|
||
export const { actions } = channelsSlice; | ||
export default channelsSlice.reducer; | ||
// export const { actions } = channelsSlice; | ||
// export default channelsSlice.reducer; |
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,8 +1,8 @@ | ||
import { configureStore } from '@reduxjs/toolkit'; | ||
import channelsReducer from './channelsSlice'; | ||
// import { configureStore } from '@reduxjs/toolkit'; | ||
// import channelsReducer from './channelsSlice'; | ||
|
||
export default configureStore({ | ||
reducer: { | ||
channels: channelsReducer, | ||
} | ||
}); | ||
// export default configureStore({ | ||
// reducer: { | ||
// channels: channelsReducer, | ||
// } | ||
// }); |
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,4 +1,6 @@ | ||
const apiPath = '/api/v1'; | ||
|
||
export default { | ||
login: '/login', | ||
main: '/', | ||
loginPath: () => '/login', | ||
usersPath: () => [apiPath, 'data'].join('/'), | ||
}; |
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,8 @@ | ||
import { object, string } from 'yup'; | ||
|
||
const userSchema = (t) => object().shape({ | ||
username: string().required(), | ||
password: string().required(), | ||
}); | ||
|
||
export default userSchema; |