chore: add notification livreur

This commit is contained in:
2026-03-02 13:15:15 +01:00
parent 6c8af9acd4
commit d78a5743a1
7 changed files with 1063 additions and 1 deletions
+50
View File
@@ -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",
};
}
};