This commit is contained in:
1 parent
a0c557f9b2
commit
2d4b8ea9cf
17 files changed
+1542
-12
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { apiClient } from '@/lib/api-client.ts'
|
||||
|
||||
export type DevicePlatform = 'ios' | 'android' | 'web'
|
||||
export type NotificationChannel = 'EMAIL' | 'PUSH'
|
||||
|
||||
export interface NotificationPreference {
|
||||
channel: NotificationChannel
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
// CLIENT REQUEST
|
||||
|
||||
export async function deviceTokenRegister(token: string, platform: DevicePlatform = 'web') {
|
||||
return apiClient.post<void>('/api/notifications/device-tokens', { token, platform })
|
||||
}
|
||||
|
||||
export async function deviceTokenRemove(token: string) {
|
||||
return apiClient.delete('/api/notifications/device-tokens', { token })
|
||||
}
|
||||
|
||||
export async function preferencesList() {
|
||||
return apiClient.get<NotificationPreference[]>('/api/notifications/preferences')
|
||||
}
|
||||
|
||||
export async function preferenceSet(channel: NotificationChannel, enabled: boolean) {
|
||||
return apiClient.put<void>(`/api/notifications/preferences/${channel}`, { enabled })
|
||||
}
|
||||
|
||||
export async function testPushSend(title?: string, body?: string) {
|
||||
return apiClient.post<void>('/api/notifications/test-push', { title, body })
|
||||
}
|
||||
Reference in new issue
Block a user