-
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 #299 from Studio-Yandex-Practicum/enhancement_221_…
…api_about_us enhancement_221_api_about_us
- Loading branch information
Showing
13 changed files
with
145 additions
and
6 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
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 interface IAboutUs { | ||
text?: string | ||
} |
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 |
---|---|---|
|
@@ -6,5 +6,5 @@ | |
font-weight: 400; | ||
color: var.$body-color; | ||
margin: 0; | ||
padding: 0; | ||
padding: 30px 0 56px; | ||
} |
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,19 @@ | ||
@use '@/shared/styles/utils/variables' as var; | ||
|
||
.title { | ||
width: 100%; | ||
margin: 0 0 10px; | ||
padding: 0; | ||
} | ||
|
||
.link { | ||
text-decoration: none; | ||
color: var.$subtitle-color; | ||
font-size: 13.5px; | ||
font-weight: 400; | ||
line-height: 16.2px; | ||
|
||
&:hover { | ||
color: var.$theme-primary-color; | ||
} | ||
} |
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 { useEffect } from 'react' | ||
import { useDispatch, useSelector } from 'react-redux' | ||
import { Link } from 'react-router-dom' | ||
|
||
import { AppDispatch } from '@/app/providers/StoreProvider/config/store' | ||
import WrapperForMainContent from '@/components/WrapperForMainContent/WrapperForMainContent' | ||
import AboutUs from '@/entities/AboutUs' | ||
import Heading, { HeadingType } from '@/shared/ui/Heading/Heading' | ||
import Subheading from '@/shared/ui/Subheading/Subheading' | ||
|
||
import styles from './AboutUsPage.module.scss' | ||
import { getAboutUsSelector } from './model/selectors/selectors' | ||
import { getAboutUs } from './model/services/getAboutUs' | ||
|
||
const AboutUsPage = () => { | ||
const dispatch = useDispatch<AppDispatch>() | ||
const aboutUs = useSelector(getAboutUsSelector) | ||
|
||
useEffect(() => { | ||
dispatch(getAboutUs()) | ||
}, [dispatch]) | ||
|
||
return ( | ||
<WrapperForMainContent> | ||
{aboutUs?.map((item, index) => ( | ||
<Heading key={index} type={HeadingType.MAIN} className={styles.title}> | ||
{item.headline} | ||
</Heading> | ||
))} | ||
|
||
<Subheading> | ||
<Link to={'/'} className={styles.link}> | ||
Главная | ||
</Link>{' '} | ||
/ О нас | ||
</Subheading> | ||
|
||
{aboutUs?.map((item, index) => <AboutUs key={index} text={item.text} />)} | ||
</WrapperForMainContent> | ||
) | ||
} | ||
|
||
export default AboutUsPage |
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 { StateSchema } from '@/app/providers/StoreProvider' | ||
|
||
export const getAboutUsSelector = (state: StateSchema) => { | ||
return state.aboutUs.result | ||
} |
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,20 @@ | ||
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 { IData } from '../types/types' | ||
|
||
export const getAboutUs = createAsyncThunk<IData[], void, ThunkConfig<ApiError>>( | ||
'aboutUs/getAboutUs', | ||
async (_, thunkAPI) => { | ||
const { rejectWithValue, extra } = thunkAPI | ||
try { | ||
const { data } = await extra.api.get(`api/${ApiRoutes.ABOUTUS}`) | ||
return data | ||
} 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,35 @@ | ||
import { createSlice } from '@reduxjs/toolkit' | ||
|
||
import { rejectedPayloadHandle } from '@/shared/api/rejectedPayloadHandle' | ||
|
||
import { getAboutUs } from '../services/getAboutUs' | ||
import { IAboutUsSchema } from '../types/types' | ||
|
||
const initialState: IAboutUsSchema = { | ||
isLoading: false, | ||
result: [], | ||
error: null | ||
} | ||
|
||
export const aboutUsSlice = createSlice({ | ||
name: 'aboutUs', | ||
initialState, | ||
reducers: {}, | ||
extraReducers: builder => { | ||
builder | ||
.addCase(getAboutUs.pending, state => { | ||
state.isLoading = true | ||
state.error = null | ||
}) | ||
.addCase(getAboutUs.fulfilled, (state, { payload }) => { | ||
state.isLoading = false | ||
state.result = payload | ||
}) | ||
.addCase(getAboutUs.rejected, (state, { payload }) => { | ||
state.isLoading = false | ||
state.error = rejectedPayloadHandle(payload) | ||
}) | ||
} | ||
}) | ||
|
||
export const { actions: aboutUsActions, reducer: aboutUsReducer } = aboutUsSlice |
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,10 @@ | ||
export interface IData { | ||
headline?: string | ||
text?: string | ||
} | ||
|
||
export interface IAboutUsSchema { | ||
isLoading: boolean | ||
result?: IData[] | ||
error?: string | string[] | null | ||
} |
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