-
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.
Merge pull request #165 from MathisBurger/feature/system-wide-notific…
…ations System wide notifications
- Loading branch information
Showing
20 changed files
with
326 additions
and
34 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
tasky/migrations/2024-11-20-142007_notifications_system_wide/down.sql
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 @@ | ||
-- This file should undo anything in `up.sql` |
2 changes: 2 additions & 0 deletions
2
tasky/migrations/2024-11-20-142007_notifications_system_wide/up.sql
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,2 @@ | ||
ALTER TABLE notifications ADD COLUMN show_until TIMESTAMP; | ||
ALTER TABLE notifications ADD COLUMN system_wide BOOLEAN NOT NULL DEFAULT false; |
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
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,56 @@ | ||
"use client"; | ||
import {Button, Container, Stack, Title} from "@mantine/core"; | ||
import {useTranslation} from "react-i18next"; | ||
import EntityList, {EntityListCol, EntityListRowAction} from "@/components/EntityList"; | ||
import RichTextDisplay from "@/components/display/RichTextDisplay"; | ||
import useClientQuery from "@/hooks/useClientQuery"; | ||
import useApiServiceClient from "@/hooks/useApiServiceClient"; | ||
import {useState} from "react"; | ||
import CreateSystemWideNotificationModal from "@/components/CreateSystemWideNotificationModal"; | ||
|
||
|
||
const NotificationsPage = () => { | ||
|
||
const {t} = useTranslation('common'); | ||
const api = useApiServiceClient(); | ||
const [notifications, refetch] = useClientQuery(() => api.getSystemWideNotification()); | ||
const [createModalOpen, setCreateModalOpen] = useState<boolean>(false); | ||
|
||
const cols: EntityListCol[] = [ | ||
{ | ||
field: 'title', | ||
label: t('common:fields.title') | ||
}, | ||
{ | ||
field: 'content', | ||
label: t('common:fields.description'), | ||
render: (value) => <RichTextDisplay content={value as string} fullSize={false} /> | ||
} | ||
]; | ||
|
||
const rowActions: EntityListRowAction[] = [ | ||
{ | ||
name: t('actions.delete'), | ||
onClick: async (row) => { | ||
await api.deleteSystemWideNotifications(row.id); | ||
refetch(); | ||
}, | ||
color: 'red' | ||
} | ||
] | ||
|
||
return ( | ||
<Container fluid> | ||
<Stack gap={5}> | ||
<Title>{t('common:titles.system-wide-notifications')}</Title> | ||
<Button color="indigo" onClick={() => setCreateModalOpen(true)}>{t('common:actions.create-notification')}</Button> | ||
<EntityList cols={cols} rows={notifications ?? []} rowActions={rowActions} /> | ||
</Stack> | ||
{createModalOpen && ( | ||
<CreateSystemWideNotificationModal onClose={() => setCreateModalOpen(false)} refetch={refetch} /> | ||
)} | ||
</Container> | ||
); | ||
} | ||
|
||
export default NotificationsPage; |
Binary file not shown.
Oops, something went wrong.