From dc4d146e3dbc7276b441041cf5d23afac41b2980 Mon Sep 17 00:00:00 2001 From: Atanas Yonkov Date: Mon, 27 Feb 2023 16:19:07 +0200 Subject: [PATCH] Add option to undismiss a reminder on frontend --- .../components/Namespaces/Reminders/List.vue | 3 +-- .../components/Namespaces/Reminders/index.vue | 14 +++++++--- lib/js/src/api-clients/system.ts | 26 +++++++++++++++++++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/client/web/compose/src/components/Namespaces/Reminders/List.vue b/client/web/compose/src/components/Namespaces/Reminders/List.vue index 41e25bb37..f28aa9315 100644 --- a/client/web/compose/src/components/Namespaces/Reminders/List.vue +++ b/client/web/compose/src/components/Namespaces/Reminders/List.vue @@ -23,8 +23,7 @@ { - this.fetchReminders() - }) + onDismiss (r, value) { + if (value) { + this.$SystemAPI.reminderDismiss(r).then(() => { + this.fetchReminders() + }) + } else { + this.$SystemAPI.reminderUndismiss(r).then(() => { + this.fetchReminders() + }) + } }, onDelete (r) { diff --git a/lib/js/src/api-clients/system.ts b/lib/js/src/api-clients/system.ts index 8936673f9..fa3d61885 100644 --- a/lib/js/src/api-clients/system.ts +++ b/lib/js/src/api-clients/system.ts @@ -2590,6 +2590,25 @@ export default class System { return this.api().request(cfg).then(result => stdResolve(result)) } + // Undismiss reminder + async reminderUndismiss (a: KV, extra: AxiosRequestConfig = {}): Promise { + const { + reminderID, + } = (a as KV) || {} + if (!reminderID) { + throw Error('field reminderID is empty') + } + const cfg: AxiosRequestConfig = { + ...extra, + method: 'patch', + url: this.reminderUndismissEndpoint({ + reminderID, + }), + } + + return this.api().request(cfg).then(result => stdResolve(result)) + } + reminderDismissEndpoint (a: KV): string { const { reminderID, @@ -2597,6 +2616,13 @@ export default class System { return `/reminder/${reminderID}/dismiss` } + reminderUndismissEndpoint (a: KV): string { + const { + reminderID, + } = a || {} + return `/reminder/${reminderID}/undismiss` + } + // Snooze reminder async reminderSnooze (a: KV, extra: AxiosRequestConfig = {}): Promise { const {