pc setup: hero falls back to the case present on the chosen day; add-ons (tilt pivot) are not counted as extra units in a slot card
All checks were successful
Deploy production / deploy (push) Successful in 1m6s

This commit is contained in:
2026-10-25 16:35:30 +00:00
parent ec4d3fd79e
commit 5a87a079eb
3 changed files with 9 additions and 4 deletions

View File

@@ -10,6 +10,7 @@
slotIcon,
slotLabel,
thumb,
isAddOn,
units,
usageBadges,
type Part
@@ -34,7 +35,7 @@
} = $props();
const first = $derived(parts[0]);
const qty = $derived(parts.reduce((s, p) => s + units(p), 0));
const qty = $derived(parts.reduce((s, p) => s + (isAddOn(p) ? 0 : units(p)), 0));
const image = $derived(parts.flatMap((p) => p.imageUrls)[0] ?? null);
const names = $derived([...new Set(parts.map(displayName))]);
const spec = $derived(keySpec(first));

View File

@@ -201,6 +201,9 @@ export const presentAt = (
export type SlotCard = { key: string; slot: string; parts: Part[] };
/** Visible parts of one section on day `at`, one card per slot (several parts may share it). */
/** An add-on (e.g. a tilt pivot) extends another part in the same slot card; it is not counted as an extra unit. */
export const isAddOn = (p: { model: string }) => /\badd-on\b/i.test(p.model);
export function slotCards(parts: Part[], section: string, at: string): SlotCard[] {
const cards = new Map<string, SlotCard>();
for (const p of parts) {
@@ -216,8 +219,7 @@ export function slotCards(parts: Part[], section: string, at: string): SlotCard[
return i < 0 ? 999 : i;
};
// Add-ons (e.g. a monitor-arm tilt pivot) sit after the item they extend.
const addOn = (p: Part) => /\badd-on\b/i.test(p.model);
for (const c of cards.values()) c.parts.sort((a, b) => Number(addOn(a)) - Number(addOn(b)));
for (const c of cards.values()) c.parts.sort((a, b) => Number(isAddOn(a)) - Number(isAddOn(b)));
return [...cards.values()].sort((a, b) => rank(a.slot) - rank(b.slot));
}