routing fixes
This commit is contained in:
parent
a490471e4f
commit
0ee9686fb1
2 changed files with 34 additions and 16 deletions
|
|
@ -33,16 +33,33 @@ function useOptions(path: string) {
|
|||
.then((r) => r.json())
|
||||
.then((j) => {
|
||||
if (!alive) return;
|
||||
|
||||
const raw = (j?.data ?? j) as any[];
|
||||
|
||||
const normalized: Opt[] = Array.isArray(raw)
|
||||
? raw
|
||||
.map((x) => ({
|
||||
id: String(x?.id ?? x?.value ?? x?.key ?? ""),
|
||||
// recognize common label fields + 'opacity'
|
||||
label: String(x?.label ?? x?.name ?? x?.title ?? x?.text ?? x?.opacity ?? ""),
|
||||
}))
|
||||
.map((x) => {
|
||||
const id = String(x?.id ?? x?.value ?? x?.key ?? "").trim();
|
||||
|
||||
// Accept common label fields + "opacity" (string field)
|
||||
let label =
|
||||
(x?.label ??
|
||||
x?.name ??
|
||||
x?.title ??
|
||||
x?.text ??
|
||||
x?.opacity) as string | undefined;
|
||||
|
||||
// Nice fallback for sources where you have make/model
|
||||
if (!label && (x?.make || x?.model)) {
|
||||
label = [x.make, x.model].filter(Boolean).join(" ");
|
||||
}
|
||||
|
||||
label = String(label ?? "").trim();
|
||||
return { id, label };
|
||||
})
|
||||
.filter((o) => o.id && o.label)
|
||||
: [];
|
||||
|
||||
setOpts(normalized);
|
||||
})
|
||||
.finally(() => alive && setLoading(false));
|
||||
|
|
@ -168,13 +185,12 @@ export default function SettingsSubmit({ initialTarget }: { initialTarget?: Targ
|
|||
};
|
||||
}, []);
|
||||
|
||||
// Prefer username; then display_name; then full name; then email.
|
||||
const meLabel =
|
||||
(me?.username && me.username.trim()) ||
|
||||
(me?.display_name && me.display_name.trim()) ||
|
||||
(me?.username?.trim()) ||
|
||||
(me?.email?.trim()) ||
|
||||
([me?.first_name, me?.last_name].filter(Boolean).join(" ").trim()) ||
|
||||
(me?.email && me.email.trim()) ||
|
||||
"";
|
||||
(me?.display_name?.trim()) ||
|
||||
(me?.id ? `User ${me.id.slice(0, 8)}…${me.id.slice(-4)}` : "Unknown user");
|
||||
|
||||
|
||||
// Options
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue