import { createActionGroup, emptyProps, props } from '@ngrx/store';
import { OpeningBalance, CreateOpeningBalance, UpdateOpeningBalance } from '../../models/opening-balance.model';
import { PaginationMeta } from '../../models/api.model';

export const OpeningBalancesActions = createActionGroup({
  source: 'Opening Balances',
  events: {
    'Load Opening Balances': props<{ page?: number; perPage?: number; forceReload?: boolean }>(),
    'Load Opening Balances Success': props<{ openingBalances: OpeningBalance[]; meta: PaginationMeta }>(),
    'Load Opening Balances Failure': props<{ error: string }>(),
    'Create Opening Balance': props<{ openingBalance: CreateOpeningBalance }>(),
    'Create Opening Balance Success': props<{ openingBalance: OpeningBalance }>(),
    'Create Opening Balance Failure': props<{ error: string }>(),
    'Update Opening Balance': props<{ id: number; openingBalance: UpdateOpeningBalance }>(),
    'Update Opening Balance Success': props<{ openingBalance: OpeningBalance }>(),
    'Update Opening Balance Failure': props<{ error: string }>(),
    'Delete Opening Balance': props<{ id: number }>(),
    'Delete Opening Balance Success': props<{ id: number }>(),
    'Delete Opening Balance Failure': props<{ error: string }>(),
    'Confirm Opening Balance': props<{ id: number }>(),
    'Confirm Opening Balance Success': props<{ openingBalance: OpeningBalance }>(),
    'Confirm Opening Balance Failure': props<{ error: string }>(),
    'Clear Opening Balances Error': emptyProps(),
  },
});
