Skip to content

Commit 468e883

Browse files
committed
feat: introduce success notifications
1 parent fa999e4 commit 468e883

File tree

5 files changed

+82
-5
lines changed

5 files changed

+82
-5
lines changed

apps/frontend/src/routes/_auth/questionnaire/_questionnaire/$id/entries.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
import { Button, formatDate, getDateFromTimeAndWeekday, Group, Stack, useMantineTheme, useDisclosure, Modal, getTime } from "@quassel/ui";
1+
import {
2+
Button,
3+
formatDate,
4+
getDateFromTimeAndWeekday,
5+
Group,
6+
Stack,
7+
useMantineTheme,
8+
useDisclosure,
9+
Modal,
10+
getTime,
11+
notifications,
12+
} from "@quassel/ui";
213
import { createFileRoute, Link, useNavigate } from "@tanstack/react-router";
314
import { i18n } from "../../../../../stores/i18n";
415
import { useStore } from "@nanostores/react";
@@ -31,6 +42,8 @@ const messages = i18n("questionnaireEntries", {
3142
formAction: "Continue",
3243
backAction: "Back",
3344
addEntityLabel: "Add",
45+
notificationSuccessCreateLanguage: "Successfully add a new language.",
46+
notificationSuccessCreateCarer: "Successfully add a new carer.",
3447
});
3548

3649
function QuestionnaireEntries() {
@@ -58,13 +71,15 @@ function QuestionnaireEntries() {
5871
const { data: languages } = $api.useQuery("get", "/languages", { params: { query: { participantId } } });
5972
const createLanguageMutation = $api.useMutation("post", "/languages", {
6073
onSuccess() {
74+
notifications.show({ message: t.notificationSuccessCreateLanguage, color: "uzhGreen" });
6175
c.refetchQueries($api.queryOptions("get", "/languages", { params: { query: { participantId } } }));
6276
},
6377
});
6478

6579
const { data: carers } = $api.useQuery("get", "/carers", { params: { query: { participantId } } });
6680
const createCarerMutation = $api.useMutation("post", "/carers", {
6781
onSuccess() {
82+
notifications.show({ message: t.notificationSuccessCreateCarer, color: "uzhGreen" });
6883
c.refetchQueries($api.queryOptions("get", "/carers", { params: { query: { participantId } } }));
6984
},
7085
});

libs/ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@mantine/core": "^7.14.3",
3030
"@mantine/dates": "^7.14.3",
3131
"@mantine/hooks": "^7.14.3",
32+
"@mantine/notifications": "^7.15.1",
3233
"@tabler/icons-react": "3.17.0",
3334
"dayjs": "^1.11.13",
3435
"react": "^18.3.1",

libs/ui/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Theme
2+
import "@mantine/core/styles.css";
23
import "@mantine/core/styles/global.css";
34
import "@mantine/core/styles/ScrollArea.css";
45
import "@mantine/core/styles/UnstyledButton.css";
@@ -28,8 +29,11 @@ import "@mantine/core/styles/Title.css";
2829
import "@mantine/core/styles/ActionIcon.css";
2930
import "@mantine/core/styles/Combobox.css";
3031
import "@mantine/core/styles/Stack.css";
32+
3133
import "@mantine/dates/styles.css";
3234

35+
import "@mantine/notifications/styles.css";
36+
3337
export { ThemeProvider } from "./theme/ThemeProvider";
3438

3539
// custom components
@@ -70,6 +74,8 @@ export { TimeInput } from "@mantine/dates";
7074

7175
export { useDisclosure } from "@mantine/hooks";
7276

77+
export { notifications } from "@mantine/notifications";
78+
7379
export {
7480
IconLogout,
7581
IconUsers,

libs/ui/src/theme/ThemeProvider.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import dayjs from "dayjs";
55
import utc from "dayjs/plugin/utc";
66
import customParseFormat from "dayjs/plugin/customParseFormat";
77
import de from "dayjs/locale/de";
8+
import { DefaultMantineColor, MantineColorsTuple } from "@mantine/core";
9+
import { Notifications } from "@mantine/notifications";
810

911
dayjs.extend(utc);
1012
dayjs.extend(customParseFormat);
1113
dayjs.locale(de);
1214

13-
import { DefaultMantineColor, MantineColorsTuple } from "@mantine/core";
14-
1515
type ExtendedCustomColors =
1616
| "uzhBlue"
1717
| "uzhCyan"
@@ -53,10 +53,13 @@ export const theme: MantineThemeOverride = {
5353
primaryColor: "uzhBlue",
5454
};
5555

56-
export function ThemeProvider(args: ThemeProviderProps) {
56+
export function ThemeProvider({ children, ...args }: ThemeProviderProps) {
5757
return (
5858
<DatesProvider settings={{ timezone: "UTC" }}>
59-
<MantineProvider {...args} theme={theme} />
59+
<MantineProvider {...args} theme={theme}>
60+
<Notifications />
61+
{children}
62+
</MantineProvider>
6063
</DatesProvider>
6164
);
6265
}

pnpm-lock.yaml

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)