export interface ScalePinnedTotalRowBase {
  id: string
  groupCode: string
  groupName: string
  majorCode: string
  majorName: string
  hasCost: boolean
  hasArea: boolean
  amount?: number | null
  landArea?: number | null
  benchmarkBudget: number | null
  benchmarkBudgetBasic: number | null
  benchmarkBudgetOptional: number | null
  benchmarkBudgetBasicChecked: boolean
  benchmarkBudgetOptionalChecked: boolean
  basicFormula: string | null
  optionalFormula: string | null
  consultCategoryFactor: number | null
  majorFactor: number | null
  workStageFactor: number | null
  workRatio: number | null
  budgetFee: number | null
  budgetFeeBasic: number | null
  budgetFeeOptional: number | null
  remark: string
  path: string[]
}

export const createScalePinnedTotalRow = <TRow extends ScalePinnedTotalRowBase>(
  overrides: Partial<TRow> & Pick<TRow, 'budgetFee' | 'budgetFeeBasic' | 'budgetFeeOptional'>
) => {
  const baseRow: ScalePinnedTotalRowBase = {
    id: 'pinned-total-row',
    groupCode: '',
    groupName: '',
    majorCode: '',
    majorName: '',
    hasCost: false,
    hasArea: false,
    amount: null,
    benchmarkBudget: null,
    benchmarkBudgetBasic: null,
    benchmarkBudgetOptional: null,
    benchmarkBudgetBasicChecked: true,
    benchmarkBudgetOptionalChecked: true,
    basicFormula: '',
    optionalFormula: '',
    consultCategoryFactor: null,
    majorFactor: null,
    workStageFactor: null,
    workRatio: null,
    budgetFee: null,
    budgetFeeBasic: null,
    budgetFeeOptional: null,
    remark: '',
    path: ['TOTAL']
  }
  return {
    ...baseRow,
    ...overrides
  } as TRow
}

export const createPinnedTopRowData = <TRow>(row: TRow): TRow[] => [row]
