@@ -20,9 +20,10 @@ import Typography from "@/ui/components/Typography";
2020import { MAGIC_URL } from "@/utils/endpoints" ;
2121import { log } from "@/utils/logger/logger" ;
2222import ModelManager from "@/utils/magic/ModelManager" ;
23+ import { sendSmartQRCodeNotification , testQRCodeNotification } from "@/utils/restaurant/qrcode-notification" ;
2324
2425export 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 >
0 commit comments