UNPKG

@ministryofjustice/hmpps-digital-prison-reporting-frontend

Version:

The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.

28 lines (21 loc) 837 B
import ReportDataStore from '../data/reportDataStore' import { UserReportData } from '../types/UserReports' import { ReportStoreConfig } from '../types/ReportStore' export default class ReportStoreService { reportStore: ReportDataStore constructor(private readonly reportDataStore: ReportDataStore) { this.reportStore = reportDataStore } async getState(userId: string) { return this.reportStore.getUserConfig(userId) } async saveState(userId: string, userConfig: ReportStoreConfig) { await this.reportStore.setUserConfig(userId, userConfig) } findIndexByExecutionId(id: string, array: UserReportData[]) { return array.findIndex((report) => report.executionId === id) } findIndexByTableId(id: string, array: UserReportData[]) { return array.findIndex((report) => report.tableId === id) } }