-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement 163 header core api #227
Merged
+1,179
−306
Merged
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
425451c
#140-api-inserted-to-BlogBlock
JuliaAvramenko 7aee7ab
получить основные данные в footer через Api
ArturKhelshtein 670e8d0
поправить именование информации для исключения совпадения наименовани…
ArturKhelshtein 4b123a7
подвинуть по FSD все ссылки в header
ArturKhelshtein 4e9e0d9
#140-bug-fix
JuliaAvramenko 8d4e6bb
Merge branch 'master' into api-140-insert-to-BlogBlock
JuliaAvramenko 5400102
Merge pull request #209 from Studio-Yandex-Practicum/api-140-insert-t…
JuliaAvramenko be613ad
добавить правило импорта
ArturKhelshtein 90d05ce
Merge pull request #231 from Studio-Yandex-Practicum/refactor/orderRule
ArturKhelshtein 3c18930
rebase
ArturKhelshtein cb0dbb5
поправить именование информации для исключения совпадения наименовани…
ArturKhelshtein 0a51451
rebase
ArturKhelshtein 1d02de1
fast-forward
ArturKhelshtein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
File renamed without changes.
4 changes: 3 additions & 1 deletion
4
...ets/SearchResult/SearchResult.stories.tsx → ...ies/SearchResult/SearchResult.stories.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
8 changes: 5 additions & 3 deletions
8
src/widgets/SearchResult/SearchResult.tsx → src/entities/SearchResult/SearchResult.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
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
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
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
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
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
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.
File renamed without changes
File renamed without changes
File renamed without changes
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { StateSchema } from '@/app/providers/StoreProvider' | ||
|
||
export const getCoreBaseHeaderSelector = (state: StateSchema) => state.coreBaseHeader |
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,29 @@ | ||
import { createAsyncThunk } from '@reduxjs/toolkit' | ||
|
||
import { ThunkConfig } from '@/app/providers/StoreProvider/config/StateSchema' | ||
import { apiErrorIdentify } from '@/shared/api/apiErrorIdentify' | ||
import { ApiError, ApiErrorTypes, ApiRoutes } from '@/shared/api/types' | ||
|
||
import { CoreBaseHeaderData } from '../types/types' | ||
|
||
/** | ||
* ассинхронный запрос Api через thunk Redux toolkit | ||
* <CoreBaseHeaderData> - формат ожидаемого ответа | ||
* <ThunkConfig> - формат запроса (описан в config StoreProvider) | ||
* <ApiError> - формат ошибки API запроса (описан в типах API) | ||
* первый аргумент - thunkConfig ID action type (отображается в dev tools) | ||
* второй аргумент - асинхронная функция, которая вызовет dispatch в компоненте | ||
*/ | ||
|
||
export const getCoreBaseHeader = createAsyncThunk<CoreBaseHeaderData, void, ThunkConfig<ApiError>>( | ||
'core/base_header', | ||
async (_, thunkAPI) => { | ||
const { rejectWithValue, extra } = thunkAPI | ||
try { | ||
const response = await extra.api.get(`api/${ApiRoutes.CORE_BASE}`) | ||
return response.data.header as CoreBaseHeaderData | ||
} catch (error) { | ||
return rejectWithValue(apiErrorIdentify(error, ApiErrorTypes.DATA_EMPTY_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,45 @@ | ||
import { createSlice } from '@reduxjs/toolkit' | ||
|
||
import { rejectedPayloadHandle } from '@/shared/api/rejectedPayloadHandle' | ||
|
||
import { getCoreBaseHeader } from '../services/getCoreBaseHeader' | ||
import { CoreBaseHeaderSchema } from '../types/types' | ||
|
||
const initialState: CoreBaseHeaderSchema = { | ||
isLoading: false, | ||
header: { | ||
main_logo: { | ||
image: '', | ||
url: '', | ||
title: '' | ||
}, | ||
support: { | ||
callback: '', | ||
phone_number: '' | ||
} | ||
}, | ||
error: undefined | ||
} | ||
|
||
const footerSlice = createSlice({ | ||
name: 'header', | ||
initialState, | ||
reducers: {}, | ||
extraReducers: builder => { | ||
builder | ||
.addCase(getCoreBaseHeader.pending, state => { | ||
state.isLoading = true | ||
state.error = undefined | ||
}) | ||
.addCase(getCoreBaseHeader.fulfilled, (state, { payload }) => { | ||
state.isLoading = false | ||
state.header = payload | ||
}) | ||
.addCase(getCoreBaseHeader.rejected, (state, { payload }) => { | ||
state.isLoading = false | ||
state.error = rejectedPayloadHandle(payload) | ||
}) | ||
} | ||
}) | ||
|
||
export default footerSlice.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
interface Logo { | ||
image: string | ||
url: string | ||
title: string | ||
} | ||
|
||
interface Support { | ||
callback: string | ||
phone_number: string | ||
} | ||
|
||
export interface CoreBaseHeaderData { | ||
main_logo: Logo | ||
support: Support | ||
} | ||
|
||
export interface CoreBaseHeaderSchema { | ||
isLoading: boolean | ||
header: CoreBaseHeaderData | ||
error?: string | string[] | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нужен комментарий?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
раньше данные получались из мок, теперь с сервера, можно и удалить в целом