-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d722808
commit f2da6bf
Showing
8 changed files
with
64 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
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 { ArticlesPageGreeting } from './ui/ArticlesPageGreeting/ArticlesPageGreeting'; | ||
|
||
export { | ||
ArticlesPageGreeting, | ||
}; |
49 changes: 49 additions & 0 deletions
49
src/features/ArticlesPageGreeting/ui/ArticlesPageGreeting/ArticlesPageGreeting.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useTranslation } from 'react-i18next'; | ||
import { memo, useCallback, useEffect, useState } from 'react'; | ||
import { Modal } from '@/shared/ui/Modal'; | ||
import { Text } from '@/shared/ui/Text'; | ||
import { saveJsonSettings, useJsonSettings } from '@/entities/User'; | ||
import { useAppDispatch } from '@/shared/lib/hooks/useAppDispatch/useAppDispatch'; | ||
import { isMobile } from 'react-device-detect'; | ||
import { Drawer } from '@/shared/ui/Drawer'; | ||
|
||
export const ArticlesPageGreeting = memo(() => { | ||
const [isModalOpen, setIsModalOpen] = useState(false); | ||
const { isArticlesPageGreetingsOpened } = useJsonSettings(); | ||
const dispatch = useAppDispatch(); | ||
const { t } = useTranslation(); | ||
|
||
useEffect(() => { | ||
if (!isArticlesPageGreetingsOpened) { | ||
setIsModalOpen(true); | ||
void dispatch(saveJsonSettings({ isArticlesPageGreetingsOpened: true })); | ||
} | ||
}, [isArticlesPageGreetingsOpened, dispatch]); | ||
|
||
const handleModalClose = useCallback(() => { | ||
setIsModalOpen(false); | ||
}, [setIsModalOpen]); | ||
|
||
const content = ( | ||
<Text | ||
title={t('Here is the article page.')} | ||
text={t('You can choose any article, read it and rate if you want.')} | ||
/> | ||
); | ||
|
||
if (isMobile) { | ||
return ( | ||
<Drawer isOpen={isModalOpen} onClose={handleModalClose}> | ||
{content} | ||
</Drawer> | ||
); | ||
} | ||
|
||
return ( | ||
<Modal lazy isOpen={isModalOpen} onClose={handleModalClose}> | ||
{content} | ||
</Modal> | ||
); | ||
}); | ||
|
||
ArticlesPageGreeting.displayName = 'ArticlesPageGreeting'; |
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