|
|
@ -14,12 +14,16 @@ import {
|
|
|
|
} from "@mantine/core";
|
|
|
|
} from "@mantine/core";
|
|
|
|
import { useForm } from "@mantine/form";
|
|
|
|
import { useForm } from "@mantine/form";
|
|
|
|
import { isObject } from "lodash";
|
|
|
|
import { isObject } from "lodash";
|
|
|
|
import { FunctionComponent, useMemo } from "react";
|
|
|
|
import { FunctionComponent, useCallback, useMemo } from "react";
|
|
|
|
import { useMutation } from "react-query";
|
|
|
|
import { useMutation } from "react-query";
|
|
|
|
import { Card } from "../components";
|
|
|
|
import { Card } from "../components";
|
|
|
|
import { notificationsKey } from "../keys";
|
|
|
|
import { notificationsKey } from "../keys";
|
|
|
|
import { useSettingValue, useUpdateArray } from "../utilities/hooks";
|
|
|
|
import { useSettingValue, useUpdateArray } from "../utilities/hooks";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const notificationHook = (notifications: Settings.NotificationInfo[]) => {
|
|
|
|
|
|
|
|
return notifications.map((info) => JSON.stringify(info));
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
interface Props {
|
|
|
|
selections: readonly Settings.NotificationInfo[];
|
|
|
|
selections: readonly Settings.NotificationInfo[];
|
|
|
|
payload: Settings.NotificationInfo | null;
|
|
|
|
payload: Settings.NotificationInfo | null;
|
|
|
@ -122,6 +126,13 @@ export const NotificationView: FunctionComponent = () => {
|
|
|
|
"name"
|
|
|
|
"name"
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const updateWrapper = useCallback(
|
|
|
|
|
|
|
|
(info: Settings.NotificationInfo) => {
|
|
|
|
|
|
|
|
update(info, notificationHook);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
[update]
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const modals = useModals();
|
|
|
|
const modals = useModals();
|
|
|
|
|
|
|
|
|
|
|
|
const elements = useMemo(() => {
|
|
|
|
const elements = useMemo(() => {
|
|
|
@ -135,12 +146,12 @@ export const NotificationView: FunctionComponent = () => {
|
|
|
|
modals.openContextModal(NotificationModal, {
|
|
|
|
modals.openContextModal(NotificationModal, {
|
|
|
|
payload,
|
|
|
|
payload,
|
|
|
|
selections: notifications,
|
|
|
|
selections: notifications,
|
|
|
|
onComplete: update,
|
|
|
|
onComplete: updateWrapper,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
></Card>
|
|
|
|
></Card>
|
|
|
|
));
|
|
|
|
));
|
|
|
|
}, [modals, notifications, update]);
|
|
|
|
}, [modals, notifications, updateWrapper]);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<SimpleGrid cols={3}>
|
|
|
|
<SimpleGrid cols={3}>
|
|
|
@ -151,7 +162,7 @@ export const NotificationView: FunctionComponent = () => {
|
|
|
|
modals.openContextModal(NotificationModal, {
|
|
|
|
modals.openContextModal(NotificationModal, {
|
|
|
|
payload: null,
|
|
|
|
payload: null,
|
|
|
|
selections: notifications ?? [],
|
|
|
|
selections: notifications ?? [],
|
|
|
|
onComplete: update,
|
|
|
|
onComplete: updateWrapper,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
></Card>
|
|
|
|
></Card>
|
|
|
|