the problem was that my if statement:
if (envoi?.paid && envoi?.trackingNumber && envoi?.qrCodeUrl && envoi?.simulationStatus === SimulationStatus.COMPLETED)
which doesn't run because my api backend return an object that contains another object, the soulution i should change my if statement for exemple to be: if(envoi?.envoi.paid)
instead of:
if(envoi?.paid)
Or, update the api response to return directly the 'envoi' object instead of returning it in another object like i had before :
return NextResponse.json({envoi: envoi}, {status: 200});