diff --git a/src/components/input/LoaderScreen/index.tsx b/src/components/input/LoaderScreen/index.tsx new file mode 100644 index 00000000..0cc3c1da --- /dev/null +++ b/src/components/input/LoaderScreen/index.tsx @@ -0,0 +1,25 @@ +import React, { FC } from 'react'; + +import classNames from 'classnames'; + +import { LoaderCircle } from '../LoaderCircle'; + +import styles from './styles.module.scss'; + +interface LoaderScreenProps { + className?: string; + align?: 'top' | 'middle'; +} + +const LoaderScreen: FC = ({ + className, + align = 'middle', +}) => ( +
+ +
+); + +export { LoaderScreen }; diff --git a/src/components/input/LoaderScreen/styles.module.scss b/src/components/input/LoaderScreen/styles.module.scss new file mode 100644 index 00000000..09e8cce1 --- /dev/null +++ b/src/components/input/LoaderScreen/styles.module.scss @@ -0,0 +1,14 @@ +@import 'src/styles/variables'; + +.screen { + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; + padding: $gap; + + &.align-top { + align-items: flex-start; + } +} diff --git a/src/components/menu/HorizontalMenu/index.tsx b/src/components/menu/HorizontalMenu/index.tsx index 51daf0d2..146f1ebc 100644 --- a/src/components/menu/HorizontalMenu/index.tsx +++ b/src/components/menu/HorizontalMenu/index.tsx @@ -14,6 +14,7 @@ interface HorizontalMenuItemProps { icon?: string; color?: 'green' | 'orange' | 'yellow'; active?: boolean; + stretchy?: boolean; onClick?: () => void; } @@ -31,6 +32,7 @@ HorizontalMenu.Item = ({ children, isLoading, active, + stretchy, onClick, }: PropsWithChildren) => { if (isLoading) { @@ -44,7 +46,11 @@ HorizontalMenu.Item = ({ return (
{!!icon && } diff --git a/src/components/menu/HorizontalMenu/styles.module.scss b/src/components/menu/HorizontalMenu/styles.module.scss index e4ae9935..54d3c298 100644 --- a/src/components/menu/HorizontalMenu/styles.module.scss +++ b/src/components/menu/HorizontalMenu/styles.module.scss @@ -57,6 +57,11 @@ background: $warning_gradient; } } + + &.stretchy { + flex: 1; + justify-content: center; + } } .text { diff --git a/src/components/notifications/NotificationSettingsForm/index.tsx b/src/components/notifications/NotificationSettingsForm/index.tsx index 3eb1d8b2..9abebdc5 100644 --- a/src/components/notifications/NotificationSettingsForm/index.tsx +++ b/src/components/notifications/NotificationSettingsForm/index.tsx @@ -1,5 +1,6 @@ import React, { FC, useCallback } from 'react'; +import { Card } from '~/components/containers/Card'; import { Group } from '~/components/containers/Group'; import { Zone } from '~/components/containers/Zone'; import { Button } from '~/components/input/Button'; @@ -49,11 +50,16 @@ const NotificationSettingsForm: FC = ({ return ( - + + + Получать уведомления + + + +
+ + - - Включены - = ({ - +
+ + = () => { const { closeAllTabs } = useStackContext(); + const [tab, setTab] = useState(Tabs.List); + const { loading } = useNotificationSettings(); return ( - - + +
+ + + setTab(Tabs.List)} + stretchy + > + Уведомления + + + setTab(Tabs.Settings)} + stretchy + > + Настройки + + + +
); }; diff --git a/src/components/profile/ProfileSidebarNotifications/styles.module.scss b/src/components/profile/ProfileSidebarNotifications/styles.module.scss new file mode 100644 index 00000000..59f37f49 --- /dev/null +++ b/src/components/profile/ProfileSidebarNotifications/styles.module.scss @@ -0,0 +1,31 @@ +@import 'src/styles/variables'; + +.grid { + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; + z-index: 4; + height: 100%; +} + +.head { + @include row_shadow; + + width: 100%; + padding: $gap; + flex: 0; +} + +.tabs { + flex: 1; +} + +.list { + @include row_shadow; + + overflow-y: auto; + flex: 1 1; + overflow: auto; + width: 100%; +} diff --git a/src/containers/notifications/NotificationList/index.tsx b/src/containers/notifications/NotificationList/index.tsx index c1759845..b086f87b 100644 --- a/src/containers/notifications/NotificationList/index.tsx +++ b/src/containers/notifications/NotificationList/index.tsx @@ -1,6 +1,6 @@ -import React, { FC, useEffect } from 'react'; +import { FC, useEffect } from 'react'; -import { LoaderCircle } from '~/components/input/LoaderCircle'; +import { LoaderScreen } from '~/components/input/LoaderScreen'; import { NotificationComment } from '~/components/notifications/NotificationComment'; import { useNotificationsList } from '~/hooks/notifications/useNotificationsList'; import { useNotifications } from '~/utils/providers/NotificationProvider'; @@ -18,7 +18,7 @@ const NotificationList: FC = () => { }, []); if (isLoading) { - return ; + return ; } return ( diff --git a/src/hooks/notifications/useNotificationSettings.ts b/src/hooks/notifications/useNotificationSettings.ts index e3ad2434..aa65118e 100644 --- a/src/hooks/notifications/useNotificationSettings.ts +++ b/src/hooks/notifications/useNotificationSettings.ts @@ -14,13 +14,13 @@ export const useNotificationSettings = () => { enabled: settingsEnabled, lastSeen, lastDate, - isLoading: isLoadingSettings, + isLoading, update, refresh, settings, } = useNotificationSettingsRequest(); - const enabled = !isLoadingSettings && !settingsError && settingsEnabled; + const enabled = !isLoading && !settingsError && settingsEnabled; const hasNew = enabled && !!lastDate && (!lastSeen || isAfter(lastDate, lastSeen)); @@ -47,5 +47,6 @@ export const useNotificationSettings = () => { markAsRead, refresh, update, + loading: isLoading, }; }; diff --git a/src/hooks/notifications/useNotificationSettingsRequest.ts b/src/hooks/notifications/useNotificationSettingsRequest.ts index 531c33b5..43046ac0 100644 --- a/src/hooks/notifications/useNotificationSettingsRequest.ts +++ b/src/hooks/notifications/useNotificationSettingsRequest.ts @@ -66,7 +66,7 @@ export const useNotificationSettingsRequest = () => { const refresh = useCallback(() => mutate(), [mutate]); return { - isLoading, + isLoading: isLoading && !data, error, lastSeen: data?.lastSeen && isValid(parseISO(data.lastSeen))