From 1095c6a4276d4347fa72413beeec40e2b984417b Mon Sep 17 00:00:00 2001 From: Tony Averty Date: Mon, 12 Oct 2026 17:08:47 +0200 Subject: [PATCH] =?UTF-8?q?App=20Pro=20:=20animations=20fluides=20(feuille?= =?UTF-8?q?=20de=20recherche=20client=20anim=C3=A9e,=20bandeaux,=20formula?= =?UTF-8?q?ires,=20onglets,=20listes),=20navigation=20all=C3=A9g=C3=A9e=20?= =?UTF-8?q?(freezeOnBlur)=20;=20script=20de=20cr=C3=A9ation=20du=20magasin?= =?UTF-8?q?=20de=20d=C3=A9monstration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- backend/scripts/create-demo-store.ts | 104 +++++++++++++++++++++++++++ pro/app/_layout.tsx | 2 + pro/app/account.tsx | 4 +- pro/app/campaigns.tsx | 7 +- pro/app/index.tsx | 4 +- pro/app/login.tsx | 5 +- pro/app/loyalty.tsx | 4 +- pro/app/module/[id].tsx | 13 +++- pro/app/scan.tsx | 92 +++++++++++++++--------- pro/app/stats.tsx | 6 +- pro/app/team.tsx | 14 ++-- pro/src/ui.tsx | 18 ++++- 12 files changed, 222 insertions(+), 51 deletions(-) create mode 100644 backend/scripts/create-demo-store.ts diff --git a/backend/scripts/create-demo-store.ts b/backend/scripts/create-demo-store.ts new file mode 100644 index 0000000..1d8bc1e --- /dev/null +++ b/backend/scripts/create-demo-store.ts @@ -0,0 +1,104 @@ +import { PrismaClient } from '@prisma/client'; +import * as argon2 from 'argon2'; +import { randomBytes } from 'crypto'; +import { createTransport } from 'nodemailer'; + +/** + * Crée le magasin de démonstration pour App Review (Apple) : actif d'emblée, formule Pro, + * sans Stripe ni lien de paiement, abonnement valable 3 mois, dirigeant avec mot de passe aléatoire. + * Le mot de passe est envoyé par e-mail à NOTIFY_EMAIL (affiché ici si SMTP n'est pas configuré). + * + * Usage : npx ts-node scripts/create-demo-store.ts + * (le hachage argon2 ne peut pas être produit en SQL pur, d'où ce script plutôt qu'un .sql) + */ +const STAFF_EMAIL = 'demo.apple@gmail.com'; +const NOTIFY_EMAIL = 'tony.prive35@gmail.com'; +const SERIAL_ALPHABET = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789'; +const token = () => randomBytes(24).toString('base64url'); +const serial = () => 'MEP' + [...randomBytes(8)].map((b) => SERIAL_ALPHABET[b % SERIAL_ALPHABET.length]).join(''); +const password = () => [...randomBytes(16)].map((b) => SERIAL_ALPHABET[b % SERIAL_ALPHABET.length]).join('').replace(/(.{4})(?=.)/g, '$1-'); + +async function main() { + try { + process.loadEnvFile(); + } catch { + /* variables déjà dans l'environnement */ + } + const prisma = new PrismaClient(); + if (await prisma.staffUser.findUnique({ where: { email: STAFF_EMAIL } })) { + throw new Error(`${STAFF_EMAIL} existe déjà : rien créé.`); + } + const pwd = password(); + const periodEnd = new Date(); + periodEnd.setMonth(periodEnd.getMonth() + 3); + + const store = await prisma.store.create({ + data: { + slug: 'cafe-demo-' + randomBytes(2).toString('hex'), + name: 'Café Démo', + addressLine: '1 rue de la Démo', + postalCode: '35000', + city: 'Rennes', + siret: '35600000000048', + contactName: 'Tony Averty', + contactEmail: STAFF_EMAIL, + contactPhone: '0612345678', + status: 'ACTIVE', + maxAmountCents: 50000, + minScanIntervalSec: 300, + subscription: { + create: { status: 'ACTIVE', plan: 'PRO', interval: 'MONTH', currentPeriodEnd: periodEnd }, + }, + cardDesign: { + create: { + programName: 'Carte Café Démo', + pointsMode: 'STAMP', + backgroundColor: '#0E7A66', + rewards: { create: [{ label: 'Un café offert', cost: 10 }] }, + }, + }, + staff: { + create: { + email: STAFF_EMAIL, + displayName: 'Tony Averty', + role: 'MANAGER', + passwordHash: await argon2.hash(pwd), + }, + }, + }, + }); + + const customer = await prisma.customer.create({ + data: { firstName: 'Camille', email: 'camille.demo@example.com', consentAt: new Date() }, + }); + const card = await prisma.loyaltyCard.create({ + data: { storeId: store.id, customerId: customer.id, serial: serial(), authToken: token(), accessKey: token() }, + }); + + const summary = [ + `Magasin : ${store.name} (${store.id}), actif, formule Pro, valable jusqu'au ${periodEnd.toLocaleDateString('fr-FR')}`, + `Connexion app : ${STAFF_EMAIL}`, + `Client de démo : Camille — carte ${card.serial.replace(/(.{4})/g, '$1 ').trim()}`, + `Mot de passe : ${pwd}`, + ].join('\n'); + + if (process.env.SMTP_HOST) { + const transport = createTransport({ + host: process.env.SMTP_HOST, + port: Number(process.env.SMTP_PORT ?? 587), + secure: Number(process.env.SMTP_PORT) === 465, + auth: process.env.SMTP_USER ? { user: process.env.SMTP_USER, pass: process.env.SMTP_PASS } : undefined, + }); + await transport.sendMail({ + from: process.env.MAIL_FROM, + to: NOTIFY_EMAIL, + subject: 'Compte de démonstration App Review', + text: summary, + }); + console.log(summary.replace(/Mot de passe : .*/, 'Mot de passe : envoyé par e-mail à ' + NOTIFY_EMAIL)); + } else { + console.log('SMTP non configuré — voici le récapitulatif (à noter) :\n' + summary); + } + await prisma.$disconnect(); +} +main(); diff --git a/pro/app/_layout.tsx b/pro/app/_layout.tsx index 82dc994..5335448 100644 --- a/pro/app/_layout.tsx +++ b/pro/app/_layout.tsx @@ -37,6 +37,8 @@ function Navigator() { headerTitleStyle: { fontFamily: font.bold }, headerBackButtonDisplayMode: 'minimal', contentStyle: { backgroundColor: c.bg }, + // Les écrans masqués par une transition ne se re-rendent plus : navigation plus fluide. + freezeOnBlur: true, }} > diff --git a/pro/app/account.tsx b/pro/app/account.tsx index d47a73e..580f640 100644 --- a/pro/app/account.tsx +++ b/pro/app/account.tsx @@ -3,7 +3,7 @@ import { Alert, Pressable, ScrollView, Switch, TextInput, View } from 'react-nat import { api, ApiError } from '../src/api'; import { describe } from '../src/errors'; import { useSession } from '../src/session'; -import { Banner, Button, Card, T } from '../src/ui'; +import { smooth, Banner, Button, Card, T } from '../src/ui'; import { font, useColors } from '../src/theme'; import { useScanSound } from '../src/prefs'; import { confirmIdentity } from '../src/biometrics'; @@ -27,6 +27,7 @@ export default function Account() { await api.post('/api/staff/password', { current, next }); setCurrent(''); setNext(''); + smooth(); setDone(true); } catch (e) { setError(describe(e).detail); @@ -82,6 +83,7 @@ export default function Account() { setError(null); try { await api.post('/api/staff/me/deletion-request'); + smooth(); setRequested(true); } catch (e) { setError(describe(e).detail); diff --git a/pro/app/campaigns.tsx b/pro/app/campaigns.tsx index a05814b..6b790b3 100644 --- a/pro/app/campaigns.tsx +++ b/pro/app/campaigns.tsx @@ -4,7 +4,7 @@ import { useFocusEffect } from 'expo-router'; import { api } from '../src/api'; import { describe } from '../src/errors'; import { useStore } from '../src/session'; -import { Banner, Button, Card, T } from '../src/ui'; +import { smooth, Banner, Button, Card, T } from '../src/ui'; import { font, useColors } from '../src/theme'; import { Icon } from '../src/icons'; import { confirmIdentity } from '../src/biometrics'; @@ -35,7 +35,9 @@ export default function Campaigns() { const load = useCallback(async () => { try { - setData(await api.get('/api/staff/campaigns')); + const next = await api.get('/api/staff/campaigns'); + smooth(); + setData(next); } catch (e) { setError(describe(e).detail); } @@ -61,6 +63,7 @@ export default function Campaigns() { try { await api.post('/api/staff/campaigns', { message: text, title: (title ?? data!.defaultTitle).trim() }); setMessage(''); + smooth(); setSent(true); await load(); } catch (e) { diff --git a/pro/app/index.tsx b/pro/app/index.tsx index dfdffa0..e66244c 100644 --- a/pro/app/index.tsx +++ b/pro/app/index.tsx @@ -5,7 +5,7 @@ import { SafeAreaView } from 'react-native-safe-area-context'; import Svg, { Path } from 'react-native-svg'; import { api, API_URL, Summary } from '../src/api'; import { useSession, useStore } from '../src/session'; -import { BrandSymbol, Button, Card, T, unit } from '../src/ui'; +import { smooth, BrandSymbol, Button, Card, T, unit } from '../src/ui'; import { font, useColors } from '../src/theme'; import { Icon, IconName } from '../src/icons'; @@ -155,7 +155,7 @@ function Counter() { key={k} accessibilityRole="tab" accessibilityState={{ selected: tab === k }} - onPress={() => setTab(k)} + onPress={() => { smooth(); setTab(k); }} style={{ flex: 1, paddingVertical: 10, borderRadius: 10, alignItems: 'center', backgroundColor: tab === k ? c.primary : 'transparent' }} > {label} diff --git a/pro/app/login.tsx b/pro/app/login.tsx index 3ce7c05..c976fbe 100644 --- a/pro/app/login.tsx +++ b/pro/app/login.tsx @@ -4,7 +4,7 @@ import { SafeAreaView } from 'react-native-safe-area-context'; import { useSession } from '../src/session'; import { api } from '../src/api'; import { describe } from '../src/errors'; -import { Banner, BrandSymbol, Button, Card, T } from '../src/ui'; +import { smooth, Banner, BrandSymbol, Button, Card, T } from '../src/ui'; import { font, useColors } from '../src/theme'; /** Connexion (Dirigeant et employés) : mêmes identifiants que l'espace web. */ @@ -27,6 +27,7 @@ export default function Login() { setError(null); try { await api.postPublic('/api/public/mot-de-passe/oubli', { email: email.trim() }); + smooth(); setForgotDone(true); } catch (e) { setError(describe(e).detail); @@ -118,7 +119,7 @@ export default function Login() { />