export interface ResultTextPropsBase { text: string } export interface ResultTextPropsFull extends ResultTextPropsBase { mappingId: number textId: number updated: Date } export interface ResultTextPropsLimited extends ResultTextPropsBase { mappingId?: null textId?: null updated?: null } export function reconstituteResultText(button: HTMLButtonElement, partial: Partial = {}): ResultTextProps { const text = button.innerText if (typeof partial.mappingId ?? button.dataset["mappingId"] === "undefined") { return {text} } else { return { text, mappingId: partial.mappingId ?? parseInt(button.dataset["mappingId"]!), textId: partial.textId ?? parseInt(button.dataset["textId"]!), updated: partial.updated ?? new Date(parseInt(button.dataset["updated"]!)) } } } export type ResultTextProps = ResultTextPropsFull|ResultTextPropsLimited export function ResultText({text, mappingId, textId, updated}: ResultTextProps) { return }