-
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 branch 'master' into enhancement-159-footerApi
- Loading branch information
Showing
19 changed files
with
324 additions
and
30 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,21 @@ | ||
@use '@/app/styles/index' as var; | ||
|
||
.card { | ||
position: relative; | ||
transition: transform 0.3s ease-in-out; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
gap: 15px; | ||
|
||
&:hover { | ||
transform: scale(1.1, 1.05); | ||
transition: transform 0.3s ease-in-out; | ||
} | ||
|
||
img { | ||
border-radius: 6px; | ||
transition: transform 0.3s ease-in-out; | ||
scroll-snap-align: start; | ||
} | ||
} |
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,25 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import StoryCard from './StoryCard' | ||
import Img1 from '@/assets/images/stories/img-stories-01.png' | ||
|
||
const meta = { | ||
title: 'entities/StoryCard', | ||
component: StoryCard, | ||
parameters: { | ||
layout: 'centered' | ||
}, | ||
tags: ['autodocs'] | ||
} satisfies Meta<typeof StoryCard> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Default: Story = { | ||
args: { | ||
card: { | ||
id: 1, | ||
src: Img1, | ||
alt: 'Stock image' | ||
} | ||
} | ||
} |
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,23 @@ | ||
import { FC } from 'react' | ||
import { TCard } from '@/models/CardModel' | ||
import styles from './StoryCard.module.scss' | ||
import Link from '@/shared/ui/Link/Link' | ||
|
||
export type Props = { | ||
card: TCard | ||
} | ||
|
||
/** | ||
* Карточка из блока группы историй | ||
* @param {TCard} card - параметры карточки из группы историй | ||
*/ | ||
|
||
const StoryCard: FC<Props> = ({ card }) => { | ||
return ( | ||
<Link to={''} className={styles.card}> | ||
<img src={card.src} alt={card.alt} draggable="false" /> | ||
</Link> | ||
) | ||
} | ||
|
||
export default StoryCard |
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,5 @@ | ||
import { StateSchema } from '@/app/providers/StoreProvider' | ||
|
||
export const getShopNewsSelector = (state: StateSchema) => { | ||
return state.shopNews.news | ||
} |
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 { createAsyncThunk } from '@reduxjs/toolkit' | ||
import { ThunkConfig } from '@/app/providers/StoreProvider/config/StateSchema' | ||
import { ApiError, ApiErrorTypes, ApiRoutes } from '@/shared/api/types' | ||
import { apiErrorIdentify } from '@/shared/api/apiErrorIdentify' | ||
import { ShopNewsData } from '../types/types' | ||
|
||
// export const getStoreReviews = createAsyncThunk<StoreReviewData[], void, ThunkConfig<ApiError>>( | ||
export const getShopNews = createAsyncThunk<ShopNewsData[], void, ThunkConfig<ApiError>>( | ||
//void1- выходные данные, void2- входные данные , thunkConfig- тип store | ||
'shop-news', // action type, первый аргумент | ||
async (_, thunkAPI) => { | ||
// второй аргумент- асинхронная функция , кот вызовет dispatch в компоненте | ||
const { rejectWithValue, extra } = thunkAPI | ||
try { | ||
const { data } = await extra.api.get(ApiRoutes.SHOP_NEWS) | ||
|
||
return data.results | ||
} 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,29 @@ | ||
import { createSlice } from '@reduxjs/toolkit' | ||
import { getShopNews } from '../services/getShopNews' | ||
import { ShopNewsSchema } from '../types/types' | ||
|
||
const initialState: ShopNewsSchema = { | ||
isLoading: false, | ||
news: [] | ||
} | ||
|
||
export const shopNewsSlice = createSlice({ | ||
name: 'shopNews', | ||
initialState, | ||
reducers: {}, | ||
extraReducers: builder => { | ||
builder | ||
.addCase(getShopNews.pending, state => { | ||
state.isLoading = true | ||
}) | ||
.addCase(getShopNews.fulfilled, (state, { payload }) => { | ||
state.isLoading = false | ||
state.news = payload | ||
}) | ||
.addCase(getShopNews.rejected, state => { | ||
state.isLoading = false | ||
}) | ||
} | ||
}) | ||
|
||
export const { actions: shopNewsActions, reducer: shopNewsReducer } = shopNewsSlice |
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 @@ | ||
export interface GetShopNewsResponse { | ||
count: number | ||
previous: string | ||
next: string | ||
results: ShopNewsData[] | ||
} | ||
|
||
export interface ShopNewsData { | ||
id: number | ||
title: string | ||
text: string | ||
image: string | ||
pub_date: string | ||
slug: string | ||
meta_title: string | ||
meta_description: string | ||
} | ||
|
||
export interface ShopNewsSchema { | ||
isLoading: boolean | ||
news: ShopNewsData[] | ||
} |
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
Oops, something went wrong.