mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
notifications: notification settings page
This commit is contained in:
parent
d77a01d8bc
commit
7135d06673
17 changed files with 319 additions and 35 deletions
|
@ -1,17 +1,22 @@
|
|||
import { API } from '~/constants/api';
|
||||
import { NotificationSettings } from '~/types/notifications';
|
||||
import { api, cleanResult } from '~/utils/api';
|
||||
import {
|
||||
notificationSettingsFromRequest,
|
||||
notificationSettingsToRequest,
|
||||
} from '~/utils/notifications/notificationSettingsFromRequest';
|
||||
|
||||
import {
|
||||
ApiGetNotificationSettingsResponse,
|
||||
ApiGetNotificationsResponse,
|
||||
ApiUpdateNotificationSettingsResponse,
|
||||
ApiUpdateNotificationSettingsRequest,
|
||||
} from './types';
|
||||
|
||||
export const apiGetNotificationSettings = () =>
|
||||
export const apiGetNotificationSettings = (): Promise<NotificationSettings> =>
|
||||
api
|
||||
.get<ApiGetNotificationSettingsResponse>(API.NOTIFICATIONS.SETTINGS)
|
||||
.then(cleanResult);
|
||||
.then(cleanResult)
|
||||
.then(notificationSettingsFromRequest);
|
||||
|
||||
export const apiGetNotifications = () =>
|
||||
api
|
||||
|
@ -19,11 +24,12 @@ export const apiGetNotifications = () =>
|
|||
.then(cleanResult);
|
||||
|
||||
export const apiUpdateNotificationSettings = (
|
||||
settings: ApiUpdateNotificationSettingsRequest,
|
||||
settings: Partial<NotificationSettings>,
|
||||
) =>
|
||||
api
|
||||
.post<ApiUpdateNotificationSettingsResponse>(
|
||||
API.NOTIFICATIONS.SETTINGS,
|
||||
settings,
|
||||
notificationSettingsToRequest(settings),
|
||||
)
|
||||
.then(cleanResult);
|
||||
.then(cleanResult)
|
||||
.then(notificationSettingsFromRequest);
|
||||
|
|
|
@ -4,6 +4,8 @@ export interface ApiGetNotificationSettingsResponse {
|
|||
enabled: boolean;
|
||||
flow: boolean;
|
||||
comments: boolean;
|
||||
send_telegram: boolean;
|
||||
show_indicator: boolean;
|
||||
last_seen?: string | null;
|
||||
last_date?: string | null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue