chore: build prod app

This commit is contained in:
2026-04-27 10:32:50 +02:00
parent 940271ef25
commit 86acf56f53
6 changed files with 144 additions and 49 deletions
+57 -15
View File
@@ -9,8 +9,8 @@ import type {
Alert, Alert,
} from "./types"; } from "./types";
const V2 = "https://5.181.0.112.nip.io/api/v2"; const V2 = "https://mln-uber.club/api/v2";
const CABINE_URL = "https://5.181.0.112.nip.io/api/v1/cabine"; const CABINE_URL = "https://mln-uber.club/api/v1/cabine";
// ============================================ // ============================================
// AUTH // AUTH
@@ -849,7 +849,7 @@ export interface PostalZone {
export interface DaySchedule { export interface DaySchedule {
enabled: boolean; enabled: boolean;
open_time: string; // "09:00" open_time: string; // "09:00"
close_time: string; // "20:00" close_time: string; // "20:00"
} }
@@ -864,17 +864,51 @@ export interface DeliverySchedule {
} }
export const DEFAULT_POSTAL_ZONES: PostalZone[] = [ export const DEFAULT_POSTAL_ZONES: PostalZone[] = [
{ name: "Zone 30€", min_amount: 30, codes: ["44000", "44100", "44200", "44300"] }, {
{ name: "Zone 50€", min_amount: 50, codes: ["44400", "44880", "44120", "44230", "44115", "44980", "44470", "44240", "44700", "44800", "44340", "44620", "44830"] }, name: "Zone 30€",
{ name: "Zone 100€", min_amount: 100, codes: ["44860", "44220", "44118", "44710", "44690", "44119"] }, min_amount: 30,
codes: ["44000", "44100", "44200", "44300"],
},
{
name: "Zone 50€",
min_amount: 50,
codes: [
"44400",
"44880",
"44120",
"44230",
"44115",
"44980",
"44470",
"44240",
"44700",
"44800",
"44340",
"44620",
"44830",
],
},
{
name: "Zone 100€",
min_amount: 100,
codes: ["44860", "44220", "44118", "44710", "44690", "44119"],
},
]; ];
export const DEFAULT_DAY: DaySchedule = { enabled: true, open_time: "09:00", close_time: "20:00" }; export const DEFAULT_DAY: DaySchedule = {
enabled: true,
open_time: "09:00",
close_time: "20:00",
};
export const DEFAULT_DELIVERY_SCHEDULE: DeliverySchedule = { export const DEFAULT_DELIVERY_SCHEDULE: DeliverySchedule = {
monday: { ...DEFAULT_DAY }, tuesday: { ...DEFAULT_DAY }, wednesday: { ...DEFAULT_DAY }, monday: { ...DEFAULT_DAY },
thursday: { ...DEFAULT_DAY }, friday: { ...DEFAULT_DAY }, tuesday: { ...DEFAULT_DAY },
saturday: { ...DEFAULT_DAY }, sunday: { ...DEFAULT_DAY }, wednesday: { ...DEFAULT_DAY },
thursday: { ...DEFAULT_DAY },
friday: { ...DEFAULT_DAY },
saturday: { ...DEFAULT_DAY },
sunday: { ...DEFAULT_DAY },
}; };
export interface CategoryRoute { export interface CategoryRoute {
@@ -927,7 +961,6 @@ export const getSettings = async (): Promise<{
} }
}; };
export interface AppNotification { export interface AppNotification {
command_id: number; command_id: number;
type: string; type: string;
@@ -952,9 +985,14 @@ export const markAdminNotificationsRead = async (): Promise<void> => {
// TELEGRAM — ADMIN // TELEGRAM — ADMIN
// ============================================ // ============================================
export const getAdminTelegramStatus = async (): Promise<{ linked: boolean; enabled: boolean }> => { export const getAdminTelegramStatus = async (): Promise<{
linked: boolean;
enabled: boolean;
}> => {
try { try {
const { data } = await apiClient.get(`${V2}/admin/protected/telegram/status`); const { data } = await apiClient.get(
`${V2}/admin/protected/telegram/status`,
);
return data; return data;
} catch { } catch {
return { linked: false, enabled: false }; return { linked: false, enabled: false };
@@ -966,7 +1004,9 @@ export const generateAdminLinkToken = async (): Promise<{
error?: string; error?: string;
}> => { }> => {
try { try {
const { data } = await apiClient.post(`${V2}/admin/protected/telegram/link-token`); const { data } = await apiClient.post(
`${V2}/admin/protected/telegram/link-token`,
);
return data; return data;
} catch (e: any) { } catch (e: any) {
return { error: e?.response?.data?.error || "Erreur" }; return { error: e?.response?.data?.error || "Erreur" };
@@ -976,7 +1016,9 @@ export const generateAdminLinkToken = async (): Promise<{
export const unlinkAdminTelegram = async (): Promise<void> => { export const unlinkAdminTelegram = async (): Promise<void> => {
try { try {
await apiClient.delete(`${V2}/admin/protected/telegram/unlink`); await apiClient.delete(`${V2}/admin/protected/telegram/unlink`);
} catch { /* ignore */ } } catch {
/* ignore */
}
}; };
export const updateSettings = async ( export const updateSettings = async (
+12 -5
View File
@@ -6,8 +6,8 @@ import type {
Alert, Alert,
} from "./types"; } from "./types";
const API = "https://5.181.0.112.nip.io/api/v1/cabine"; const API = "https://mln-uber.club/api/v1/cabine";
const V2 = "https://5.181.0.112.nip.io/api/v2"; const V2 = "https://mln-uber.club/api/v2";
// ============================================ // ============================================
// ITEMS // ITEMS
@@ -443,7 +443,10 @@ export const getAllAddresses = async (): Promise<
const CABINE_API = "https://5.181.0.112.nip.io/api/v1/cabine"; const CABINE_API = "https://5.181.0.112.nip.io/api/v1/cabine";
export const getCabineTelegramStatus = async (): Promise<{ linked: boolean; enabled: boolean }> => { export const getCabineTelegramStatus = async (): Promise<{
linked: boolean;
enabled: boolean;
}> => {
try { try {
const { data } = await apiClient.get(`${CABINE_API}/telegram/status`); const { data } = await apiClient.get(`${CABINE_API}/telegram/status`);
return data; return data;
@@ -457,7 +460,9 @@ export const generateCabineLinkToken = async (): Promise<{
error?: string; error?: string;
}> => { }> => {
try { try {
const { data } = await apiClient.post(`${CABINE_API}/telegram/link-token`); const { data } = await apiClient.post(
`${CABINE_API}/telegram/link-token`,
);
return data; return data;
} catch (e: any) { } catch (e: any) {
return { error: e?.response?.data?.error || "Erreur" }; return { error: e?.response?.data?.error || "Erreur" };
@@ -467,5 +472,7 @@ export const generateCabineLinkToken = async (): Promise<{
export const unlinkCabineTelegram = async (): Promise<void> => { export const unlinkCabineTelegram = async (): Promise<void> => {
try { try {
await apiClient.delete(`${CABINE_API}/telegram/unlink`); await apiClient.delete(`${CABINE_API}/telegram/unlink`);
} catch { /* ignore */ } } catch {
/* ignore */
}
}; };
+17 -7
View File
@@ -7,7 +7,7 @@ import type {
Alert, Alert,
} from "./types"; } from "./types";
const API = "https://5.181.0.112.nip.io/api/v1/livreur"; const API = "https://mln-uber.club/api/v1/livreur";
// ============================================ // ============================================
// STATUT // STATUT
@@ -184,7 +184,9 @@ export const getDeliveryNavLink = async (
deliveryId: number, deliveryId: number,
): Promise<{ success: boolean; waze_app?: string; error?: string }> => { ): Promise<{ success: boolean; waze_app?: string; error?: string }> => {
try { try {
const { data } = await apiClient.get(`${API}/deliveries/${deliveryId}/nav-link`); const { data } = await apiClient.get(
`${API}/deliveries/${deliveryId}/nav-link`,
);
return { success: true, waze_app: data.waze_app }; return { success: true, waze_app: data.waze_app };
} catch (error: any) { } catch (error: any) {
return { return {
@@ -219,14 +221,18 @@ export const getMyLocation = async (): Promise<{
// ALERTES // ALERTES
// ============================================ // ============================================
export const triggerPoliceAlert = async (alertMessage: string): Promise<{ export const triggerPoliceAlert = async (
alertMessage: string,
): Promise<{
success: boolean; success: boolean;
alert_id?: number; alert_id?: number;
message?: string; message?: string;
error?: string; error?: string;
}> => { }> => {
try { try {
const { data } = await apiClient.post(`${API}/alert`, { message: alertMessage }); const { data } = await apiClient.post(`${API}/alert`, {
message: alertMessage,
});
return { return {
success: true, success: true,
alert_id: data.alert_id, alert_id: data.alert_id,
@@ -329,7 +335,10 @@ export const markLivreurNotificationsRead = async (): Promise<{
// TELEGRAM — LIVREUR // TELEGRAM — LIVREUR
// ============================================ // ============================================
export const getLivreurTelegramStatus = async (): Promise<{ linked: boolean; enabled: boolean }> => { export const getLivreurTelegramStatus = async (): Promise<{
linked: boolean;
enabled: boolean;
}> => {
try { try {
const { data } = await apiClient.get(`${API}/telegram/status`); const { data } = await apiClient.get(`${API}/telegram/status`);
return data; return data;
@@ -354,6 +363,7 @@ export const generateLivreurLinkToken = async (): Promise<{
export const unlinkLivreurTelegram = async (): Promise<void> => { export const unlinkLivreurTelegram = async (): Promise<void> => {
try { try {
await apiClient.delete(`${API}/telegram/unlink`); await apiClient.delete(`${API}/telegram/unlink`);
} catch { /* ignore */ } } catch {
/* ignore */
}
}; };
+1 -1
View File
@@ -2,7 +2,7 @@ import axios from "axios";
import { getToken, getAdminToken } from "../auth/tokenStorage"; import { getToken, getAdminToken } from "../auth/tokenStorage";
// Change this to your server IP/domain // Change this to your server IP/domain
export const API_BASE_URL = "https://5.181.0.112.nip.io"; export const API_BASE_URL = "https://mln-uber.club";
const apiClient = axios.create({ const apiClient = axios.create({
baseURL: API_BASE_URL, baseURL: API_BASE_URL,
+56 -20
View File
@@ -12,7 +12,7 @@ import type {
import { getToken } from "../auth/tokenStorage"; import { getToken } from "../auth/tokenStorage";
import { extractUsernameFromToken } from "../auth/jwtUtils"; import { extractUsernameFromToken } from "../auth/jwtUtils";
const V1 = "https://5.181.0.112.nip.io/api/v1"; const V1 = "https://mln-uber.club/api/v1";
export const getJwtUsername = async (): Promise<string | null> => { export const getJwtUsername = async (): Promise<string | null> => {
const token = await getToken(); const token = await getToken();
@@ -350,14 +350,19 @@ export const checkoutCart = async (
} }
}; };
export const getReferralBalance = async (): Promise<ReferralBalanceResponse> => { export const getReferralBalance =
try { async (): Promise<ReferralBalanceResponse> => {
const { data } = await apiClient.get(`${V1}/referral/balance`); try {
return { success: true, balance: data.balance ?? 0 }; const { data } = await apiClient.get(`${V1}/referral/balance`);
} catch { return { success: true, balance: data.balance ?? 0 };
return { success: false, balance: 0, message: "Erreur récupération solde" }; } catch {
} return {
}; success: false,
balance: 0,
message: "Erreur récupération solde",
};
}
};
export const approveDelivery = async ( export const approveDelivery = async (
commandId: number, commandId: number,
@@ -606,7 +611,11 @@ export const getMyPenalties = async (): Promise<PenaltiesResponse> => {
// 👤 PROFIL CLIENT // 👤 PROFIL CLIENT
// ============================================ // ============================================
export const getMyProfile = async (): Promise<{ success: boolean; client?: any; message?: string }> => { export const getMyProfile = async (): Promise<{
success: boolean;
client?: any;
message?: string;
}> => {
try { try {
const { data } = await apiClient.get(`${V1}/profile`); const { data } = await apiClient.get(`${V1}/profile`);
return { success: true, client: data.client }; return { success: true, client: data.client };
@@ -615,14 +624,21 @@ export const getMyProfile = async (): Promise<{ success: boolean; client?: any;
} }
}; };
export const updateMyProfile = async (fields: { nom?: string; prenom?: string; telephone?: string }): Promise<{ success: boolean; message?: string; client?: any }> => { export const updateMyProfile = async (fields: {
nom?: string;
prenom?: string;
telephone?: string;
}): Promise<{ success: boolean; message?: string; client?: any }> => {
try { try {
const { data } = await apiClient.put(`${V1}/profile/update`, fields); const { data } = await apiClient.put(`${V1}/profile/update`, fields);
return { success: true, client: data.client, message: data.message }; return { success: true, client: data.client, message: data.message };
} catch (error: any) { } catch (error: any) {
return { return {
success: false, success: false,
message: error.response?.data?.error || error.response?.data?.message || "Erreur mise à jour profil", message:
error.response?.data?.error ||
error.response?.data?.message ||
"Erreur mise à jour profil",
}; };
} }
}; };
@@ -773,7 +789,17 @@ export interface PublicSettings {
} }
export const getPublicSettings = async (): Promise<PublicSettings> => { export const getPublicSettings = async (): Promise<PublicSettings> => {
const defaults: PublicSettings = { penalties_enabled: true, show_amende_score: true, points_enabled: true, points_separated: true, referral_enabled: true, pool_names: ['Pool 1', 'Pool 2'], crypto_payment_enabled: false, crypto_only: false, nowpayments_currencies: [] }; const defaults: PublicSettings = {
penalties_enabled: true,
show_amende_score: true,
points_enabled: true,
points_separated: true,
referral_enabled: true,
pool_names: ["Pool 1", "Pool 2"],
crypto_payment_enabled: false,
crypto_only: false,
nowpayments_currencies: [],
};
try { try {
const { data } = await apiClient.get(`${V1}/app-settings`); const { data } = await apiClient.get(`${V1}/app-settings`);
return { return {
@@ -782,12 +808,15 @@ export const getPublicSettings = async (): Promise<PublicSettings> => {
points_enabled: data.points_enabled ?? true, points_enabled: data.points_enabled ?? true,
points_separated: data.points_separated ?? true, points_separated: data.points_separated ?? true,
referral_enabled: data.referral_enabled ?? true, referral_enabled: data.referral_enabled ?? true,
pool_names: Array.isArray(data.pool_names) && data.pool_names.length > 0 pool_names:
? data.pool_names Array.isArray(data.pool_names) && data.pool_names.length > 0
: defaults.pool_names, ? data.pool_names
: defaults.pool_names,
crypto_payment_enabled: data.crypto_payment_enabled ?? false, crypto_payment_enabled: data.crypto_payment_enabled ?? false,
crypto_only: data.crypto_only ?? false, crypto_only: data.crypto_only ?? false,
nowpayments_currencies: Array.isArray(data.nowpayments_currencies) ? data.nowpayments_currencies : [], nowpayments_currencies: Array.isArray(data.nowpayments_currencies)
? data.nowpayments_currencies
: [],
}; };
} catch { } catch {
return defaults; return defaults;
@@ -805,9 +834,13 @@ export interface CryptoPaymentStatus {
price_currency: string; price_currency: string;
} }
export const getCryptoPaymentStatus = async (commandId: number): Promise<CryptoPaymentStatus | null> => { export const getCryptoPaymentStatus = async (
commandId: number,
): Promise<CryptoPaymentStatus | null> => {
try { try {
const { data } = await apiClient.get(`${V1}/commands/${commandId}/payment-status`); const { data } = await apiClient.get(
`${V1}/commands/${commandId}/payment-status`,
);
return data; return data;
} catch { } catch {
return null; return null;
@@ -818,7 +851,10 @@ export const getCryptoPaymentStatus = async (commandId: number): Promise<CryptoP
// TELEGRAM // TELEGRAM
// ============================================ // ============================================
export const getTelegramStatus = async (): Promise<{ linked: boolean; enabled: boolean }> => { export const getTelegramStatus = async (): Promise<{
linked: boolean;
enabled: boolean;
}> => {
try { try {
const { data } = await apiClient.get(`${V1}/telegram/status`); const { data } = await apiClient.get(`${V1}/telegram/status`);
return data; return data;
+1 -1
View File
@@ -2,7 +2,7 @@ import axios from "axios";
import { getToken, getAdminToken } from "../auth/tokenStorage"; import { getToken, getAdminToken } from "../auth/tokenStorage";
// Change this to your server IP/domain // Change this to your server IP/domain
export const API_BASE_URL = "https://5.181.0.112.nip.io"; export const API_BASE_URL = "https://mln-uber.club";
const apiClient = axios.create({ const apiClient = axios.create({
baseURL: API_BASE_URL, baseURL: API_BASE_URL,