| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| import { fmt } from "../ui"; |
| import type { DecompDescriptor, DrillDescriptor, EntityDescriptor } from "../ui/types"; |
|
|
| const ENTITY_WORD: Record<string, string> = { |
| customer: "Customer", |
| sku: "Product", |
| rep: "Salesperson", |
| bu: "Business Unit", |
| }; |
|
|
| function Row({ label, value }: { label: string; value: string }) { |
| return ( |
| <div className="pg-drill-row"> |
| <span className="pg-drill-key">{label}</span> |
| <span className="pg-drill-val">{value}</span> |
| </div> |
| ); |
| } |
|
|
| export function DrillPanel({ |
| drill, |
| onClose, |
| }: { |
| drill: DrillDescriptor; |
| onClose: () => void; |
| }) { |
| const isDecomp = drill.kind === "decomp"; |
| const d = drill as DecompDescriptor; |
| const e = drill as EntityDescriptor; |
| return ( |
| <aside className="pg-drill" role="dialog" aria-label={drill.label}> |
| <header className="pg-drill-head"> |
| <div> |
| <span className="pg-drill-kind"> |
| {isDecomp ? "Period" : (ENTITY_WORD[drill.kind] ?? drill.kind)} |
| </span> |
| <h2 className="pg-drill-title">{drill.label}</h2> |
| </div> |
| <button type="button" className="pg-drill-close" onClick={onClose} aria-label="Close"> |
| Γ |
| </button> |
| </header> |
| |
| <div className="pg-drill-body"> |
| {isDecomp ? ( |
| <> |
| <Row label="Window" value={`${fmt.date(d.date_from)} β ${fmt.date(d.date_to)}`} /> |
| {d.cmp_from && d.cmp_to ? ( |
| <Row label="Compared with" value={`${fmt.date(d.cmp_from)} β ${fmt.date(d.cmp_to)}`} /> |
| ) : null} |
| <Row label="Scope" value={d.scope_value == null ? d.scope_type : `${d.scope_type} Β· ${d.scope_value}`} /> |
| </> |
| ) : ( |
| <> |
| <Row label={ENTITY_WORD[drill.kind] ?? "Record"} value={e.label} /> |
| <Row label="Identifier" value={String(e.id)} /> |
| </> |
| )} |
|
|
| { |
| } |
| <p className="pg-drill-note"> |
| This wave ships the drill as a complete <em>declaration</em>: the exact |
| scope above is what the number was computed over, and you can check it. |
| The row-level breakdown behind it opens in the next release β until |
| then, use the same view in the current application. |
| </p> |
| </div> |
| </aside> |
| ); |
| } |
|
|