import React, { useState } from 'react'; import { Field, TextInput } from './controls'; /** * Temporary front-end lock until the backend has real auth. The password ships * in the bundle, so this only keeps casual visitors out — it protects nothing. */ const PASSWORD = process.env.REACT_APP_ACCESS_PASSWORD || 'Taric-Kiwi-7428'; const STORAGE_KEY = 'cargoflow.unlocked'; function readUnlocked(): boolean { try { return localStorage.getItem(STORAGE_KEY) === PASSWORD; } catch { return false; } } export function PasswordGate({ children }: { children: React.ReactNode }) { const [unlocked, setUnlocked] = useState(readUnlocked); const [value, setValue] = useState(''); const [wrong, setWrong] = useState(false); if (unlocked) return <>{children}; const onSubmit = (event: React.FormEvent) => { event.preventDefault(); if (value !== PASSWORD) { setWrong(true); return; } try { localStorage.setItem(STORAGE_KEY, PASSWORD); } catch { // Private mode: stay unlocked for this tab only. } setUnlocked(true); }; return (
CargoFlow
{ setValue(event.target.value); setWrong(false); }} /> {wrong ?

Wrong password.

: null}
); }