Skip to content

Commit ddd7ccd

Browse files
committed
2 parents 4e8379c + 6c6a2d0 commit ddd7ccd

File tree

7 files changed

+548
-7
lines changed

7 files changed

+548
-7
lines changed

app.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ module.exports = {
6363
"expo-router",
6464
"expo-font",
6565
"expo-localization",
66+
[
67+
"expo-notifications",
68+
{
69+
icon: "./assets/images/icon.png",
70+
color: "#003A21",
71+
defaultChannel: "default",
72+
},
73+
],
6674
[
6775
"expo-image-picker",
6876
{

app/(settings)/settings.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,14 @@ export default function SettingsIndex() {
258258
{(level || establishment) &&
259259
<Stack direction={"horizontal"} gap={6} style={{ marginTop: 4 }}>
260260
{level &&
261-
<Stack direction={"horizontal"} gap={8} hAlign={"center"} radius={100} backgroundColor={colors.background} inline padding={[12, 3]} card flat style={{ flexShrink: 0 }}>
261+
<Stack direction={"horizontal"} gap={8} hAlign={"center"} radius={100} backgroundColor={colors.background} inline padding={[12, 3]} card flat>
262262
<Typography variant={"body1"} color="secondary">
263263
{level}
264264
</Typography>
265265
</Stack>
266266
}
267267
{establishment &&
268-
<Stack direction={"horizontal"} gap={8} hAlign={"center"} radius={100} backgroundColor={colors.background} inline padding={[12, 3]} card flat style={{ flex: 1 }}>
268+
<Stack direction={"horizontal"} gap={8} hAlign={"center"} radius={100} backgroundColor={colors.background} inline padding={[12, 3]} card flat>
269269
<Typography
270270
variant={"body1"}
271271
color="secondary"

app/._layout.tsx.swp

16 KB
Binary file not shown.

app/_layout.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { AlertProvider } from '@/ui/components/AlertProvider';
3333
import { runsIOS26 } from '@/ui/utils/IsLiquidGlass';
3434
import { AppColors } from "@/utils/colors";
3535
import ModelManager from '@/utils/magic/ModelManager';
36+
import { registerQRCodeNotificationRouting } from '@/utils/restaurant/qrcode-notification';
3637
import { screenOptions } from '@/utils/theme/ScreenOptions';
3738
import { DarkTheme, DefaultTheme } from '@/utils/theme/Theme';
3839

@@ -155,8 +156,8 @@ const RootLayoutNav = React.memo(function RootLayoutNav() {
155156
useEffect(() => {
156157
if (customLanguage) {
157158
// Changing language is asynchronous, so we don't await it
158-
i18n.changeLanguage(customLanguage).catch((error) => {
159-
console.error("Error changing language:", error);
159+
i18n.changeLanguage(customLanguage).catch((error: unknown) => {
160+
// Error changing language
160161
});
161162
}
162163
}, [customLanguage]);
@@ -213,6 +214,10 @@ const RootLayoutNav = React.memo(function RootLayoutNav() {
213214
}
214215
}, [magicEnabled]);
215216

217+
useEffect(() => {
218+
void registerQRCodeNotificationRouting();
219+
}, []);
220+
216221
useEffect(() => {
217222
/*
218223
DONNÉES D'ANALYSE : serveur Countly (https://countly.papillon.bzh)

app/devmode.tsx

Lines changed: 87 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ import Typography from "@/ui/components/Typography";
2020
import { MAGIC_URL } from "@/utils/endpoints";
2121
import { log } from "@/utils/logger/logger";
2222
import ModelManager from "@/utils/magic/ModelManager";
23+
import { sendSmartQRCodeNotification, testQRCodeNotification } from "@/utils/restaurant/qrcode-notification";
2324

2425
export default function Devmode() {
25-
const accountStore = useAccountStore();
26+
const _accountStore = useAccountStore();
2627
const logsStore = useLogStore();
2728
const settingStore = useSettingsStore(state => state.personalization)
2829
const mutateProperty = useSettingsStore(state => state.mutateProperty)
@@ -33,8 +34,10 @@ export default function Devmode() {
3334
const { colors } = useTheme();
3435
const alert = useAlert();
3536

36-
const [showAccountStore, setShowAccountStore] = useState(false);
37+
const [_showAccountStore, _setShowAccountStore] = useState(false);
3738
const [showLogsStore, setShowLogsStore] = useState(false);
39+
const [isTestNotificationLoading, setIsTestNotificationLoading] = useState(false);
40+
const [isSmartNotificationLoading, setIsSmartNotificationLoading] = useState(false);
3841

3942
const [visibleLogsCount, setVisibleLogsCount] = useState(20);
4043

@@ -264,6 +267,80 @@ export default function Devmode() {
264267
</Item>
265268

266269
</List>
270+
<Stack direction="horizontal" gap={10} vAlign="start" hAlign="center" style={{
271+
paddingHorizontal: 6,
272+
paddingVertical: 0,
273+
marginBottom: 14,
274+
opacity: 0.5,
275+
}}>
276+
<Icon>
277+
<Papicons name={"QrCode"} size={18} />
278+
</Icon>
279+
<Typography>
280+
QR Code
281+
</Typography>
282+
</Stack>
283+
284+
<List>
285+
<Item
286+
onPress={async () => {
287+
if (isTestNotificationLoading) { return; } // Éviter les clics multiples
288+
289+
try {
290+
setIsTestNotificationLoading(true);
291+
await testQRCodeNotification();
292+
} catch (error) {
293+
Alert.alert("Erreur", `Erreur lors de l'envoi de la notification: ${String(error)}`);
294+
} finally {
295+
setTimeout(() => {
296+
setIsTestNotificationLoading(false);
297+
}, 3000);
298+
}
299+
}}
300+
>
301+
<Typography variant="title">
302+
{isTestNotificationLoading ? "Envoi en cours..." : "Tester notification QR Code"}
303+
</Typography>
304+
</Item>
305+
<Item
306+
onPress={async () => {
307+
if (isSmartNotificationLoading) { return; } // Éviter les clics multiples
308+
309+
try {
310+
setIsSmartNotificationLoading(true);
311+
312+
// Vérifier d'abord si un service compatible est disponible
313+
const { hasMealBookedToday } = await import("@/utils/restaurant/qrcode-notification");
314+
const bookingInfo = await hasMealBookedToday();
315+
316+
// Priorité 1: Vérifier si un service compatible existe
317+
if (!bookingInfo.serviceId || !bookingInfo.serviceType) {
318+
Alert.alert("Aucun service compatible", "L'utilisateur n'a pas de service compatible (Turboself ou Izly)");
319+
return;
320+
}
321+
322+
// Priorité 2: Vérifier si une réservation existe
323+
if (!bookingInfo.hasBooked) {
324+
const serviceName = bookingInfo.serviceType === 1 ? "Turboself" : "Izly";
325+
Alert.alert("Aucune réservation", `L'utilisateur n'a pas réservé de repas mais utilise ${serviceName}`);
326+
return;
327+
}
328+
329+
await sendSmartQRCodeNotification();
330+
} catch (error) {
331+
Alert.alert("Erreur", `Erreur lors de l'envoi de la notification intelligente: ${String(error)}`);
332+
} finally {
333+
setTimeout(() => {
334+
setIsSmartNotificationLoading(false);
335+
}, 3000);
336+
}
337+
}}
338+
>
339+
<Typography variant="title">
340+
{isSmartNotificationLoading ? "Envoi en cours..." : "Tester notification intelligente"}
341+
</Typography>
342+
</Item>
343+
</List>
267344
<Stack direction="horizontal" gap={10} vAlign="start" hAlign="center" style={{
268345
paddingHorizontal: 6,
269346
paddingVertical: 0,
@@ -326,7 +403,14 @@ export default function Devmode() {
326403
<Typography variant="title">ConsoleLog Magic Store</Typography>
327404
</Item>
328405
<Item
329-
onPress={() => resetMagicCache()}
406+
onPress={() => {
407+
try {
408+
magicStore.clear();
409+
Alert.alert("Cache vidé", "Le cache des prédictions Magic a été vidé avec succès !");
410+
} catch (error) {
411+
Alert.alert("Erreur", `Erreur lors du vidage du cache: ${String(error)}`);
412+
}
413+
}}
330414
>
331415
<Typography variant="title">Reset Magic Cache</Typography>
332416
</Item>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"expo-localization": "~17.0.7",
6464
"expo-location": "~19.0.7",
6565
"expo-network": "~8.0.7",
66+
"expo-notifications": "~0.32.12",
6667
"expo-router": "~6.0.4",
6768
"expo-secure-store": "~15.0.7",
6869
"expo-splash-screen": "~31.0.10",

0 commit comments

Comments
 (0)