This repository has been archived by the owner on Apr 14, 2024. It is now read-only.
-
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
Showing
15 changed files
with
122 additions
and
50 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
File renamed without changes.
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 @@ | ||
export * from './useGetNotification'; |
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,10 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { api } from '~/shared/contexts'; | ||
|
||
export const useGetNotification = (notificationId: string) => | ||
useQuery({ | ||
queryKey: ['notificatiions', notificationId], | ||
queryFn: () => api.notificationsApi.get(notificationId), | ||
staleTime: 15000, | ||
}); |
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 +1,2 @@ | ||
export * from './Notification'; | ||
export * from './Notification.constants'; |
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 * from './useReadNotification'; |
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,14 @@ | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
|
||
import { api } from '~/shared/contexts'; | ||
|
||
export const useReadNotification = (notificationId: string) => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: () => api.notificationsApi.read(notificationId), | ||
onSuccess: () => { | ||
queryClient.invalidateQueries(['notifications']); | ||
}, | ||
}); | ||
}; |
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,4 @@ | ||
export * from './notification'; | ||
export * from './notification-settings'; | ||
export * from './notifications-filter'; | ||
export * from './api'; |
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,27 @@ | ||
import { Container, Flex, Heading } from '@chakra-ui/react'; | ||
|
||
import { useReadNotification } from '~/features/notifications'; | ||
|
||
import { Notification } from '~/entities/notification'; | ||
|
||
import { GoBack } from '~/shared/ui/GoBack'; | ||
|
||
interface NotificationBasePage { | ||
notificationId: string; | ||
} | ||
|
||
export function NotificationBasePage({ notificationId }: NotificationBasePage) { | ||
const { mutate: readNotification } = useReadNotification(notificationId); | ||
|
||
return ( | ||
<Container maxW="md" mt={2} mb={4}> | ||
<Flex alignItems="center" gap={2} my={4}> | ||
<GoBack /> | ||
<Heading as="h1" variant="h1"> | ||
Уведомления | ||
</Heading> | ||
</Flex> | ||
<Notification notificationId={notificationId} read={readNotification} /> | ||
</Container> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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,19 +1,15 @@ | ||
import { Container, Flex, Heading } from '@chakra-ui/react'; | ||
import { Navigate, useParams } from 'react-router-dom'; | ||
|
||
import { Notification } from '~/entities/notification'; | ||
import { PATHS } from '~/shared/lib/router'; | ||
|
||
import { GoBack } from '~/shared/ui/GoBack'; | ||
import { NotificationBasePage } from './NotificationBasePage'; | ||
|
||
export function NotificationPage() { | ||
return ( | ||
<Container maxW="md" mt={2} mb={4}> | ||
<Flex alignItems="center" gap={2} my={4}> | ||
<GoBack /> | ||
<Heading as="h1" variant="h1"> | ||
Уведомления | ||
</Heading> | ||
</Flex> | ||
<Notification /> | ||
</Container> | ||
const { id: notificationId } = useParams(); | ||
|
||
return !notificationId ? ( | ||
<Navigate to={PATHS.notFound} replace /> | ||
) : ( | ||
<NotificationBasePage notificationId={notificationId} /> | ||
); | ||
} |
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,2 +1 @@ | ||
export * from './NotificationPage'; | ||
export * from './NotificationPage.desktop'; |
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