chore: update

This commit is contained in:
2026-03-08 16:33:50 +01:00
parent 712d667d86
commit dc9e812391
5 changed files with 476 additions and 66 deletions
+35 -10
View File
@@ -562,7 +562,6 @@ export const deleteProductMediaAdmin = async (
return { success: true, message: data.message };
};
// ============================================
// ============================================
// ADDRESSES
// ============================================
@@ -711,31 +710,48 @@ export interface AppSettings {
points_enabled: boolean;
points_categories_weed: string[];
points_categories_zipette: string[];
points_categories_total: string[];
points_separated: boolean;
points_weed_tiers: PointsTier[];
points_zipette_tiers: PointsTier[];
points_total_tiers: PointsTier[];
referral_enabled: boolean;
}
export const getSettings = async (): Promise<{ success: boolean; settings?: AppSettings; error?: string }> => {
export const getSettings = async (): Promise<{
success: boolean;
settings?: AppSettings;
error?: string;
}> => {
try {
const { data } = await apiClient.get(`${V2}/admin/protected/settings`);
return { success: true, settings: data.settings };
} catch (error: any) {
return { success: false, error: error.response?.data?.error || "Erreur" };
return {
success: false,
error: error.response?.data?.error || "Erreur",
};
}
};
export const registerAdminPushToken = async (pushToken: string): Promise<void> => {
export const registerAdminPushToken = async (
pushToken: string,
): Promise<void> => {
try {
await apiClient.post(`${V2}/admin/protected/push-token`, { push_token: pushToken });
} catch { /* ignore */ }
await apiClient.post(`${V2}/admin/protected/push-token`, {
push_token: pushToken,
});
} catch {
/* ignore */
}
};
export const unregisterAdminPushToken = async (): Promise<void> => {
try {
await apiClient.delete(`${V2}/admin/protected/push-token`);
} catch { /* ignore */ }
} catch {
/* ignore */
}
};
export interface AppNotification {
@@ -746,7 +762,10 @@ export interface AppNotification {
read: boolean;
}
export const getAdminNotifications = async (): Promise<{ notifications: AppNotification[]; unread_count: number }> => {
export const getAdminNotifications = async (): Promise<{
notifications: AppNotification[];
unread_count: number;
}> => {
const { data } = await apiClient.get(`${V2}/admin/protected/notifications`);
return data;
};
@@ -759,9 +778,15 @@ export const updateSettings = async (
settings: AppSettings,
): Promise<{ success: boolean; settings?: AppSettings; error?: string }> => {
try {
const { data } = await apiClient.put(`${V2}/admin/protected/settings`, settings);
const { data } = await apiClient.put(
`${V2}/admin/protected/settings`,
settings,
);
return { success: true, settings: data.settings };
} catch (error: any) {
return { success: false, error: error.response?.data?.error || "Erreur" };
return {
success: false,
error: error.response?.data?.error || "Erreur",
};
}
};
+60 -6
View File
@@ -351,16 +351,22 @@ export interface PublicSettings {
points_separated: boolean;
}
export const registerCabinePushToken = async (pushToken: string): Promise<void> => {
export const registerCabinePushToken = async (
pushToken: string,
): Promise<void> => {
try {
await apiClient.post(`${API}/push-token`, { push_token: pushToken });
} catch { /* ignore */ }
} catch {
/* ignore */
}
};
export const unregisterCabinePushToken = async (): Promise<void> => {
try {
await apiClient.delete(`${API}/push-token`);
} catch { /* ignore */ }
} catch {
/* ignore */
}
};
export interface AppNotification {
@@ -371,7 +377,10 @@ export interface AppNotification {
read: boolean;
}
export const getCabineNotifications = async (): Promise<{ notifications: AppNotification[]; unread_count: number }> => {
export const getCabineNotifications = async (): Promise<{
notifications: AppNotification[];
unread_count: number;
}> => {
const { data } = await apiClient.get(`${API}/notifications`);
return data;
};
@@ -382,7 +391,9 @@ export const markCabineNotificationsRead = async (): Promise<void> => {
export const getPublicSettings = async (): Promise<PublicSettings> => {
try {
const { data } = await apiClient.get(`http://5.181.0.112/api/v1/app-settings`);
const { data } = await apiClient.get(
`http://5.181.0.112/api/v1/app-settings`,
);
return {
penalties_enabled: data.penalties_enabled ?? true,
show_amende_score: data.show_amende_score ?? true,
@@ -390,6 +401,49 @@ export const getPublicSettings = async (): Promise<PublicSettings> => {
points_separated: data.points_separated ?? true,
};
} catch {
return { penalties_enabled: true, show_amende_score: true, points_enabled: true, points_separated: true };
return {
penalties_enabled: true,
show_amende_score: true,
points_enabled: true,
points_separated: true,
};
}
};
// ============================================
// ADDRESSES
// ============================================
export const addAddress = async (
invalidAddress: string,
correctAddress: string,
): Promise<{ success: boolean; message: string }> => {
const { data } = await apiClient.post(`${API}/add/address`, {
invalid_address: invalidAddress,
correct_address: correctAddress,
});
return { success: true, message: data.message };
};
export const deleteAddress = async (
invalidAddress: string,
correctAddress: string,
): Promise<{ success: boolean; message: string }> => {
const { data } = await apiClient.delete(`${API}/delete/address`, {
data: {
invalid_address: invalidAddress,
correct_address: correctAddress,
},
});
return { success: true, message: data.message };
};
export const getAllAddresses = async (): Promise<
{ invalid_address: string; correct_address: string }[]
> => {
const { data } = await apiClient.get(`${API}/addresses`);
return (data.addresses ?? []).map((a: any) => ({
invalid_address: a.invalid_address ?? a.InvalidAddress ?? "",
correct_address: a.correct_address ?? a.CorrectAddress ?? "",
}));
};