import {html, shadowView} from "@benev/slate" import stylesCss from "./styles.css.js" import {Passport} from "../../../../auth/passport.js" import {Situation} from "../../../logic/situation.js" import themeCss from "../../../../common/theme.css.js" import {Breakdown} from "../../common/breakdown/view.js" import {PassportsFile} from "../../../../auth/passports-file.js" export const IngressPage = shadowView(use => (situation: Situation.Ingress) => { use.styles([themeCss, stylesCss]) const passports = use.signal([]) const problems = use.signal([]) async function handleUpload(event: InputEvent) { const input = event.currentTarget as HTMLInputElement const files = Array.from(input.files ?? []) passports.value = [] problems.value = [] for (const file of files) { try { const text = await file.text() const passportsFile = PassportsFile.fromData(JSON.parse(text)) passports.value = [...passports.value, ...passportsFile.list()] } catch { problems.value = [...problems.value, `error with file "${file.name}"`] } } } function accept() { situation.onAddPassports(passports.value) situation.onBack() } return html`

Import passport files from your device

${problems.value.length > 0 ? html`
    ${problems.value.map(problem => html`
  1. ${problem}
  2. `)}
` : null} ${passports.value.length > 0 ? html` ${Breakdown([passports.value])} ` : null}
` })