diff --git a/apps/api/src/app.ts b/apps/api/src/app.ts index 3cedfee..5f29097 100644 --- a/apps/api/src/app.ts +++ b/apps/api/src/app.ts @@ -140,7 +140,8 @@ export async function buildApp({ config, db, realtime, fetchImpl, reporter: give await registerOrgRoutes(app, { db, sessions }); await registerEventRoutes(app, { db, sessions, sports, broadcaster }); await registerSportsRoutes(app, { db, sessions, sports }); - await registerPhotoRoutes(app, { db, sessions, storage, signer, broadcaster, archive }); + // Photos whose IPTC changes go again to where they went. + await registerPhotoRoutes(app, { db, sessions, storage, signer, broadcaster, archive, resend: (orgId, ids) => delivery.resendPhotos(orgId, ids) }); await registerArchiveRoutes(app, { db, sessions, archive, storageRoot: config.STORAGE_ROOT, minFreeBytes: config.ARCHIVE_MIN_FREE_GB * 1e9 }); await registerArchiveViewerRoutes(app, { db, secrets, signer, archive, tokens: new ViewerTokens(config.JWT_SECRET), fetchImpl }); await registerCompositionRoutes(app, { db, sessions, storage, storageRoot: config.STORAGE_ROOT }); diff --git a/apps/api/src/delivery/routes.ts b/apps/api/src/delivery/routes.ts index b166d7e..9368795 100644 --- a/apps/api/src/delivery/routes.ts +++ b/apps/api/src/delivery/routes.ts @@ -83,6 +83,8 @@ const UpdateTarget = TargetBase.partial().extend({ disabled: z.boolean().optiona const ListQuery = z.object({ targetId: z.uuid().optional(), eventId: z.uuid().optional(), + /** One photo's deliveries (the Info window shows where it went). */ + photoId: z.uuid().optional(), status: z.enum(["QUEUED", "RUNNING", "WAITING", "DONE", "FAILED"]).optional(), limit: z.coerce.number().int().min(1).max(500).default(200), }); @@ -286,10 +288,10 @@ export async function registerDeliveryRoutes( const { orgId } = OrgParams.parse(req.params); const q = ListQuery.parse(req.query); await requireMembership(db, req, orgId, "INGESTER"); - const where = { organizationId: orgId, ...compact({ targetId: q.targetId, eventId: q.eventId, status: q.status }) }; + const where = { organizationId: orgId, ...compact({ targetId: q.targetId, eventId: q.eventId, photoId: q.photoId, status: q.status }) }; const [items, counts] = await Promise.all([ db.deliveryItem.findMany({ where, orderBy: [{ createdAt: "desc" }, { sequence: "desc" }], take: q.limit }), - db.deliveryItem.groupBy({ by: ["status"], where: { organizationId: orgId, ...compact({ targetId: q.targetId, eventId: q.eventId }) }, _count: true }), + db.deliveryItem.groupBy({ by: ["status"], where: { organizationId: orgId, ...compact({ targetId: q.targetId, eventId: q.eventId, photoId: q.photoId }) }, _count: true }), ]); return { items: items.map(toItemSummary), diff --git a/apps/api/src/delivery/service.ts b/apps/api/src/delivery/service.ts index ad2a2f9..dcea70e 100644 --- a/apps/api/src/delivery/service.ts +++ b/apps/api/src/delivery/service.ts @@ -233,6 +233,28 @@ export class DeliveryService { return rows.length; } + /** + * These photos' IPTC changed (the Info window): every destination that already has them gets them again, with + * the same name, the new file replacing the old one. Not the untouched originals (they carry no metadata), nor + * items being taken back. Returns how many were queued. + */ + async resendPhotos(organizationId: string, photoIds: readonly string[]): Promise { + if (!photoIds.length) return 0; + const rows = await this.deps.db.$queryRaw<{ id: string }[]>` + UPDATE delivery_items di SET status = 'QUEUED', attempts = 0, next_attempt_at = now(), last_error = NULL, finished_at = NULL, + replaces_path = di.remote_path, updated_at = now() + FROM delivery_targets t + WHERE t.id = di.target_id AND di.organization_id = ${organizationId}::uuid AND di.photo_id = ANY(${[...photoIds]}::uuid[]) + AND di.status = 'DONE' AND di.retract = false AND t.disabled_at IS NULL AND NOT (t.originals AND t.untouched) + RETURNING di.id`; + for (const r of rows) { + const item = await this.deps.db.deliveryItem.findUnique({ where: { id: r.id } }); + if (item) this.deps.broadcaster.library(item.organizationId, { type: "delivery.updated", item: toItemSummary(item) }); + } + if (rows.length) this.deps.log.info({ count: rows.length }, "delivery: photos sent again after an IPTC change"); + return rows.length; + } + /** Atomically takes up to `limit` due items (safe with several workers). */ async claim(limit: number): Promise { // Every half minute: delivered photos edited again join the queue. diff --git a/apps/api/src/library/photos.ts b/apps/api/src/library/photos.ts index 9ce9703..768dbc1 100644 --- a/apps/api/src/library/photos.ts +++ b/apps/api/src/library/photos.ts @@ -38,6 +38,9 @@ const FileParams = z.object({ photoId: z.uuid(), variant: z.enum(["thumb", "prev const FileQuery = z.object({ exp: z.coerce.number().int(), sig: z.string().min(10).max(100) }); const CodeListBody = z.object({ content: z.string().max(500_000) }); +/** An object with its keys in order, so two IPTC sets compare by content. */ +const sorted = (o: Record) => Object.fromEntries(Object.entries(o).sort(([a], [b]) => a.localeCompare(b))); + export async function registerPhotoRoutes( app: FastifyInstance, deps: { @@ -48,6 +51,8 @@ export async function registerPhotoRoutes( broadcaster: Broadcaster; /** Archive photos: the original is read from the cloud it lives on. */ archive?: { openOriginal(photoId: string): Promise } | undefined; + /** Sends photos whose IPTC changed again to where they went (DeliveryService.resendPhotos). */ + resend?: ((organizationId: string, photoIds: string[]) => Promise) | undefined; }, ) { const { db, storage, signer, broadcaster } = deps; @@ -138,21 +143,28 @@ export async function registerPhotoRoutes( /** * Photo Mechanic's Info window: IPTC fields set on one or many photos, on top of their event's template. A field * set to null goes back to the template; fields not sent are left as they are. Variables and codes still apply. + * A photo already delivered whose fields changed goes again to every destination that has it (replacing it there). */ app.put("/v1/orgs/:orgId/photos/iptc", { preHandler: authenticate }, async (req) => { const { orgId } = OrgParams.parse(req.params); const body = IptcBatch.parse(req.body); await requireMembership(db, req, orgId, "INGESTER"); const photos = await db.photo.findMany({ where: { organizationId: orgId, id: { in: body.ids } }, select: { id: true, iptcOverrides: true } }); + const changed: string[] = []; for (const p of photos) { - const merged: Record = { ...IptcTemplate.partial().parse(p.iptcOverrides ?? {}) }; + const before = IptcTemplate.partial().parse(p.iptcOverrides ?? {}); + const merged: Record = { ...before }; for (const [k, v] of Object.entries(body.set)) { if (v === null) delete merged[k]; else merged[k] = v; } - await db.photo.update({ where: { id: p.id }, data: { iptcOverrides: IptcTemplate.partial().parse(merged) } }); + const after = IptcTemplate.partial().parse(merged); + if (JSON.stringify(sorted(before)) === JSON.stringify(sorted(after))) continue; + await db.photo.update({ where: { id: p.id }, data: { iptcOverrides: after } }); + changed.push(p.id); } - return { updated: photos.length }; + const resent = deps.resend && changed.length ? await deps.resend(orgId, changed) : 0; + return { updated: photos.length, changed: changed.length, resent }; }); /** diff --git a/apps/api/test/delivery.test.ts b/apps/api/test/delivery.test.ts index b77bde1..b5ecd85 100644 --- a/apps/api/test/delivery.test.ts +++ b/apps/api/test/delivery.test.ts @@ -421,6 +421,28 @@ describe("delivery", () => { expect(nc.files.size).toBe(1); }); + it("an IPTC change in the Info window sends the photo again where it went, replacing the old file", async () => { + const { orgId, token, target } = await setup(); + const id = await photo("info.jpg", "2026:09:23 21:10:00"); + await ctx.app.inject({ method: "POST", url: `/v1/orgs/${orgId}/deliveries`, headers: bearer(token), payload: { targetId: target.id, photoIds: [id] } }); + await drain(); + const [file] = [...nc.files.keys()]; + const read = async () => { + const out = path.join(dir, "info-check.jpg"); + await writeFile(out, nc.files.get(file!)!); + return (await exiftool.readRaw(out, { readArgs: ["-G1", "-a"] })) as Record; + }; + expect((await read())["IPTC:ObjectName"]).toBeUndefined(); + const put = (set: Record) => ctx.app.inject({ method: "PUT", url: `/v1/orgs/${orgId}/photos/iptc`, headers: bearer(token), payload: { ids: [id], set } }); + expect((await put({ title: "Miguel Silva (VSC)" })).json()).toEqual({ updated: 1, changed: 1, resent: 1 }); + await drain(); + // Same file, same name: replaced, not a second copy. + expect([...nc.files.keys()]).toEqual([file]); + expect((await read())["IPTC:ObjectName"]).toBe("Miguel Silva (VSC)"); + // Saving the same values again sends nothing. + expect((await put({ title: "Miguel Silva (VSC)" })).json()).toEqual({ updated: 1, changed: 0, resent: 0 }); + }); + it("ZeroZero: signs in, finds the event's game, and uploads with the photographer as author", async () => { const { orgId, token } = await setup(); const event = ( diff --git a/apps/api/test/library.test.ts b/apps/api/test/library.test.ts index 5446107..785863c 100644 --- a/apps/api/test/library.test.ts +++ b/apps/api/test/library.test.ts @@ -290,7 +290,7 @@ describe("library", () => { headers: bearer(admin), payload: { ids, patch: { flag: "PICK", rating: 4, players: ["Miguel Silva (VSC)"] } }, }); - expect(patch.json()).toEqual({ updated: 2 }); + expect(patch.json()).toEqual({ updated: 2, changed: 2, resent: 0 }); expect(broadcaster.sent[0]?.message).toEqual({ type: "photo.updated", ids, patch: { flag: "PICK", rating: 4, players: ["Miguel Silva (VSC)"] } }); const picks = await ctx.app.inject({ method: "GET", url: `/v1/orgs/${orgId}/photos?flag=PICK&minRating=4`, headers: bearer(admin) }); @@ -328,7 +328,7 @@ describe("library", () => { const a = (await service.ingestFile(await drop("foto.r1", "a.jpg", await jpeg({ color: "#111111" })))) as { photoId: string }; const b = (await service.ingestFile(await drop("foto.r1", "b.jpg", await jpeg({ color: "#222222" })))) as { photoId: string }; const put = await ctx.app.inject({ method: "PUT", url: `/v1/orgs/${orgId}/photos/iptc`, headers: bearer(admin), payload: { ids: [a.photoId, b.photoId], set: { caption: "Golo de {home}, em {city}", keywords: ["ANDEBOL", "GOLO"] } } }); - expect(put.json()).toEqual({ updated: 2 }); + expect(put.json()).toEqual({ updated: 2, changed: 2, resent: 0 }); const got = (await ctx.app.inject({ method: "GET", url: `/v1/photos/${b.photoId}/iptc`, headers: bearer(admin) })).json() as { values: Record; overrides: Record; template: Record }; expect(got.values).toMatchObject({ caption: "Golo de VSC, em Guimarães", keywords: ["ANDEBOL", "GOLO"], event: "VSC x AAAS" }); expect(got.overrides).toEqual({ caption: "Golo de {home}, em {city}", keywords: ["ANDEBOL", "GOLO"] }); diff --git a/apps/app/src/i18n.ts b/apps/app/src/i18n.ts index 62e447d..cdf5e8d 100644 --- a/apps/app/src/i18n.ts +++ b/apps/app/src/i18n.ts @@ -73,7 +73,7 @@ export const t = { setUpDelivery: "Configurar envio", noTargetsHelp: "Ainda não há destinos de envio (FTP da agência, pasta, etc.). Cria um em Entregar.", deliveryBadge: { QUEUED: "A enviar", DONE: "Enviada", FAILED: "Envio falhou" }, - shortcuts: "P escolher · X rejeitar · U limpar · 0–5 estrelas · 6–9 cor · I informação · E/Enter lupa · G/Esc grelha · D revelar", + shortcuts: "P escolher · X rejeitar · U limpar · 0–5 estrelas · 6–9 cor · I informação · E/Enter lupa · G/Esc grelha · D revelar · R recortar · W conta-gotas · Ctrl+Alt+2 revelar · Photo Mechanic: T marcar · Cmd+1–5 cor · Ctrl+1–5 estrelas (Windows: Ctrl cor, Alt estrelas)", selected: (n: number) => (n === 1 ? "1 selecionada" : `${n} selecionadas`), ofTotal: (n: number, total: number) => `${n} de ${total}`, players: "Jogadores", @@ -331,12 +331,37 @@ export const t = { info: { title: "Informação (IPTC)", count: (n: number) => (n === 1 ? "1 foto" : `${n} fotos`), - fields: { title: "Título", headline: "Título curto", caption: "Legenda", personsShown: "Pessoas", keywords: "Palavras-chave", event: "Evento", city: "Cidade", location: "Local" }, + fields: { + title: "Title/Object Name", + caption: "Description/Caption", + headline: "Headline", + event: "Event", + location: "Location", + city: "City", + copyright: "Copyright", + credit: "Credit", + source: "Source", + keywords: "Keywords", + supplementalCategories: "Supp Cat", + creator: "Creator/Photographer", + personsShown: "Persons shown", + }, mixed: "(vários — escreve para mudar em todas)", empty: "(vazio)", - help: "Vazio = o modelo do evento. Variáveis: {players} {home} {away} {city} {venue} {event} {photographer}; códigos como \\v7\\. Ctrl/Cmd+Enter guarda; com Shift guarda e envia.", + help: "Vazio = o modelo do evento (a cinzento, o que vai ser escrito). Variáveis: {players} {home} {away} {city} {venue} {event} {photographer}; códigos como \\v7\\. Ctrl/Cmd+Enter: guardar e →; com Shift: guardar, enviar e →.", now: "Legenda atual", saveAndSend: "Guardar e enviar", + saveNext: "Guardar e →", + saveSendNext: "Guardar, enviar e →", + previous: "Foto anterior", + next: "Foto seguinte", + copy: "Copiar", + paste: "Colar", + copied: "Campos copiados", + saved: "Guardado", + sentTo: "Já enviada para", + notSent: "Ainda não foi enviada.", + resendHelp: "Se o IPTC mudar ao guardar, volta a seguir para estes destinos e substitui o ficheiro que lá está.", }, deliverN: (n: number) => `Entregar ${n}`, noTargets: "Sem destinos configurados.", @@ -989,7 +1014,7 @@ export const t = { paste: "Colar ajustes", pasted: (n: number) => `Ajustes colados em ${n} ${n === 1 ? "foto" : "fotos"}`, noAccess: "Só podes revelar fotos que enviaste.", - shortcuts: "← → foto · P escolher · X rejeitar · U limpar · 0–5 estrelas · 6–9 cor · G grelha · I informação · Shift+A automático · \\ antes/depois · R recortar · W conta-gotas · Z 1:1 (arrastar move) · Ctrl+Z anular", + shortcuts: "← → foto · P escolher · X rejeitar · U limpar · 0–5 estrelas · 6–9 cor · G grelha · I informação · Shift+A automático · \\ antes/depois · R recortar · W conta-gotas · Z 1:1 (arrastar move) · E lupa · Ctrl+Alt+1 biblioteca · Ctrl+Z anular", groups: { wb: "Equilíbrio de brancos", tone: "Tom", presence: "Presença", profile: "Perfil" }, labels: { "profile.amount": "Intensidade", diff --git a/apps/app/src/library/IptcInfo.tsx b/apps/app/src/library/IptcInfo.tsx index a146da4..dfae78a 100644 --- a/apps/app/src/library/IptcInfo.tsx +++ b/apps/app/src/library/IptcInfo.tsx @@ -1,143 +1,282 @@ -import type { PhotoSummary } from "@photoreport/contracts"; +import type { DeliveryItemSummary, PhotoSummary } from "@photoreport/contracts"; import type { ApiClient, DeliveryTarget } from "@photoreport/sdk"; -import { useEffect, useRef, useState } from "react"; +import { useCallback, useEffect, useRef, useState } from "react"; import { t } from "../i18n.js"; import { deliver, setIptc } from "../offline/sync.js"; -/** The fields of Photo Mechanic's Info window, in its order. Lists are comma separated. */ -const FIELDS = [ +/** The fields of Photo Mechanic's Metadata Info window, in its order. Lists are comma separated. */ +export const FIELDS = [ { id: "title", list: false, long: false }, - { id: "headline", list: false, long: false }, { id: "caption", list: false, long: true }, - { id: "personsShown", list: true, long: false }, - { id: "keywords", list: true, long: false }, + { id: "headline", list: false, long: false }, { id: "event", list: false, long: false }, - { id: "city", list: false, long: false }, { id: "location", list: false, long: false }, + { id: "city", list: false, long: false }, + { id: "copyright", list: false, long: false }, + { id: "credit", list: false, long: false }, + { id: "source", list: false, long: false }, + { id: "keywords", list: true, long: false }, + { id: "supplementalCategories", list: true, long: false }, + { id: "creator", list: false, long: false }, + { id: "personsShown", list: true, long: false }, ] as const; type FieldId = (typeof FIELDS)[number]["id"]; +type Values = Partial>; const show = (v: string | string[] | undefined) => (Array.isArray(v) ? v.join(", ") : (v ?? "")); const MIXED = "\\u0000mixed"; +/** Copy / Paste between photos, like Photo Mechanic's (kept while the app is open). */ +let copied: Values | null = null; + +/** The fields to send for what was typed: an emptied field goes back to the template (null). */ +export function changesOf(values: Values, touched: ReadonlySet): Record { + const set: Record = {}; + for (const f of FIELDS) { + if (!touched.has(f.id)) continue; + const raw = values[f.id] ?? ""; + if (raw === MIXED) continue; + const v = raw.trim(); + set[f.id] = + v === "" + ? null + : f.list + ? v + .split(",") + .map((x) => x.trim()) + .filter(Boolean) + : v; + } + return set; +} /** - * Info (I): IPTC for the selected photos, on top of their event's template, with variables and codes, then - * optionally send them straight away (rendered with their edits) to a delivery target, like Photo Mechanic's - * Info window followed by Upload. + * Info (I), Photo Mechanic's Metadata Info: the IPTC of one photo at a time, walked with ← →, beside the photo, with + * Save, Save & →, Save, Upload & →, Copy and Paste; or of all the selected photos at once. Fields left empty show + * (in grey) what the event's template gives. A photo already delivered whose IPTC changes goes again to every + * destination that has it, replacing the file there. */ -export function IptcInfo(props: { api: ApiClient; orgId: string; photos: PhotoSummary[]; targets: DeliveryTarget[]; canDeliver: boolean; onClose: () => void }) { - const { api, photos } = props; - const [values, setValues] = useState>({} as Record); - const [template, setTemplate] = useState>({}); - const [preview, setPreview] = useState>({}); +export function IptcInfo(props: { + api: ApiClient; + orgId: string; + /** The selected photos. One: it is walked through `sequence`; several: edited together. */ + photos: PhotoSummary[]; + /** The photos ← → walk through when one is open (the grid's order); defaults to the selection. */ + sequence?: PhotoSummary[]; + targets: DeliveryTarget[]; + canDeliver: boolean; + onClose: () => void; +}) { + const { api, orgId } = props; + const walking = props.photos.length === 1; + const list = walking ? (props.sequence?.length ? props.sequence : props.photos) : props.photos; + const [index, setIndex] = useState(() => Math.max(0, list.findIndex((p) => p.id === props.photos[0]?.id))); + const current = walking ? list[index] : undefined; + const editing = walking && current ? [current] : props.photos; + + const [values, setValues] = useState({}); + const [resolved, setResolved] = useState>({}); const [touched, setTouched] = useState>(new Set()); + const [sent, setSent] = useState([]); const [targetId, setTargetId] = useState(props.targets[0]?.id ?? ""); const [state, setState] = useState<"loading" | "idle" | "saving" | "error">("loading"); const [note, setNote] = useState(null); const first = useRef(null); + const ids = editing.map((p) => p.id).join(","); + + const loadDeliveries = useCallback(async () => { + if (!walking || !current) return setSent([]); + const r = await api.listDeliveries(orgId, { photoId: current.id }).catch(() => ({ items: [] as DeliveryItemSummary[] })); + // The latest delivery to each destination. + const latest = new Map(); + for (const item of r.items) if (!latest.has(item.targetId)) latest.set(item.targetId, item); + setSent([...latest.values()]); + }, [api, orgId, walking, current]); useEffect(() => { let alive = true; + setState("loading"); + setTouched(new Set()); void (async () => { try { - const all = await Promise.all(photos.slice(0, 60).map((p) => api.photoIptc(p.id))); + const all = await Promise.all(editing.slice(0, 60).map((p) => api.photoIptc(p.id))); if (!alive) return; - // A field shows its value when every selected photo agrees, "(vários)" otherwise. - const common = {} as Record; + // A field shows its value when every photo agrees, "(vários)" otherwise. + const common: Values = {}; for (const f of FIELDS) { const vals = new Set(all.map((r) => show(r.overrides?.[f.id]))); common[f.id] = vals.size === 1 ? [...vals][0]! : MIXED; } setValues(common); - setTemplate(all[0]?.template ?? {}); - setPreview(all[0]?.values ?? {}); + setResolved(all.length === 1 ? (all[0]?.values ?? {}) : {}); setState("idle"); setTimeout(() => first.current?.focus(), 0); } catch { if (alive) setState("error"); } })(); + void loadDeliveries(); return () => { alive = false; }; - }, [api, photos]); + }, [api, ids]); // eslint-disable-line react-hooks/exhaustive-deps - const save = async (send: boolean) => { + /** Saves what was typed; `send`: also to the chosen destination; `then`: where to go next. */ + const save = async (opts: { send?: boolean; then?: "stay" | "next" | "close" }) => { setState("saving"); setNote(null); try { - const set: Record = {}; - for (const f of FIELDS) { - if (!touched.has(f.id)) continue; - const v = values[f.id].trim(); - set[f.id] = v === "" ? null : f.list ? v.split(",").map((x) => x.trim()).filter(Boolean) : v; + const set = changesOf(values, touched); + const photoIds = editing.map((p) => p.id); + const notes: string[] = []; + if (Object.keys(set).length) { + const r = await setIptc(api, orgId, photoIds, set); + notes.push(r === "queued" ? t.offline.queuedDelivery : t.info.saved); } - const ids = photos.map((p) => p.id); - if (Object.keys(set).length) await setIptc(api, props.orgId, ids, set); - if (send && targetId) { - const r = await deliver(api, props.orgId, targetId, ids); - setNote(r.waiting ? t.offline.queuedDelivery : t.delivered(r.queued.length, r.skipped.length)); - setState("idle"); - return; + if (opts.send && targetId) { + const r = await deliver(api, orgId, targetId, photoIds); + notes.push(r.waiting ? t.offline.queuedDelivery : t.delivered(r.queued.length, r.skipped.length)); } - props.onClose(); + setTouched(new Set()); + setNote(notes.join(" · ") || null); + setState("idle"); + if (opts.then === "close") return props.onClose(); + if (opts.then === "next" && walking && index < list.length - 1) setIndex(index + 1); + else void loadDeliveries(); } catch { setState("error"); } }; + const go = (delta: number) => { + const next = index + delta; + if (next < 0 || next >= list.length) return; + setNote(null); + setIndex(next); + }; + const copy = () => { + const out: Values = {}; + for (const f of FIELDS) { + const v = values[f.id]; + if (v && v !== MIXED) out[f.id] = v; + } + copied = out; + setNote(t.info.copied); + }; + const paste = () => { + if (!copied) return; + setValues({ ...values, ...copied }); + setTouched(new Set([...touched, ...(Object.keys(copied) as FieldId[])])); + }; const onKey = (e: React.KeyboardEvent) => { e.stopPropagation(); // typing here never culls or navigates if (e.key === "Escape") props.onClose(); if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) { e.preventDefault(); - void save(e.shiftKey); + // Ctrl/Cmd+Enter: Save & →; with Shift: Save, Upload & →. + void save({ send: e.shiftKey, then: walking ? "next" : "close" }); } }; + const busy = state !== "idle"; + const button = "h-8 border border-black bg-cell px-3 text-[12px] text-ink hover:bg-cell-on disabled:opacity-40"; const input = "w-full border border-black bg-[#161617] px-2 text-[13px] text-ink placeholder:text-faint focus:border-accent focus:outline-none"; + const name = (id: string) => props.targets.find((x) => x.id === id)?.name ?? "—"; return (
-
+
{t.info.title} - {t.info.count(photos.length)} + {walking && current ? `${current.name} · ${index + 1}/${list.length}` : t.info.count(props.photos.length)} +
+
+ {state === "loading" ? ( +

…

+ ) : ( +
+ {FIELDS.map((f, i) => { + const mixed = values[f.id] === MIXED; + const common = { + "aria-label": t.info.fields[f.id], + className: `${input} ${f.long ? "min-h-24 py-1.5" : "h-8"}`, + value: mixed ? "" : (values[f.id] ?? ""), + placeholder: mixed ? t.info.mixed : show(resolved[f.id]) || t.info.empty, + onChange: (e: React.ChangeEvent) => { + setValues({ ...values, [f.id]: e.target.value }); + setTouched(new Set(touched).add(f.id)); + }, + }; + return ( +