-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from Studio-Yandex-Practicum/development/api/…
…athorization Athorization
- Loading branch information
Showing
147 changed files
with
637 additions
and
400 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
APP_HOSTNAME=https://gealit.ru/ |
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ lerna-debug.log* | |
node_modules | ||
dist | ||
.env | ||
package-lock.json | ||
|
||
*.local | ||
|
||
|
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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {StoreProvider} from "../../../src/app/providers/SroreProvider/index.js"; | ||
|
||
export const StoreDecorator = (initialState) => (Story) => | ||
( <StoreProvider initialState={initialState}> | ||
<Story/> | ||
</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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import '../../../src/index.scss'; | ||
import '../../../src/app/styles/index.scss'; | ||
|
||
export const StyleDecorator = (story) => story(); |
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,3 @@ | ||
import fs from 'fs'; | ||
|
||
fs.copyFileSync('.env.sample', '.env') |
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { RouterProvider } from 'react-router-dom' | ||
import { router } from './router/AppRouter' | ||
import { useEffect } from 'react' | ||
import { loginActions } from '@/features/login/model/slice/loginSlice' | ||
import { useAppDispatch } from '@/shared/libs/hooks/store' | ||
import { tokenFromStorageGet } from '@/shared/libs/helpers/localStorageHandler' | ||
import { $api } from '@/shared/api/api' | ||
|
||
function App() { | ||
const dispatch = useAppDispatch() | ||
|
||
useEffect(() => { | ||
const token = tokenFromStorageGet() | ||
if (token) { | ||
dispatch(loginActions.initAuth(token)) | ||
$api.addToken(token) | ||
} | ||
}, [dispatch]) | ||
return <RouterProvider router={router} /> | ||
} | ||
|
||
export default App |
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,16 @@ | ||
import { LoginSchema } from '@/features/login/model/types/types' | ||
import { ApiInstance } from '@/shared/api/api' | ||
|
||
export interface StateSchema { | ||
login: LoginSchema | ||
} | ||
|
||
export interface ThunkExtraArg { | ||
api: ApiInstance | ||
} | ||
|
||
export interface ThunkConfig<E> { | ||
rejectValue: E | ||
extra: ThunkExtraArg | ||
state: StateSchema | ||
} |
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,27 @@ | ||
import { configureStore, ReducersMapObject } from '@reduxjs/toolkit' | ||
import { loginReducer } from '@/features/login/model/slice/loginSlice' | ||
import { StateSchema, ThunkExtraArg } from './StateSchema' | ||
import { $api } from '@/shared/api/api' | ||
|
||
const rootReducer: ReducersMapObject<StateSchema> = { | ||
login: loginReducer | ||
} | ||
|
||
export function createReduxStore(initialState: StateSchema) { | ||
const extraArg: ThunkExtraArg = { | ||
api: $api | ||
} | ||
return configureStore({ | ||
reducer: rootReducer, | ||
devTools: __IS_DEV__, | ||
preloadedState: initialState, | ||
middleware: getDefaultMiddleware => | ||
getDefaultMiddleware({ | ||
thunk: { | ||
extraArgument: extraArg | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
export type AppDispatch = ReturnType<typeof createReduxStore>['dispatch'] |
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 @@ | ||
export type { StateSchema } from './config/StateSchema' | ||
|
||
export { StoreProvider } from './ui/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,18 @@ | ||
import { ReactNode } from 'react' | ||
import { Provider } from 'react-redux' | ||
import { DeepPartial } from '@reduxjs/toolkit' | ||
import { StateSchema } from '../config/StateSchema' | ||
import { createReduxStore } from '../config/store' | ||
|
||
interface StoreProviderProps { | ||
initialState?: DeepPartial<StateSchema> // DeepPartial для Storybook | ||
children?: ReactNode | ||
} | ||
|
||
export const StoreProvider = (props: StoreProviderProps) => { | ||
const { initialState, children } = props | ||
|
||
const store = createReduxStore(initialState as StateSchema) // кастуем DeepPartial | ||
|
||
return <Provider store={store}>{children}</Provider> | ||
} |
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 { AppRouter } from './ui/AppRouter' | ||
|
||
export { AppRouter as router } |
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@import '@/shared/styles/utils/variables'; | ||
|
||
@import 'vendors/normalise'; | ||
|
||
@import 'base/reset'; |
File renamed without changes.
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
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.