mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
Cleanup notification drawer (#7911)
- Add "mark all as read" button - Fix icons
This commit is contained in:
parent
e6765fc7df
commit
05e234fc49
@ -12,9 +12,9 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
Tooltip
|
Tooltip
|
||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
import { IconBellCheck, IconBellPlus } from '@tabler/icons-react';
|
import { IconArrowRight, IconBellCheck } from '@tabler/icons-react';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import { Link, useNavigate } from 'react-router-dom';
|
import { Link, useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
@ -59,6 +59,19 @@ export function NotificationDrawer({
|
|||||||
return (notificationQuery.data?.results?.length ?? 0) > 0;
|
return (notificationQuery.data?.results?.length ?? 0) > 0;
|
||||||
}, [notificationQuery.data]);
|
}, [notificationQuery.data]);
|
||||||
|
|
||||||
|
const markAllAsRead = useCallback(() => {
|
||||||
|
api
|
||||||
|
.get(apiUrl(ApiEndpoints.notifications_readall), {
|
||||||
|
params: {
|
||||||
|
read: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((_error) => {})
|
||||||
|
.then((_response) => {
|
||||||
|
notificationQuery.refetch();
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Drawer
|
<Drawer
|
||||||
opened={opened}
|
opened={opened}
|
||||||
@ -77,6 +90,18 @@ export function NotificationDrawer({
|
|||||||
title={
|
title={
|
||||||
<Group justify="space-between" wrap="nowrap">
|
<Group justify="space-between" wrap="nowrap">
|
||||||
<StylishText size="lg">{t`Notifications`}</StylishText>
|
<StylishText size="lg">{t`Notifications`}</StylishText>
|
||||||
|
<Group justify="end" wrap="nowrap">
|
||||||
|
<Tooltip label={t`Mark all as read`}>
|
||||||
|
<ActionIcon
|
||||||
|
variant="transparent"
|
||||||
|
onClick={() => {
|
||||||
|
markAllAsRead();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<IconBellCheck />
|
||||||
|
</ActionIcon>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip label={t`View all notifications`}>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onClose();
|
onClose();
|
||||||
@ -84,8 +109,10 @@ export function NotificationDrawer({
|
|||||||
}}
|
}}
|
||||||
variant="transparent"
|
variant="transparent"
|
||||||
>
|
>
|
||||||
<IconBellPlus />
|
<IconArrowRight />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
|
</Tooltip>
|
||||||
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user