chore: add notification livreur
This commit is contained in:
@@ -260,3 +260,53 @@ export const getMyAlerts = async (): Promise<{
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// ============================================
|
||||
// NOTIFICATIONS
|
||||
// ============================================
|
||||
|
||||
export type LivreurNotification = {
|
||||
command_id: number;
|
||||
type: string;
|
||||
message: string;
|
||||
created_at: string;
|
||||
read: boolean;
|
||||
};
|
||||
|
||||
export const getLivreurNotifications = async (): Promise<{
|
||||
success: boolean;
|
||||
notifications?: LivreurNotification[];
|
||||
unread_count?: number;
|
||||
total?: number;
|
||||
error?: string;
|
||||
}> => {
|
||||
try {
|
||||
const { data } = await apiClient.get(`${API}/notifications`);
|
||||
return {
|
||||
success: true,
|
||||
notifications: data.notifications || [],
|
||||
unread_count: data.unread_count || 0,
|
||||
total: data.total || 0,
|
||||
};
|
||||
} catch (error: any) {
|
||||
return {
|
||||
success: false,
|
||||
error: error.response?.data?.error || "Erreur réseau",
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export const markLivreurNotificationsRead = async (): Promise<{
|
||||
success: boolean;
|
||||
error?: string;
|
||||
}> => {
|
||||
try {
|
||||
await apiClient.post(`${API}/notifications/read`);
|
||||
return { success: true };
|
||||
} catch (error: any) {
|
||||
return {
|
||||
success: false,
|
||||
error: error.response?.data?.error || "Erreur réseau",
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user