diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js index 6298de3..f6a042d 100644 --- a/frontend/src/lib/pt-br-locale.test.js +++ b/frontend/src/lib/pt-br-locale.test.js @@ -27,11 +27,11 @@ describe('Brazilian Portuguese locale', () => { .sort(byCodeUnit) const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex') - expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(342) - expect(inherited).toHaveLength(463) + expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(354) + expect(inherited).toHaveLength(475) // If this fails, review the changed keys and wording before accepting a new hash. From // frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list - expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('cafd0b6fde9f8261563b5040aa6e1278f5b469dc2d6b9c81d7d5554bb6825a05') + expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('d379a3a509af71a6773017d3374938c2067cc870bbf7bd5bbc0bb8ad853d0781') }) test('does not leak European Portuguese UI terms', () => { diff --git a/frontend/src/lib/qr.test.js b/frontend/src/lib/qr.test.js new file mode 100644 index 0000000..dfb7eb4 --- /dev/null +++ b/frontend/src/lib/qr.test.js @@ -0,0 +1,51 @@ +import { describe, it, expect } from 'vitest' +import { normalizeFmt, canRenderFmt } from './qr.js' + +// The QR helpers decide which scanned/typed codes the check-in feature will store: it can read +// many symbologies but only redraw QR, so canRenderFmt is the gate, and normalizeFmt is what +// folds every spelling mlkit might report into the single token everything else compares on. + +describe('normalizeFmt', () => { + it('folds every QR spelling to "qrcode"', () => { + // mlkit's BarcodeFormat, the enum-ish casings, and the casual 'qr' all mean the same thing. + expect(normalizeFmt('QR_CODE')).toBe('qrcode') + expect(normalizeFmt('QrCode')).toBe('qrcode') + expect(normalizeFmt('qrcode')).toBe('qrcode') + expect(normalizeFmt('qr')).toBe('qrcode') + expect(normalizeFmt('QR')).toBe('qrcode') + }) + + it('lower-cases and strips separators for other formats', () => { + expect(normalizeFmt('EAN_13')).toBe('ean13') + expect(normalizeFmt('Code128')).toBe('code128') + expect(normalizeFmt('CODE_128')).toBe('code128') + }) + + it('treats empty / nullish as an empty token rather than throwing', () => { + expect(normalizeFmt('')).toBe('') + expect(normalizeFmt(null)).toBe('') + expect(normalizeFmt(undefined)).toBe('') + }) +}) + +describe('canRenderFmt', () => { + it('accepts only QR, in any spelling', () => { + expect(canRenderFmt('QR_CODE')).toBe(true) + expect(canRenderFmt('QrCode')).toBe(true) + expect(canRenderFmt('qr')).toBe(true) + }) + + it('rejects 1D and other 2D symbologies we cannot faithfully redraw', () => { + // These are readable by the scanner but lean-qr can't reproduce them, so a card in one of + // these formats must never be stored — it would display as the wrong bars at the turnstile. + for (const fmt of ['EAN_13', 'EAN_8', 'CODE_128', 'CODE_39', 'ITF', 'UPC_A', 'PDF_417', 'AZTEC', 'DATA_MATRIX']) { + expect(canRenderFmt(fmt)).toBe(false) + } + }) + + it('rejects empty / unknown formats', () => { + expect(canRenderFmt('')).toBe(false) + expect(canRenderFmt(null)).toBe(false) + expect(canRenderFmt('something-else')).toBe(false) + }) +}) diff --git a/frontend/src/lib/scan.test.js b/frontend/src/lib/scan.test.js new file mode 100644 index 0000000..07941db --- /dev/null +++ b/frontend/src/lib/scan.test.js @@ -0,0 +1,18 @@ +import { describe, it, expect } from 'vitest' +import { scanCode, importCodeFromImage } from './scan.js' + +// In the test environment VITE_MOBILE is unset, so MOBILE is false — the same as a web build. +// Both capture paths must refuse to run there rather than reach for a native plugin that isn't +// present. (The happy-path decoding is exercised on-device; here we pin the guard that keeps the +// scanner out of every non-mobile build.) + +describe('scan guards off mobile', () => { + it('scanCode rejects when not in the mobile build', async () => { + await expect(scanCode()).rejects.toThrow(/only available in the app/) + }) + + it('importCodeFromImage rejects when not in the mobile build', async () => { + const fakeFile = new Blob(['x'], { type: 'image/png' }) + await expect(importCodeFromImage(fakeFile)).rejects.toThrow(/only available in the app/) + }) +}) diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js index 0059d37..740e50b 100644 --- a/frontend/src/locales/de.js +++ b/frontend/src/locales/de.js @@ -760,4 +760,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Auf 0 stellen, um zum Standard ({0}) zurückzukehren.', 'Applies to this exercise everywhere, not just this plan.': 'Gilt überall für diese Übung, nicht nur in diesem Plan.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Eingetragen wird weiterhin das Gesamtgewicht — die Stange zählt nur für die Scheiben-Rechnung pro Seite.', + // Gym check-in (mobile-only) + 'Check in': 'Einchecken', + 'At the gym': 'Im Studio', + 'Show this at the gym': 'Im Studio vorzeigen', + 'Add your gym card': 'Studio-Karte hinzufügen', + 'Add a card': 'Karte hinzufügen', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Tippe die Nummer deiner Mitgliedskarte ein, importiere ein Foto oder scanne sie mit der Kamera. Keine zusätzliche App im Studio nötig — öffne einfach diesen Bildschirm.', + 'Remove this card?': 'Diese Karte entfernen?', + 'Scan it, import a photo, or type the code by hand.': 'Scanne sie, importiere ein Foto oder tippe den Code von Hand ein.', + 'Scan': 'Scannen', + 'Import photo': 'Foto importieren', + 'Label': 'Bezeichnung', + 'e.g. FitZone downtown': 'z. B. FitZone Zentrum', + 'Code': 'Code', + 'Membership number or code': 'Mitgliedsnummer oder Code', + 'Save card': 'Karte speichern', + 'Gym card': 'Studio-Karte', + 'Card added': 'Karte hinzugefügt', + 'Nothing to save yet': 'Noch nichts zu speichern', + "That's not a QR code — only QR cards can be shown here": 'Das ist kein QR-Code — hier lassen sich nur QR-Karten anzeigen', + 'No QR code found in that image': 'Kein QR-Code im Bild gefunden', + 'Could not read that image': 'Bild konnte nicht gelesen werden', + 'Camera permission is needed to scan. Enable it in Settings.': 'Zum Scannen wird die Kamera-Berechtigung benötigt. Aktiviere sie in den Einstellungen.', + 'Scanning is not available on this device.': 'Scannen ist auf diesem Gerät nicht verfügbar.', + 'Could not start the scanner': 'Scanner konnte nicht gestartet werden', } diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js index 7765ede..b524f01 100644 --- a/frontend/src/locales/fr.js +++ b/frontend/src/locales/fr.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Mets 0 pour revenir à la valeur par défaut ({0}).', 'Applies to this exercise everywhere, not just this plan.': 'S’applique à cet exercice partout, pas seulement dans ce plan.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Tu enregistres toujours le poids total — la barre ne sert qu’au calcul des disques par côté.', + // Gym check-in (mobile-only) + 'Check in': 'Enregistrement', + 'At the gym': 'À la salle', + 'Show this at the gym': 'À présenter à la salle', + 'Add your gym card': 'Ajoute ta carte de salle', + 'Add a card': 'Ajouter une carte', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Saisis le numéro de ta carte de membre, importe une photo ou scanne-la avec l’appareil photo. Aucune autre appli nécessaire à la salle — ouvre simplement cet écran.', + 'Remove this card?': 'Supprimer cette carte ?', + 'Scan it, import a photo, or type the code by hand.': 'Scanne-la, importe une photo ou saisis le code à la main.', + 'Scan': 'Scanner', + 'Import photo': 'Importer une photo', + 'Label': 'Libellé', + 'e.g. FitZone downtown': 'p. ex. FitZone centre-ville', + 'Code': 'Code', + 'Membership number or code': 'Numéro de membre ou code', + 'Save card': 'Enregistrer la carte', + 'Gym card': 'Carte de salle', + 'Card added': 'Carte ajoutée', + 'Nothing to save yet': 'Rien à enregistrer pour l’instant', + "That's not a QR code — only QR cards can be shown here": 'Ce n’est pas un code QR — seules les cartes QR peuvent être affichées ici', + 'No QR code found in that image': 'Aucun code QR trouvé dans cette image', + 'Could not read that image': 'Impossible de lire cette image', + 'Camera permission is needed to scan. Enable it in Settings.': 'L’autorisation caméra est nécessaire pour scanner. Active-la dans les Réglages.', + 'Scanning is not available on this device.': 'Le scan n’est pas disponible sur cet appareil.', + 'Could not start the scanner': 'Impossible de démarrer le scanner', } diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js index 4096f21..919577d 100644 --- a/frontend/src/locales/hi.js +++ b/frontend/src/locales/hi.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'डिफ़ॉल्ट ({0}) पर लौटने के लिए 0 सेट करें।', 'Applies to this exercise everywhere, not just this plan.': 'यह इस एक्सरसाइज़ पर हर जगह लागू होता है, सिर्फ़ इसी प्लान पर नहीं।', 'You still log the total weight — the bar only feeds the per-side plate math.': 'आप अब भी कुल वज़न ही दर्ज करते हैं — बार सिर्फ़ हर तरफ़ की प्लेट गिनती में काम आता है।', + // Gym check-in (mobile-only) + 'Check in': 'चेक इन', + 'At the gym': 'जिम में', + 'Show this at the gym': 'इसे जिम में दिखाएँ', + 'Add your gym card': 'अपना जिम कार्ड जोड़ें', + 'Add a card': 'कार्ड जोड़ें', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'अपने मेंबरशिप कार्ड का नंबर लिखें, उसकी फ़ोटो इम्पोर्ट करें, या कैमरे से स्कैन करें। जिम में किसी और ऐप की ज़रूरत नहीं — बस यह स्क्रीन खोलें।', + 'Remove this card?': 'यह कार्ड हटाएँ?', + 'Scan it, import a photo, or type the code by hand.': 'इसे स्कैन करें, फ़ोटो इम्पोर्ट करें, या कोड हाथ से लिखें।', + 'Scan': 'स्कैन करें', + 'Import photo': 'फ़ोटो इम्पोर्ट करें', + 'Label': 'लेबल', + 'e.g. FitZone downtown': 'जैसे FitZone डाउनटाउन', + 'Code': 'कोड', + 'Membership number or code': 'मेंबरशिप नंबर या कोड', + 'Save card': 'कार्ड सहेजें', + 'Gym card': 'जिम कार्ड', + 'Card added': 'कार्ड जोड़ा गया', + 'Nothing to save yet': 'अभी सहेजने के लिए कुछ नहीं', + "That's not a QR code — only QR cards can be shown here": 'यह QR कोड नहीं है — यहाँ केवल QR कार्ड दिखाए जा सकते हैं', + 'No QR code found in that image': 'उस छवि में कोई QR कोड नहीं मिला', + 'Could not read that image': 'वह छवि पढ़ी नहीं जा सकी', + 'Camera permission is needed to scan. Enable it in Settings.': 'स्कैन करने के लिए कैमरा अनुमति चाहिए। इसे सेटिंग्स में चालू करें।', + 'Scanning is not available on this device.': 'इस डिवाइस पर स्कैनिंग उपलब्ध नहीं है।', + 'Could not start the scanner': 'स्कैनर शुरू नहीं हो सका', } diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js index fd2b760..89c98f2 100644 --- a/frontend/src/locales/hu.js +++ b/frontend/src/locales/hu.js @@ -748,4 +748,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Állítsd 0-ra az alapérték ({0}) visszaállításához.', 'Applies to this exercise everywhere, not just this plan.': 'Mindenhol érvényes erre a gyakorlatra, nem csak ebben a tervben.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Továbbra is a teljes súlyt rögzíted — a rúd csak az oldalankénti tárcsaszámításhoz kell.', + // Gym check-in (mobile-only) + 'Check in': 'Bejelentkezés', + 'At the gym': 'A teremben', + 'Show this at the gym': 'Mutasd fel a teremben', + 'Add your gym card': 'Add hozzá a terembérleted', + 'Add a card': 'Kártya hozzáadása', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Írd be a tagsági kártyád számát, importálj róla egy fotót, vagy olvasd be a kamerával. Nincs szükség külön alkalmazásra a teremben — csak nyisd meg ezt a képernyőt.', + 'Remove this card?': 'Törlöd ezt a kártyát?', + 'Scan it, import a photo, or type the code by hand.': 'Olvasd be, importálj egy fotót, vagy írd be a kódot kézzel.', + 'Scan': 'Beolvasás', + 'Import photo': 'Fotó importálása', + 'Label': 'Címke', + 'e.g. FitZone downtown': 'pl. FitZone belváros', + 'Code': 'Kód', + 'Membership number or code': 'Tagsági szám vagy kód', + 'Save card': 'Kártya mentése', + 'Gym card': 'Terembérlet', + 'Card added': 'Kártya hozzáadva', + 'Nothing to save yet': 'Még nincs mit menteni', + "That's not a QR code — only QR cards can be shown here": 'Ez nem QR-kód — itt csak QR-kártyák jeleníthetők meg', + 'No QR code found in that image': 'Nem található QR-kód a képen', + 'Could not read that image': 'A kép nem olvasható be', + 'Camera permission is needed to scan. Enable it in Settings.': 'A beolvasáshoz kameraengedély szükséges. Engedélyezd a Beállításokban.', + 'Scanning is not available on this device.': 'A beolvasás nem érhető el ezen az eszközön.', + 'Could not start the scanner': 'A szkenner nem indítható el', } diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js index 8f80be2..7aef968 100644 --- a/frontend/src/locales/it.js +++ b/frontend/src/locales/it.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Imposta 0 per tornare al valore predefinito ({0}).', 'Applies to this exercise everywhere, not just this plan.': 'Vale per questo esercizio ovunque, non solo in questo piano.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Registri comunque il peso totale — il bilanciere serve solo al calcolo dei dischi per lato.', + // Gym check-in (mobile-only) + 'Check in': 'Check-in', + 'At the gym': 'In palestra', + 'Show this at the gym': 'Mostralo in palestra', + 'Add your gym card': 'Aggiungi la tua tessera', + 'Add a card': 'Aggiungi una tessera', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Digita il numero della tua tessera, importa una foto o scansionala con la fotocamera. Nessuna app extra in palestra — apri semplicemente questa schermata.', + 'Remove this card?': 'Rimuovere questa tessera?', + 'Scan it, import a photo, or type the code by hand.': 'Scansionala, importa una foto o digita il codice a mano.', + 'Scan': 'Scansiona', + 'Import photo': 'Importa foto', + 'Label': 'Etichetta', + 'e.g. FitZone downtown': 'es. FitZone centro', + 'Code': 'Codice', + 'Membership number or code': 'Numero tessera o codice', + 'Save card': 'Salva tessera', + 'Gym card': 'Tessera palestra', + 'Card added': 'Tessera aggiunta', + 'Nothing to save yet': 'Ancora niente da salvare', + "That's not a QR code — only QR cards can be shown here": 'Non è un codice QR — qui si possono mostrare solo tessere QR', + 'No QR code found in that image': 'Nessun codice QR trovato nell’immagine', + 'Could not read that image': 'Impossibile leggere l’immagine', + 'Camera permission is needed to scan. Enable it in Settings.': 'Per scansionare serve l’autorizzazione alla fotocamera. Attivala nelle Impostazioni.', + 'Scanning is not available on this device.': 'La scansione non è disponibile su questo dispositivo.', + 'Could not start the scanner': 'Impossibile avviare lo scanner', } diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js index d341d8a..19f8c0d 100644 --- a/frontend/src/locales/ko.js +++ b/frontend/src/locales/ko.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': '0으로 두면 기본값({0})으로 돌아갑니다.', 'Applies to this exercise everywhere, not just this plan.': '이 플랜만이 아니라 어디서든 이 운동에 적용됩니다.', 'You still log the total weight — the bar only feeds the per-side plate math.': '기록은 여전히 총 무게입니다 — 바 무게는 한쪽에 끼울 원판 계산에만 쓰입니다.', + // Gym check-in (mobile-only) + 'Check in': '체크인', + 'At the gym': '헬스장에서', + 'Show this at the gym': '헬스장에서 이것을 보여주세요', + 'Add your gym card': '헬스장 카드 추가', + 'Add a card': '카드 추가', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': '멤버십 카드 번호를 입력하거나, 사진을 가져오거나, 카메라로 스캔하세요. 헬스장에서 별도 앱이 필요 없이 이 화면만 열면 됩니다.', + 'Remove this card?': '이 카드를 삭제할까요?', + 'Scan it, import a photo, or type the code by hand.': '스캔하거나 사진을 가져오거나 코드를 직접 입력하세요.', + 'Scan': '스캔', + 'Import photo': '사진 가져오기', + 'Label': '이름', + 'e.g. FitZone downtown': '예: FitZone 시내점', + 'Code': '코드', + 'Membership number or code': '회원 번호 또는 코드', + 'Save card': '카드 저장', + 'Gym card': '헬스장 카드', + 'Card added': '카드가 추가되었습니다', + 'Nothing to save yet': '아직 저장할 내용이 없습니다', + "That's not a QR code — only QR cards can be shown here": 'QR 코드가 아닙니다 — 여기서는 QR 카드만 표시할 수 있습니다', + 'No QR code found in that image': '이미지에서 QR 코드를 찾을 수 없습니다', + 'Could not read that image': '이미지를 읽을 수 없습니다', + 'Camera permission is needed to scan. Enable it in Settings.': '스캔하려면 카메라 권한이 필요합니다. 설정에서 켜세요.', + 'Scanning is not available on this device.': '이 기기에서는 스캔을 사용할 수 없습니다.', + 'Could not start the scanner': '스캐너를 시작할 수 없습니다', } diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js index d3668cd..aba75e4 100644 --- a/frontend/src/locales/pl.js +++ b/frontend/src/locales/pl.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Ustaw 0, aby wrócić do wartości domyślnej ({0}).', 'Applies to this exercise everywhere, not just this plan.': 'Dotyczy tego ćwiczenia wszędzie, nie tylko w tym planie.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Nadal zapisujesz ciężar całkowity — gryf służy tylko do wyliczenia talerzy na stronę.', + // Gym check-in (mobile-only) + 'Check in': 'Zamelduj się', + 'At the gym': 'Na siłowni', + 'Show this at the gym': 'Pokaż to na siłowni', + 'Add your gym card': 'Dodaj kartę siłowni', + 'Add a card': 'Dodaj kartę', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Wpisz numer karty członkowskiej, zaimportuj jej zdjęcie lub zeskanuj aparatem. Na siłowni nie potrzebujesz osobnej aplikacji — po prostu otwórz ten ekran.', + 'Remove this card?': 'Usunąć tę kartę?', + 'Scan it, import a photo, or type the code by hand.': 'Zeskanuj ją, zaimportuj zdjęcie lub wpisz kod ręcznie.', + 'Scan': 'Skanuj', + 'Import photo': 'Importuj zdjęcie', + 'Label': 'Etykieta', + 'e.g. FitZone downtown': 'np. FitZone centrum', + 'Code': 'Kod', + 'Membership number or code': 'Numer członkowski lub kod', + 'Save card': 'Zapisz kartę', + 'Gym card': 'Karta siłowni', + 'Card added': 'Dodano kartę', + 'Nothing to save yet': 'Nie ma jeszcze nic do zapisania', + "That's not a QR code — only QR cards can be shown here": 'To nie jest kod QR — tutaj można pokazać tylko karty QR', + 'No QR code found in that image': 'Nie znaleziono kodu QR na tym obrazie', + 'Could not read that image': 'Nie udało się odczytać tego obrazu', + 'Camera permission is needed to scan. Enable it in Settings.': 'Do skanowania potrzebne jest pozwolenie na aparat. Włącz je w Ustawieniach.', + 'Scanning is not available on this device.': 'Skanowanie nie jest dostępne na tym urządzeniu.', + 'Could not start the scanner': 'Nie udało się uruchomić skanera', } diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js index f57f794..ee3e43a 100644 --- a/frontend/src/locales/pt-BR.js +++ b/frontend/src/locales/pt-BR.js @@ -357,7 +357,20 @@ export const PT_BR_OVERRIDES = { 'Default for this bar type.': 'Padrão para este tipo de barra.', 'Set to 0 to go back to the default ({0}).': 'Defina 0 para voltar ao padrão ({0}).', 'Applies to this exercise everywhere, not just this plan.': 'Vale para este exercício em todos os lugares, não só neste plano.', - 'You still log the total weight — the bar only feeds the per-side plate math.': 'Você continua registrando o peso total — a barra só entra no cálculo das anilhas por lado.' + 'You still log the total weight — the bar only feeds the per-side plate math.': 'Você continua registrando o peso total — a barra só entra no cálculo das anilhas por lado.', + // Gym check-in (mobile-only) — only where pt-BR differs from pt (inherited via ...pt) + 'At the gym': 'Na academia', + 'Show this at the gym': 'Mostre isto na academia', + 'Add your gym card': 'Adicione seu cartão da academia', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Digite o número do seu cartão de sócio, importe uma foto ou escaneie com a câmera. Não é preciso outro app na academia — é só abrir esta tela.', + 'Scan it, import a photo, or type the code by hand.': 'Escaneie, importe uma foto ou digite o código à mão.', + 'Scan': 'Escanear', + 'e.g. FitZone downtown': 'ex. FitZone centro', + 'Gym card': 'Cartão da academia', + 'Could not read that image': 'Não foi possível ler essa imagem', + 'Camera permission is needed to scan. Enable it in Settings.': 'É necessária a permissão da câmera para escanear. Ative-a nos Ajustes.', + 'Scanning is not available on this device.': 'O escaneamento não está disponível neste dispositivo.', + 'Could not start the scanner': 'Não foi possível iniciar o scanner' } export default { ...pt, ...PT_BR_OVERRIDES } diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js index 67c2ef2..391f79b 100644 --- a/frontend/src/locales/pt.js +++ b/frontend/src/locales/pt.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Coloca 0 para voltar à predefinição ({0}).', 'Applies to this exercise everywhere, not just this plan.': 'Aplica-se a este exercício em todo o lado, não só neste plano.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Continuas a registar o peso total — a barra só conta para o cálculo dos discos por lado.', + // Gym check-in (mobile-only) + 'Check in': 'Check-in', + 'At the gym': 'No ginásio', + 'Show this at the gym': 'Mostra isto no ginásio', + 'Add your gym card': 'Adiciona o teu cartão de sócio', + 'Add a card': 'Adicionar um cartão', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Escreve o número do teu cartão de sócio, importa uma foto ou digitaliza-o com a câmara. Não é preciso outra app no ginásio — basta abrir este ecrã.', + 'Remove this card?': 'Remover este cartão?', + 'Scan it, import a photo, or type the code by hand.': 'Digitaliza-o, importa uma foto ou escreve o código à mão.', + 'Scan': 'Digitalizar', + 'Import photo': 'Importar foto', + 'Label': 'Etiqueta', + 'e.g. FitZone downtown': 'p. ex. FitZone centro', + 'Code': 'Código', + 'Membership number or code': 'Número de sócio ou código', + 'Save card': 'Guardar cartão', + 'Gym card': 'Cartão do ginásio', + 'Card added': 'Cartão adicionado', + 'Nothing to save yet': 'Ainda não há nada para guardar', + "That's not a QR code — only QR cards can be shown here": 'Isto não é um código QR — aqui só podem ser mostrados cartões QR', + 'No QR code found in that image': 'Nenhum código QR encontrado nessa imagem', + 'Could not read that image': 'Não foi possível ler essa imagem', + 'Camera permission is needed to scan. Enable it in Settings.': 'É necessária a permissão da câmara para digitalizar. Ativa-a nas Definições.', + 'Scanning is not available on this device.': 'A digitalização não está disponível neste dispositivo.', + 'Could not start the scanner': 'Não foi possível iniciar o scanner', } diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js index 93dd646..dddad4e 100644 --- a/frontend/src/locales/ru.js +++ b/frontend/src/locales/ru.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Поставь 0, чтобы вернуться к значению по умолчанию ({0}).', 'Applies to this exercise everywhere, not just this plan.': 'Действует для этого упражнения везде, а не только в этом плане.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Записывается по-прежнему общий вес — гриф нужен только для расчёта блинов на сторону.', + // Gym check-in (mobile-only) + 'Check in': 'Отметиться', + 'At the gym': 'В зале', + 'Show this at the gym': 'Покажите это в зале', + 'Add your gym card': 'Добавьте карту зала', + 'Add a card': 'Добавить карту', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Введите номер клубной карты, импортируйте её фото или отсканируйте камерой. В зале не нужно отдельное приложение — просто откройте этот экран.', + 'Remove this card?': 'Удалить эту карту?', + 'Scan it, import a photo, or type the code by hand.': 'Отсканируйте её, импортируйте фото или введите код вручную.', + 'Scan': 'Сканировать', + 'Import photo': 'Импортировать фото', + 'Label': 'Название', + 'e.g. FitZone downtown': 'напр. FitZone в центре', + 'Code': 'Код', + 'Membership number or code': 'Номер участника или код', + 'Save card': 'Сохранить карту', + 'Gym card': 'Карта зала', + 'Card added': 'Карта добавлена', + 'Nothing to save yet': 'Пока нечего сохранять', + "That's not a QR code — only QR cards can be shown here": 'Это не QR-код — здесь можно показывать только QR-карты', + 'No QR code found in that image': 'На изображении не найден QR-код', + 'Could not read that image': 'Не удалось прочитать изображение', + 'Camera permission is needed to scan. Enable it in Settings.': 'Для сканирования нужен доступ к камере. Включите его в настройках.', + 'Scanning is not available on this device.': 'Сканирование недоступно на этом устройстве.', + 'Could not start the scanner': 'Не удалось запустить сканер', } diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js index e7c9406..b8ffd5e 100644 --- a/frontend/src/locales/th.js +++ b/frontend/src/locales/th.js @@ -756,4 +756,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'ตั้งเป็น 0 เพื่อกลับไปใช้ค่าเริ่มต้น ({0})', 'Applies to this exercise everywhere, not just this plan.': 'มีผลกับท่านี้ทุกที่ ไม่ใช่เฉพาะในแผนนี้', 'You still log the total weight — the bar only feeds the per-side plate math.': 'คุณยังบันทึกน้ำหนักรวมเหมือนเดิม — บาร์ใช้สำหรับคำนวณแผ่นน้ำหนักต่อข้างเท่านั้น', + // Gym check-in (mobile-only) + 'Check in': 'เช็คอิน', + 'At the gym': 'ที่ยิม', + 'Show this at the gym': 'แสดงสิ่งนี้ที่ยิม', + 'Add your gym card': 'เพิ่มบัตรสมาชิกยิมของคุณ', + 'Add a card': 'เพิ่มบัตร', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'พิมพ์หมายเลขบนบัตรสมาชิก นำเข้ารูปถ่าย หรือสแกนด้วยกล้อง ไม่ต้องใช้แอปอื่นที่ยิม — แค่เปิดหน้าจอนี้', + 'Remove this card?': 'ลบบัตรนี้หรือไม่?', + 'Scan it, import a photo, or type the code by hand.': 'สแกน นำเข้ารูปถ่าย หรือพิมพ์รหัสด้วยตนเอง', + 'Scan': 'สแกน', + 'Import photo': 'นำเข้ารูปถ่าย', + 'Label': 'ป้ายชื่อ', + 'e.g. FitZone downtown': 'เช่น FitZone ใจกลางเมือง', + 'Code': 'รหัส', + 'Membership number or code': 'หมายเลขสมาชิกหรือรหัส', + 'Save card': 'บันทึกบัตร', + 'Gym card': 'บัตรยิม', + 'Card added': 'เพิ่มบัตรแล้ว', + 'Nothing to save yet': 'ยังไม่มีอะไรให้บันทึก', + "That's not a QR code — only QR cards can be shown here": 'นี่ไม่ใช่คิวอาร์โค้ด — ที่นี่แสดงได้เฉพาะบัตรคิวอาร์โค้ดเท่านั้น', + 'No QR code found in that image': 'ไม่พบคิวอาร์โค้ดในรูปภาพนั้น', + 'Could not read that image': 'ไม่สามารถอ่านรูปภาพนั้นได้', + 'Camera permission is needed to scan. Enable it in Settings.': 'ต้องมีสิทธิ์กล้องเพื่อสแกน เปิดใช้งานในการตั้งค่า', + 'Scanning is not available on this device.': 'อุปกรณ์นี้ไม่รองรับการสแกน', + 'Could not start the scanner': 'ไม่สามารถเริ่มเครื่องสแกนได้', } diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js index 0ccd514..963912b 100644 --- a/frontend/src/locales/tr.js +++ b/frontend/src/locales/tr.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Varsayılana ({0}) dönmek için 0 yap.', 'Applies to this exercise everywhere, not just this plan.': 'Yalnızca bu planda değil, bu egzersiz için her yerde geçerli.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Yine de toplam ağırlığı kaydedersin — bar yalnızca taraf başına plaka hesabına girer.', + // Gym check-in (mobile-only) + 'Check in': 'Giriş yap', + 'At the gym': 'Salonda', + 'Show this at the gym': 'Bunu salonda göster', + 'Add your gym card': 'Salon kartını ekle', + 'Add a card': 'Kart ekle', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Üyelik kartındaki numarayı yaz, fotoğrafını içe aktar ya da kamerayla tara. Salonda ekstra bir uygulamaya gerek yok — sadece bu ekranı aç.', + 'Remove this card?': 'Bu kart kaldırılsın mı?', + 'Scan it, import a photo, or type the code by hand.': 'Tara, bir fotoğraf içe aktar ya da kodu elle yaz.', + 'Scan': 'Tara', + 'Import photo': 'Fotoğraf içe aktar', + 'Label': 'Etiket', + 'e.g. FitZone downtown': 'örn. FitZone merkez', + 'Code': 'Kod', + 'Membership number or code': 'Üyelik numarası veya kodu', + 'Save card': 'Kartı kaydet', + 'Gym card': 'Salon kartı', + 'Card added': 'Kart eklendi', + 'Nothing to save yet': 'Henüz kaydedilecek bir şey yok', + "That's not a QR code — only QR cards can be shown here": 'Bu bir QR kod değil — burada yalnızca QR kartlar gösterilebilir', + 'No QR code found in that image': 'Bu görüntüde QR kod bulunamadı', + 'Could not read that image': 'Bu görüntü okunamadı', + 'Camera permission is needed to scan. Enable it in Settings.': 'Taramak için kamera izni gerekir. Ayarlar’dan etkinleştir.', + 'Scanning is not available on this device.': 'Tarama bu cihazda kullanılamıyor.', + 'Could not start the scanner': 'Tarayıcı başlatılamadı', } diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js index 2580efb..72b7cfb 100644 --- a/frontend/src/locales/zh.js +++ b/frontend/src/locales/zh.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': '设为 0 即恢复默认值({0})。', 'Applies to this exercise everywhere, not just this plan.': '对这个动作处处生效,不只在此计划中。', 'You still log the total weight — the bar only feeds the per-side plate math.': '记录的仍是总重量——杆重只用于每侧杠铃片的计算。', + // Gym check-in (mobile-only) + 'Check in': '签到', + 'At the gym': '在健身房', + 'Show this at the gym': '在健身房出示这个', + 'Add your gym card': '添加你的会员卡', + 'Add a card': '添加卡片', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': '输入会员卡上的号码、导入卡片照片,或用相机扫描。在健身房无需额外应用——打开此界面即可。', + 'Remove this card?': '删除这张卡片?', + 'Scan it, import a photo, or type the code by hand.': '扫描它、导入照片,或手动输入代码。', + 'Scan': '扫描', + 'Import photo': '导入照片', + 'Label': '名称', + 'e.g. FitZone downtown': '例如 FitZone 市中心店', + 'Code': '代码', + 'Membership number or code': '会员号或代码', + 'Save card': '保存卡片', + 'Gym card': '健身房卡片', + 'Card added': '已添加卡片', + 'Nothing to save yet': '暂无可保存的内容', + "That's not a QR code — only QR cards can be shown here": '这不是二维码——此处只能显示二维码卡片', + 'No QR code found in that image': '在该图片中未找到二维码', + 'Could not read that image': '无法读取该图片', + 'Camera permission is needed to scan. Enable it in Settings.': '扫描需要相机权限。请在设置中开启。', + 'Scanning is not available on this device.': '此设备不支持扫描。', + 'Could not start the scanner': '无法启动扫描器', } diff --git a/frontend/src/store/useStore.gymcards.test.jsx b/frontend/src/store/useStore.gymcards.test.jsx new file mode 100644 index 0000000..8f0fe52 --- /dev/null +++ b/frontend/src/store/useStore.gymcards.test.jsx @@ -0,0 +1,69 @@ +// @vitest-environment happy-dom + +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' + +vi.mock('../lib/api.js', () => ({ api: vi.fn(), setRemoteAuth: vi.fn() })) + +import { DEF, useStore } from './useStore.js' + +const clone = value => JSON.parse(JSON.stringify(value)) + +beforeEach(() => { + localStorage.clear() + useStore.setState({ S: clone(DEF), user: null, ready: false }) +}) + +afterEach(() => { + localStorage.clear() + useStore.setState({ S: clone(DEF), user: null, ready: false }) +}) + +// gymCards is plain profile data — it rides the same update()/persist() path as everything else, +// with no backend or schema change. These pin the contract the check-in view relies on: a fresh +// profile starts empty, and adding/removing a card mutates and persists like any other field. + +describe('gymCards state', () => { + it('defaults to an empty array on a fresh profile', () => { + expect(useStore.getState().S.gymCards).toEqual([]) + }) + + it('adds a card via update and persists it to localStorage', () => { + useStore.getState().update(s => { + s.gymCards.push({ id: 'c1', label: 'FitZone', value: 'ABC123', fmt: 'qrcode' }) + }, false) + + const cards = useStore.getState().S.gymCards + expect(cards).toHaveLength(1) + expect(cards[0]).toMatchObject({ id: 'c1', label: 'FitZone', value: 'ABC123', fmt: 'qrcode' }) + + // persist() writes the whole state under the app's storage key — the card must be in it. + const saved = JSON.parse(localStorage.getItem('gym_state_v1')) + expect(saved.gymCards).toHaveLength(1) + expect(saved.gymCards[0].value).toBe('ABC123') + }) + + it('removes a card by id, leaving the others', () => { + useStore.getState().update(s => { + s.gymCards.push({ id: 'a', label: 'A', value: '1', fmt: 'qrcode' }) + s.gymCards.push({ id: 'b', label: 'B', value: '2', fmt: 'qrcode' }) + }, false) + + useStore.getState().update(s => { + s.gymCards = s.gymCards.filter(c => c.id !== 'a') + }, false) + + const cards = useStore.getState().S.gymCards + expect(cards).toHaveLength(1) + expect(cards[0].id).toBe('b') + }) + + it('keeps multiple cards in insertion order', () => { + useStore.getState().update(s => { + s.gymCards.push({ id: '1', label: 'One', value: 'x', fmt: 'qrcode' }) + s.gymCards.push({ id: '2', label: 'Two', value: 'y', fmt: 'qrcode' }) + s.gymCards.push({ id: '3', label: 'Three', value: 'z', fmt: 'qrcode' }) + }, false) + + expect(useStore.getState().S.gymCards.map(c => c.id)).toEqual(['1', '2', '3']) + }) +})