push notification
fix implemented
This commit is contained in:
1 parent
0bbf2ab56f
commit
57864e00da
15 files changed
+5126
-26
No files matched your search
@@ -827,3 +827,41 @@ export async function getUserReaction(
|
||||
}
|
||||
return response.json();
|
||||
}
|
||||
|
||||
// Push Notification Admin Types
|
||||
export interface PushStats {
|
||||
totalSubscribers: number;
|
||||
}
|
||||
|
||||
export interface SendNotificationResult {
|
||||
sent: number;
|
||||
failed: number;
|
||||
}
|
||||
|
||||
export interface SendNotificationDto {
|
||||
title: string;
|
||||
body: string;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
// Push Notification Admin API Functions
|
||||
export async function fetchPushStats(): Promise<PushStats> {
|
||||
const response = await authFetch(`${API_BASE_URL}/push/stats`);
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch push stats');
|
||||
}
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export async function sendPushNotification(
|
||||
dto: SendNotificationDto,
|
||||
): Promise<SendNotificationResult> {
|
||||
const response = await authFetch(`${API_BASE_URL}/push/send`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(dto),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to send push notification');
|
||||
}
|
||||
return response.json();
|
||||
}
|
||||
Reference in new issue
Block a user