Files
hipmi-mobile/service/api-notifications.ts
bagasbanuna d098b8ca16 Setup notifikasi untuk android
Fix:
- modified:   service/api-notifications.ts
- modified:   types/type-notification-category.ts

### No Issue
2026-01-05 12:27:23 +08:00

73 lines
1.6 KiB
TypeScript

import { TypeNotificationCategoryApp, TypeOfTilteCategoryApp } from "@/types/type-notification-category";
import { apiConfig } from "./api-config";
type NotificationProp = {
title: TypeOfTilteCategoryApp;
body: string;
userLoginId: string;
appId?: string;
status?: string;
type?: "announcement" | "trigger";
deepLink?: string;
kategoriApp?: TypeNotificationCategoryApp
};
export async function apiNotificationsSend({
data,
}: {
data: NotificationProp;
}) {
try {
const response = await apiConfig.post(`/mobile/notification`, {
data: data,
});
return response.data;
} catch (error) {
throw error;
}
}
export async function apiGetNotificationsById({
id,
category,
}: {
id: string;
category: TypeNotificationCategoryApp
}) {
console.log("ID", id);
console.log("Category", category);
try {
const response = await apiConfig.get(
`/mobile/notification/${id}?category=${category}`
);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiNotificationUnreadCount({ id, role }: { id: string, role: "user" | "admin" }) {
try {
const response = await apiConfig.get(
`/mobile/notification/${id}/unread-count?role=${role}`
);
console.log("Response Unread Count", response.data);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiNotificationMarkAsRead({id}: {id: string}) {
try {
const response = await apiConfig.put(`/mobile/notification/${id}`);
return response.data;
} catch (error) {
throw error;
}
}