File tree Expand file tree Collapse file tree 8 files changed +74
-3
lines changed
entities/User/model/types
features/articlePageGreeting
pages/ArticlesPage/ui/ArticlesPage Expand file tree Collapse file tree 8 files changed +74
-3
lines changed Original file line number Diff line number Diff line change 20122012 "jsonSettings" : {
20132013 "theme" : " app_magneta_theme" ,
20142014 "isFirstVisit" : true ,
2015- "settingsPageHasBeenOpened" : false
2015+ "settingsPageHasBeenOpened" : false ,
2016+ "isArtcilesPageWasOpened" : true
20162017 }
20172018 },
20182019 {
Original file line number Diff line number Diff line change 3434 " You don" : " Forbidden. You don`t have access."
3535 },
3636 "Close" : " Close" ,
37- "add five" : " add five"
37+ "add five" : " add five" ,
38+ "Welcome to the articles page" : " Welcome to the articles page" ,
39+ "Here you can search and view articles on various topics" : " Here you can search and view articles on various topics"
3840}
Original file line number Diff line number Diff line change 3131 "Forbidden" : {
3232 " You don" : " Запрещенный. \n У вас нет доступа."
3333 },
34- "Close" : " Закрывать"
34+ "Close" : " Закрывать" ,
35+ "Welcome to the articles page" : " Добро пожаловать на страницу статей" ,
36+ "Here you can search and view articles on various topics" : " Здесь вы можете искать и просматривать статьи на различные темы"
3537}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ interface _JsonSettings {
44 theme : Theme ;
55 isFirstVisist : boolean ;
66 settingsPageHasBeenOpened : boolean ;
7+ isArtcilesPageWasOpened ?: boolean ;
78}
89
910export type JsonSettings = Partial < _JsonSettings > ;
Original file line number Diff line number Diff line change 1+ export { ArticlePageGreeting } from './ui/ArticlePageGreeting/ArticlePageGreeting' ;
Original file line number Diff line number Diff line change 1+ import { ComponentStory , ComponentMeta } from '@storybook/react' ;
2+ import { ArticlePageGreeting } from './ArticlePageGreeting' ;
3+
4+ export default {
5+ title : 'entities/ArticlePageGreeting' ,
6+ component : ArticlePageGreeting ,
7+ argTypes : {
8+ backgroundColor : { control : 'color' } ,
9+ } ,
10+ } as ComponentMeta < typeof ArticlePageGreeting > ;
11+
12+ const Template : ComponentStory < typeof ArticlePageGreeting > = ( ) => {
13+ return < ArticlePageGreeting /> ;
14+ } ;
15+
16+ export const Primary = Template . bind ( { } ) ;
17+ Primary . args = { } ;
Original file line number Diff line number Diff line change 1+ import { useEffect , useState } from 'react' ;
2+ import { useTranslation } from 'react-i18next' ;
3+ import { isMobile } from 'react-device-detect' ;
4+ import { Modal } from '@/shared/ui/Modal' ;
5+ import { Text } from '@/shared/ui/Text' ;
6+ import { saveJsonSettings , useJsonSettings } from '@/entities/User' ;
7+ import { useAppDispatch } from '@/shared/lib/hooks/useAppDispatch/useAppDispatch' ;
8+ import { Drawer } from '@/shared/ui/Drawer' ;
9+
10+ export const ArticlePageGreeting = ( ) => {
11+ const { t } = useTranslation ( ) ;
12+ const [ isOpen , setIsOpen ] = useState ( false ) ;
13+ const { isArtcilesPageWasOpened } = useJsonSettings ( ) ;
14+ const dispatch = useAppDispatch ( ) ;
15+
16+ useEffect ( ( ) => {
17+ if ( ! isArtcilesPageWasOpened ) {
18+ setIsOpen ( true ) ;
19+ dispatch ( saveJsonSettings ( { isArtcilesPageWasOpened : true } ) ) ;
20+ }
21+ } , [ dispatch , isArtcilesPageWasOpened ] ) ;
22+
23+ const handleOnClose = ( ) => setIsOpen ( false ) ;
24+
25+ const text = (
26+ < Text
27+ title = { t ( 'Welcome to the articles page' ) }
28+ text = { t ( 'Here you can search and view articles on various topics' ) }
29+ />
30+ ) ;
31+
32+ if ( isMobile ) {
33+ return (
34+ < Drawer isOpen = { isOpen } lazy onClose = { handleOnClose } >
35+ { text }
36+ </ Drawer >
37+ ) ;
38+ }
39+
40+ return (
41+ < Modal isOpen = { isOpen } lazy onClose = { handleOnClose } >
42+ { text }
43+ </ Modal >
44+ ) ;
45+ } ;
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import { fetchNextArticlesPage } from '../../model/services/fetchNextArticlesPag
1313import { articlesPageReducer } from '../../model/slices/articlesPageSlice' ;
1414import s from './ArticlesPage.module.scss' ;
1515import { ArticlesPageFilters } from '../ArticlesPageFilters/ArticlesPageFilters' ;
16+ import { ArticlePageGreeting } from '@/features/articlePageGreeting' ;
1617
1718const reducers : ReducersList = {
1819 articlesPage : articlesPageReducer ,
@@ -35,6 +36,7 @@ export const ArticlesPage = memo(() => {
3536 < Page onScrollEnd = { onLoadNextPart } className = { s . ArticlesPage } data-testid = "ArticlesPage" >
3637 < ArticlesPageFilters />
3738 < ArtcileInfiniteList className = { s . list } />
39+ < ArticlePageGreeting />
3840 </ Page >
3941 </ DynamicModuleLoader >
4042 ) ;
You can’t perform that action at this time.
0 commit comments