From: Thibaud Moustier Date: Sun, 1 Mar 2026 17:30:36 +0000 (+0100) Subject: Mobile : modification icon, etc X-Git-Url: https://git.digitality.be/?a=commitdiff_plain;h=18c1ac9f4c79de6e93807385834e2245ae516f06;p=pdw25-26 Mobile : modification icon, etc --- diff --git a/Wallette/mobile/app.json b/Wallette/mobile/app.json index 106ddd5..b4c5e7f 100644 --- a/Wallette/mobile/app.json +++ b/Wallette/mobile/app.json @@ -2,7 +2,7 @@ "expo": { "name": "wall-e-tte", "slug": "wall-e-tte", - "version": "1.0.0", + "version": "1.0.1", "orientation": "portrait", "icon": "./assets/icon.png", "userInterfaceStyle": "light", diff --git a/Wallette/mobile/assets/adaptive-icon.png b/Wallette/mobile/assets/adaptive-icon.png index 03d6f6b..3d0f5be 100644 Binary files a/Wallette/mobile/assets/adaptive-icon.png and b/Wallette/mobile/assets/adaptive-icon.png differ diff --git a/Wallette/mobile/assets/favicon.png b/Wallette/mobile/assets/favicon.png index e75f697..e5e3966 100644 Binary files a/Wallette/mobile/assets/favicon.png and b/Wallette/mobile/assets/favicon.png differ diff --git a/Wallette/mobile/assets/icon.png b/Wallette/mobile/assets/icon.png index a0b1526..2d2747a 100644 Binary files a/Wallette/mobile/assets/icon.png and b/Wallette/mobile/assets/icon.png differ diff --git a/Wallette/mobile/assets/splash-icon.png b/Wallette/mobile/assets/splash-icon.png index 03d6f6b..658e38e 100644 Binary files a/Wallette/mobile/assets/splash-icon.png and b/Wallette/mobile/assets/splash-icon.png differ diff --git a/Wallette/mobile/src/screens/StrategyScreen.tsx b/Wallette/mobile/src/screens/StrategyScreen.tsx index 17e0af9..5c445df 100644 --- a/Wallette/mobile/src/screens/StrategyScreen.tsx +++ b/Wallette/mobile/src/screens/StrategyScreen.tsx @@ -3,24 +3,28 @@ import { useEffect, useState } from "react"; import { SafeAreaView } from "react-native-safe-area-context"; import { ui } from "../components/ui/uiStyles"; -import { loadSettings } from "../utils/settingsStorage"; +import { loadSettings, saveSettings } from "../utils/settingsStorage"; import type { UserSettings } from "../models/UserSettings"; import type { StrategyKey, StrategyOption } from "../types/Strategy"; import { fetchStrategies } from "../services/strategyService"; -/** - * ✅ API-ready (façade) - * Aujourd'hui : update local settings - * Demain : POST /api/strategy/select - */ import { selectStrategy } from "../services/api/strategyApi"; +/** + * StrategyScreen + * -------------- + * Maintenant : + * - On garde la liste locale (fetchStrategies) + * - On sync vers serveur : POST /api/strategy/select + * - On met à jour le settings local pour affichage immédiat + */ export default function StrategyScreen() { const [settings, setSettings] = useState(null); const [strategies, setStrategies] = useState([]); const [loading, setLoading] = useState(true); const [info, setInfo] = useState(null); + const [busy, setBusy] = useState(false); useEffect(() => { let active = true; @@ -56,11 +60,29 @@ export default function StrategyScreen() { const isSelected = (key: StrategyKey) => settings.selectedStrategyKey === key; const handleSelect = async (key: StrategyKey) => { - // ✅ Façade : aujourd'hui local, demain API - const updated = await selectStrategy(key); - - setSettings(updated); - setInfo(`Stratégie sélectionnée : ${key}`); + try { + setBusy(true); + setInfo(null); + + // 1) Update local immédiat (UX + dashboard) + const next: UserSettings = { ...settings, selectedStrategyKey: key }; + await saveSettings(next); + setSettings(next); + + // 2) Sync serveur (contrat Stéphane) + // Pair cible : pour l’instant BTC/EUR (comme le dashboard). Si vous passez multi-crypto, on l’adaptera. + await selectStrategy({ + pair: "BTC/EUR", + mode: key, + params: {}, // si un jour tu as des paramètres, tu les mets ici + }); + + setInfo(`Stratégie sélectionnée : ${key} ✅ (sync serveur OK)`); + } catch (e: any) { + setInfo(`Erreur serveur stratégie : ${e?.message ?? "inconnue"}`); + } finally { + setBusy(false); + } }; return ( @@ -97,11 +119,13 @@ export default function StrategyScreen() { ui.button, styles.fullButton, isSelected(item.key) && styles.btnSelected, + busy && styles.btnDisabled, ]} onPress={() => handleSelect(item.key)} + disabled={busy} > - {isSelected(item.key) ? "Sélectionnée ✅" : "Sélectionner"} + {isSelected(item.key) ? "Sélectionnée ✅" : busy ? "Envoi..." : "Sélectionner"} @@ -137,6 +161,10 @@ const styles = StyleSheet.create({ opacity: 0.9, }, + btnDisabled: { + opacity: 0.6, + }, + riskTag: { fontWeight: "900", opacity: 0.75, diff --git a/Wallette/mobile/src/services/api/strategyApi.ts b/Wallette/mobile/src/services/api/strategyApi.ts index dccd3ff..60395ff 100644 --- a/Wallette/mobile/src/services/api/strategyApi.ts +++ b/Wallette/mobile/src/services/api/strategyApi.ts @@ -1,24 +1,37 @@ import { apiPost } from "./http"; import { loadSession } from "../../utils/sessionStorage"; -import type { UserSettings } from "../../models/UserSettings"; +import type { StrategyKey } from "../../types/Strategy"; /** - * strategyApi (API-only) - * ---------------------- + * strategyApi (API) + * ----------------- + * Contrat (objectif) : * POST /api/strategy/select + * Body: + * { + * userId: string, + * pair: "BTC/EUR", + * mode: "RSI_SIMPLE" | "MA_CROSS" | ..., + * params: object + * } + * + * Réponse possible : + * - { ok:true, data:{ ... } } (géré par http.ts) + * - ou une réponse vide -> on considère que c'est OK si pas d'erreur HTTP */ -export async function selectStrategy(strategyKey: string): Promise { +export async function selectStrategy(params: { + pair: string; // ex: "BTC/EUR" + mode: StrategyKey; // ex: "RSI_SIMPLE" + params?: Record; +}): Promise { const session = await loadSession(); const userId = session?.userId; if (!userId) throw new Error("Session absente : impossible de sélectionner une stratégie."); - // Le backend décidera quoi renvoyer : settings mis à jour ou juste ok. - // On part sur "settings" pour éviter de recharger partout. - const data = await apiPost<{ settings: UserSettings }>(`/strategy/select`, { + await apiPost(`/strategy/select`, { userId, - strategyKey, + pair: params.pair, + mode: params.mode, + params: params.params ?? {}, }); - - if (!data.settings) throw new Error("Réponse API invalide : settings manquant."); - return data.settings; } \ No newline at end of file