import { createActionGroup, emptyProps, props } from '@ngrx/store';
import { PaginationMeta } from '../../../models/api.model';
import { HrLoan, CreateHrLoan, UpdateHrLoan } from '../../../models/hr-loan.model';

export const HrLoansActions = createActionGroup({
  source: 'HR Loans',
  events: {
    'Load HR Loans': props<{
      page?: number;
      perPage?: number;
      forceReload?: boolean;
    }>(),
    'Load HR Loans Success': props<{ loans: HrLoan[]; meta: PaginationMeta }>(),
    'Load HR Loans Failure': props<{ error: string }>(),
    'Create HR Loan': props<{ loan: CreateHrLoan }>(),
    'Create HR Loan Success': props<{ loan: HrLoan }>(),
    'Create HR Loan Failure': props<{ error: string }>(),
    'Update HR Loan': props<{ id: number; loan: UpdateHrLoan }>(),
    'Update HR Loan Success': props<{ loan: HrLoan }>(),
    'Update HR Loan Failure': props<{ error: string }>(),
    'Delete HR Loan': props<{ id: number }>(),
    'Delete HR Loan Success': props<{ id: number }>(),
    'Delete HR Loan Failure': props<{ error: string }>(),
    'Approve HR Loan': props<{ id: number }>(),
    'Approve HR Loan Success': props<{ loan: HrLoan }>(),
    'Approve HR Loan Failure': props<{ error: string }>(),
    'Reject HR Loan': props<{ id: number; data?: any }>(),
    'Reject HR Loan Success': props<{ loan: HrLoan }>(),
    'Reject HR Loan Failure': props<{ error: string }>(),
    'Clear HR Loans Error': emptyProps(),
  },
});
