import { createActionGroup, emptyProps, props } from '@ngrx/store';
import { SalesPayment } from '../../../models/sales-payment.model';
import { PaginationMeta } from '../../../models/api.model';

export const SalesPaymentsActions = createActionGroup({
  source: 'Sales Payments',
  events: {
    'Load Payments': props<{ page?: number; perPage?: number; force?: boolean }>(),
    'Load Payments Success': props<{ payments: SalesPayment[]; meta: PaginationMeta }>(),
    'Load Payments Failure': props<{ error: string }>(),
    'Create Payment': props<{ data: any }>(),
    'Create Payment Success': props<{ payment: SalesPayment }>(),
    'Create Payment Failure': props<{ error: string }>(),
    'Update Payment': props<{ id: number; data: any }>(),
    'Update Payment Success': props<{ payment: SalesPayment }>(),
    'Update Payment Failure': props<{ error: string }>(),
    'Delete Payment': props<{ id: number }>(),
    'Delete Payment Success': props<{ id: number }>(),
    'Delete Payment Failure': props<{ error: string }>(),
    'Post Payment': props<{ id: number }>(),
    'Post Payment Success': props<{ payment: SalesPayment }>(),
    'Post Payment Failure': props<{ error: string }>(),
    'Cancel Payment': props<{ id: number }>(),
    'Cancel Payment Success': props<{ payment: SalesPayment }>(),
    'Cancel Payment Failure': props<{ error: string }>(),
    'Clear Payments Error': emptyProps(),
  },
});
