-
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.
Json Settings, add Greetings modal to Articles Pgae for first user visit
- Loading branch information
1 parent
3260c4f
commit f47be15
Showing
13 changed files
with
79 additions
and
9 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
7 changes: 6 additions & 1 deletion
7
src/entities/User/model/selectors/getJsonSettings/getJsonSettings.ts
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
import { buildSelector } from '@/shared/lib/store'; | ||
import { JsonSettings } from '../../types/jsonSettings'; | ||
|
||
export const [useJsonSettings, getJsonSettings] = buildSelector((state) => state.user?.authData?.jsonSettings); | ||
const defaultJsonSettings: JsonSettings = {}; | ||
|
||
export const [useJsonSettings, getJsonSettings] = buildSelector( | ||
(state) => state.user?.authData?.jsonSettings ?? defaultJsonSettings, | ||
); |
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { Theme } from '@/shared/consts/theme'; | ||
|
||
export interface JsonSettings { | ||
theme: Theme; | ||
theme?: Theme; | ||
isArticlesPageWasOpenedOnce?: boolean; | ||
} | ||
|
||
export type JsonSettingsKey = keyof JsonSettings; |
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 @@ | ||
export { ArticlePageGreetings } from './ui/ArticlePageGreetings/ArticlePageGreetings'; |
3 changes: 3 additions & 0 deletions
3
src/features/ArticlePageGreetings/ui/ArticlePageGreetings/ArticlePageGreetings.module.scss
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 @@ | ||
.ArticlePageGreetings { | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/features/ArticlePageGreetings/ui/ArticlePageGreetings/ArticlePageGreetings.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { ArticlePageGreetings } from './ArticlePageGreetings'; | ||
|
||
const meta: Meta<typeof ArticlePageGreetings> = { | ||
title: 'features/ArticlePageGreetings', | ||
component: ArticlePageGreetings, | ||
tags: ['autodocs'], | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof ArticlePageGreetings>; | ||
|
||
export const Root: Story = { | ||
args: { | ||
|
||
}, | ||
}; |
31 changes: 31 additions & 0 deletions
31
src/features/ArticlePageGreetings/ui/ArticlePageGreetings/ArticlePageGreetings.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,31 @@ | ||
import { FC, memo, useEffect, useState } from 'react'; | ||
import { useAppTranslation } from '@/shared/lib/hooks/useAppTranslation'; | ||
import { Modal } from '@/shared/ui/Modal'; | ||
import { VStack } from '@/shared/ui/Stack'; | ||
import { Text } from '@/shared/ui/Text'; | ||
import { useAppDispatch } from '@/shared/lib/hooks/useAppDispatch'; | ||
import { saveJsonSettings, useJsonSettings } from '@/entities/User'; | ||
import cls from './ArticlePageGreetings.module.scss'; | ||
|
||
export const ArticlePageGreetings: FC = memo(() => { | ||
const { t } = useAppTranslation('articles'); | ||
const dispatch = useAppDispatch(); | ||
|
||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false); | ||
const { isArticlesPageWasOpenedOnce } = useJsonSettings(); | ||
|
||
useEffect(() => { | ||
if (!isArticlesPageWasOpenedOnce) { | ||
setIsModalOpen(true); | ||
dispatch(saveJsonSettings({ isArticlesPageWasOpenedOnce: true })); | ||
} | ||
}, [isArticlesPageWasOpenedOnce, dispatch]); | ||
|
||
return ( | ||
<Modal isOpen={isModalOpen} onClose={setIsModalOpen} className={cls.ArticlePageGreetings}> | ||
<VStack> | ||
<Text title={t('welcome')} text={t('welcome-message-description')} /> | ||
</VStack> | ||
</Modal> | ||
); | ||
}); |
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