-
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.
feat: add user auth logic / text comp
- Loading branch information
Showing
101 changed files
with
248 additions
and
24 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+70.5 KB
(650%)
.loki/reference/chrome_iphone7_pages_NotFoundPage_Normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+71 KB
(1000%)
.loki/reference/chrome_iphone7_shared_AppLink_Primary_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+70.9 KB
(1000%)
.loki/reference/chrome_iphone7_shared_AppLink_Red_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+70.1 KB
(990%)
.loki/reference/chrome_iphone7_shared_AppLink_Secondary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+71 KB
(1000%)
.loki/reference/chrome_iphone7_shared_AppLink_Secondary_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+70.5 KB
(1000%)
.loki/reference/chrome_iphone7_shared_Button_Background_Inverted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+70.1 KB
(980%)
.loki/reference/chrome_iphone7_shared_Button_Background_Theme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+70.1 KB
(990%)
.loki/reference/chrome_iphone7_shared_Button_Clear_Inverted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+71.6 KB
(1000%)
.loki/reference/chrome_iphone7_shared_Button_Outline_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+70.8 KB
(980%)
.loki/reference/chrome_iphone7_shared_Button_Outline_Size_L.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+70.8 KB
(980%)
.loki/reference/chrome_iphone7_shared_Button_Outline_Size_XL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Binary file modified
BIN
+71.6 KB
(1100%)
.loki/reference/chrome_iphone7_shared_Button_Square_XL.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
+69.8 KB
(770%)
.loki/reference/chrome_iphone7_shared_ThemeSwitcher_Dark.png
Oops, something went wrong.
Binary file modified
BIN
+69.1 KB
(740%)
.loki/reference/chrome_iphone7_shared_ThemeSwitcher_Normal.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Diff not rendered.
Diff not rendered.
Oops, something went wrong.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
+39.3 KB
(560%)
.loki/reference/chrome_laptop_pages_NotFoundPage_Normal.png
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
+38.1 KB
(710%)
.loki/reference/chrome_laptop_shared_AppLink_Primary_Dark.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
+38.1 KB
(720%)
.loki/reference/chrome_laptop_shared_AppLink_Secondary_Dark.png
Oops, something went wrong.
Binary file modified
BIN
+38.5 KB
(720%)
.loki/reference/chrome_laptop_shared_Button_Background_Inverted.png
Oops, something went wrong.
Binary file modified
BIN
+38.3 KB
(720%)
.loki/reference/chrome_laptop_shared_Button_Background_Theme.png
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
+38.3 KB
(720%)
.loki/reference/chrome_laptop_shared_Button_Clear_Inverted.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
+38.4 KB
(710%)
.loki/reference/chrome_laptop_shared_Button_Outline_Dark.png
Oops, something went wrong.
Binary file modified
BIN
+38.8 KB
(720%)
.loki/reference/chrome_laptop_shared_Button_Outline_Size_L.png
Oops, something went wrong.
Binary file modified
BIN
+38.8 KB
(720%)
.loki/reference/chrome_laptop_shared_Button_Outline_Size_XL.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
+37.2 KB
(570%)
.loki/reference/chrome_laptop_shared_ThemeSwitcher_Dark.png
Oops, something went wrong.
Binary file modified
BIN
+37.9 KB
(580%)
.loki/reference/chrome_laptop_shared_ThemeSwitcher_Normal.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Diff not rendered.
Diff not rendered.
Oops, something went wrong.
Oops, something went wrong.
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,14 +1,23 @@ | ||
{ | ||
"auth_form": "", | ||
"auth_password": "", | ||
"auth_username": "", | ||
"decrement": "", | ||
"exit": "", | ||
"increment": "", | ||
"login": "", | ||
"login_error": "", | ||
"Введите username": "", | ||
"Введите пароль": "", | ||
"Войти": "", | ||
"Вы ввели ": "", | ||
"Вы ввели неверный логин пароль": "", | ||
"Вы ввели неверный логин или пароль": "", | ||
"Главная": "", | ||
"Главная страница": "", | ||
"О сайте": "", | ||
"Обновить страницу": "", | ||
"Произошла непредвиденная ошибка": "", | ||
"Страница не найдена": "" | ||
"Страница не найдена": "", | ||
"Форма авторизации": "" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -20,4 +20,6 @@ | |
|
||
// Цвета | ||
--overlay-color: rgba(0 0 0 / 60%); | ||
--red-light: #f00; | ||
--red-dark: #ce0505; | ||
} |
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,3 +1,5 @@ | ||
export { userReducer, userActions } from './model/slice/userSlice'; | ||
|
||
export { UserSchema, User } from './model/types/user'; | ||
|
||
export { getUserAuthData } from './model/selectors/getUserAuthData/getUserAuthData'; |
3 changes: 3 additions & 0 deletions
3
src/entities/User/model/selectors/getUserAuthData/getUserAuthData.ts
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,3 @@ | ||
import { StateSchema } from 'app/providers/StoreProvider'; | ||
|
||
export const getUserAuthData = (state: StateSchema) => state?.user.authData; |
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
18 changes: 14 additions & 4 deletions
18
src/features/AuthByUsername/model/services/loginByUsername/loginByUsername.ts
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,28 +1,38 @@ | ||
import { createAsyncThunk } from '@reduxjs/toolkit'; | ||
import axios from 'axios'; | ||
import { User } from 'entities/User'; | ||
import { User, userActions } from 'entities/User'; | ||
import { USER_LOCALSTORAGE_KEY } from 'shared/const/localstorage'; | ||
|
||
interface LoginByUsernameProps { | ||
username: string; | ||
password: string | ||
} | ||
|
||
enum LoginErrors { | ||
INCORRECT_DATA = '', | ||
SERVER_ERROR = '' | ||
} | ||
|
||
export const loginByUsername = createAsyncThunk< | ||
User, | ||
LoginByUsernameProps, | ||
{ rejectValue: string } | ||
>('login/loginByUsername', async (authData, thunkAPI) => { | ||
try { | ||
const response = await axios.post<User>('http://localhost:8000/login', { | ||
const response = await axios.post<User>( | ||
'http://localhost:8000/login', | ||
authData, | ||
}); | ||
); | ||
if (!response.data) { | ||
throw new Error(); | ||
} | ||
localStorage.setItem(USER_LOCALSTORAGE_KEY, JSON.stringify(response.data)); | ||
|
||
thunkAPI.dispatch(userActions.setAuthData(response.data)); | ||
|
||
return response.data; | ||
} catch (error) { | ||
console.log(error); | ||
return thunkAPI.rejectWithValue('error'); | ||
return thunkAPI.rejectWithValue('login_error'); | ||
} | ||
}); |
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
9 changes: 9 additions & 0 deletions
9
src/shared/config/storybook/StoreDecorator/StoreDecorator.tsx
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,9 @@ | ||
import { Story } from '@storybook/react'; | ||
import { StateSchema, StoreProvider } from 'app/providers/StoreProvider'; | ||
import { DeepPartial } from '@reduxjs/toolkit'; | ||
|
||
export const StoreDecorator = (state: DeepPartial<StateSchema>) => (StoryComponent: Story) => ( | ||
<StoreProvider initialState={state}> | ||
<StoryComponent /> | ||
</StoreProvider> | ||
); |
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 @@ | ||
export const USER_LOCALSTORAGE_KEY = 'user'; |
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,19 @@ | ||
.title { | ||
font: var(--font-l); | ||
color: var(--primary-color); | ||
} | ||
|
||
.text { | ||
font: var(--font-m); | ||
color: var(--secondary-color); | ||
} | ||
|
||
.error { | ||
.title { | ||
color: var(--red-light); | ||
} | ||
|
||
.text { | ||
color: var(--red-dark); | ||
} | ||
} |
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,43 @@ | ||
import React from 'react'; | ||
import { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
import { Text, TextTheme } from 'shared/ui/Text/Text'; | ||
import { Theme } from 'app/providers/ThemeProvider'; | ||
import { ThemeDecorator } from 'shared/config/storybook/ThemeDecorator/ThemeDecorator'; | ||
|
||
export default { | ||
title: 'shared/Text', | ||
component: Text, | ||
argTypes: { | ||
backgroundColor: { control: 'color' }, | ||
}, | ||
} as ComponentMeta<typeof Text>; | ||
|
||
const Template: ComponentStory<typeof Text> = (args) => <Text {...args} />; | ||
|
||
export const PrimaryDark = Template.bind({}); | ||
PrimaryDark.args = { | ||
title: 'title title title', | ||
text: 'description description description', | ||
|
||
}; | ||
PrimaryDark.decorators = [ThemeDecorator(Theme.DARK)]; | ||
|
||
export const onlyTitleDark = Template.bind({}); | ||
onlyTitleDark.args = { | ||
title: 'onlyTitle', | ||
|
||
}; | ||
onlyTitleDark.decorators = [ThemeDecorator(Theme.DARK)]; | ||
|
||
export const onlyDescriptionDark = Template.bind({}); | ||
onlyDescriptionDark.args = { | ||
text: 'onlyDescription', | ||
}; | ||
onlyDescriptionDark.decorators = [ThemeDecorator(Theme.DARK)]; | ||
|
||
export const Error = Template.bind({}); | ||
Error.args = { | ||
title: 'title title title', | ||
text: 'description description description', | ||
theme: TextTheme.ERROR, | ||
}; |
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,31 @@ | ||
import { classNames } from 'shared/lib/classNames/classNames'; | ||
import cls from './Text.module.scss'; | ||
|
||
export enum TextTheme { | ||
PRIMARY='primary', | ||
ERROR='error', | ||
|
||
} | ||
|
||
interface TextProps { | ||
className?: string; | ||
title?:string; | ||
text?:string; | ||
theme?: TextTheme; | ||
} | ||
|
||
export const Text = (props: TextProps) => { | ||
const { | ||
className, | ||
text, | ||
title, | ||
theme = TextTheme.PRIMARY, | ||
} = props; | ||
|
||
return ( | ||
<div className={classNames(cls.Text, { [cls[theme]]: true }, [className])}> | ||
{title && <p className={cls.title}>{title}</p>} | ||
{text && <p className={cls.text}>{text}</p>} | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.