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
+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 ?? "",
}));
};