@ministryofjustice/hmpps-digital-prison-reporting-frontend
Version:
The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.
54 lines (53 loc) • 2.17 kB
TypeScript
import ReportQuery from '../../../types/ReportQuery';
import { SummaryTemplate } from '../../../types/Templates';
import { AsyncSummary } from '../../../types/UserReports';
import { components } from '../../../types/api';
import { SectionedData, SectionKey } from './types';
type OrderedRow = Record<string, string> & {
index: string;
};
type OrderedSummary = Omit<AsyncSummary, 'data'> & {
data: OrderedRow[];
};
export declare class SectionedDataHelper {
sections: Array<string>;
data: Array<Record<string, string>>;
fields: components['schemas']['FieldDefinition'][];
summariesData: OrderedSummary[];
sectionedDataArray: SectionedData[];
sectionedData: SectionedData;
reportQuery: ReportQuery;
createSectionKey(row: Record<string, string>): {
keyObj: SectionKey[];
key: string;
};
createSectionTitle(keyObj: SectionKey[], fields: components['schemas']['FieldDefinition'][] | components['schemas']['SummaryField'][]): string;
/**
* Groups the data into sections
*
* @return {*} {SectionedData}
* @memberof SectionedDataBuilder
*/
groupBySections(data: Array<Record<string, string>>, fields: components['schemas']['FieldDefinition'][] | components['schemas']['SummaryField'][], summary?: {
template: SummaryTemplate;
id: string;
}): void;
createSummarySections(): void;
mergeSections(): SectionedData;
getSortField(): string[];
getSortDirection(): 1 | -1;
private enforceSummaryRowOrder;
/**
* Sorts sections based on keyObj values using an optional nameOrder override.
* - nameOrder can be partial; unspecified names fall back to default order
* - Default order is derived from the first section's keyObj sequence
*/
sortSections(sectionedData: SectionedData): SectionedData;
withSections(sections: string[]): this;
withFields(fields: components['schemas']['FieldDefinition'][]): this;
withData(data: Array<Record<string, string>>): this;
withSummaries(summaryData: Array<AsyncSummary>): this;
withReportQuery(reportQuery: ReportQuery): this;
build(): SectionedData;
}
export {};