import React from 'react'; import numberPipe from 'app/shared/pipes/number.pipe'; import percentPipe from 'app/shared/pipes/percent.pipe'; import { TABLE_CELL } from 'app/shared/modules/tables/factories/tableCell/tableCell.constans'; import { AlertFlag } from 'app/shared/components/alertFlag/alertFlag'; import { TableCellEditContainer } from 'app/shared/containers/tableCells/tableCellEdit.container'; import { TableCellInfo } from 'app/shared/modules/tables/tableCells/tableCellInfo'; import { TableCellOperation } from 'app/shared/modules/tables/tableCells/tableCellOperation'; import { TableCellTotal } from 'app/shared/modules/tables/tableCells/tableCellTotal'; import { TableCellBold } from 'app/shared/modules/tables/tableCells/tableCellBold'; import { TableCellPerformance } from 'app/shared/modules/tables/tableCells/tablePerformanceCell'; const elementCaseTypes = [ TABLE_CELL.EDIT, TABLE_CELL.INFO, TABLE_CELL.OPERATION, TABLE_CELL.FLAG, TABLE_CELL.TOTAL, TABLE_CELL.BOLD, TABLE_CELL.BOLD, TABLE_CELL.BADGE, TABLE_CELL.BADGE_INDICATORS, TABLE_CELL.BADGE_INDICATORS_THIN, TABLE_CELL.BADGE_INDICATORS_BACKGROUND, TABLE_CELL.PERFORMANCE ] as const; const stringCaseTypes = [ TABLE_CELL.STRING, TABLE_CELL.NUMBER, TABLE_CELL.PERCENTAGE ] as const; interface ElementCase { type: typeof elementCaseTypes[number]; } interface StringCase { type: typeof stringCaseTypes[number]; } interface DefaultCase { type?: Exclude; value: T; } export class TableCellFactory { static build(data: T): React.ReactElement; static build(data: T): string; static build(data: DefaultCase): T; static build(data) { switch (data.type || data) { case TABLE_CELL.STRING: return data.value; case TABLE_CELL.NUMBER: return numberPipe.format(data.value); case TABLE_CELL.EDIT: return {}} paramId={data.value}/>; case TABLE_CELL.INFO: return ; case TABLE_CELL.OPERATION: return ; case TABLE_CELL.FLAG: return ; case TABLE_CELL.TOTAL: return ; case TABLE_CELL.BOLD: return ; case TABLE_CELL.PERCENTAGE: return percentPipe.format(data.value); case TABLE_CELL.BADGE: return
{data.value}
; case TABLE_CELL.BADGE_INDICATORS: return
{data.indicator} {data.value}
; case TABLE_CELL.BADGE_INDICATORS_THIN: return
{data.indicator} {data.value}
; case TABLE_CELL.BADGE_INDICATORS_BACKGROUND: return
{data.indicator} {data.value}
; case TABLE_CELL.PERFORMANCE: return ; default: return data.value; } } }