import { createActionGroup, emptyProps, props } from '@ngrx/store';
import { PaginationMeta } from '../../../models/api.model';
import { PurchasePayment, CreatePurchasePayment, UpdatePurchasePayment } from '../../../models/purchase-payment.model';

export const PurchasePaymentsActions = createActionGroup({
  source: 'Purchase Payments',
  events: {
    'Load Payments': props<{ page?: number; perPage?: number; force?: boolean }>(),
    'Load Payments Success': props<{ payments: PurchasePayment[]; meta: PaginationMeta }>(),
    'Load Payments Failure': props<{ error: string }>(),

    'Create Payment': props<{ data: CreatePurchasePayment }>(),
    'Create Payment Success': props<{ payment: PurchasePayment }>(),
    'Create Payment Failure': props<{ error: string }>(),

    'Update Payment': props<{ id: number; data: UpdatePurchasePayment }>(),
    'Update Payment Success': props<{ payment: PurchasePayment }>(),
    '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 }>(),
    'Cancel Payment': props<{ id: number }>(),

    'Status Change Success': props<{ payment: PurchasePayment }>(),
    'Status Change Failure': props<{ error: string }>(),

    'Clear Payments Error': emptyProps(),
  },
});
