import { createActionGroup, emptyProps, props } from '@ngrx/store';
import { PaginationMeta } from '../../../models/api.model';
import { SupplierPrice, CreateSupplierPrice, UpdateSupplierPrice } from '../../../models/supplier-price.model';

export const SupplierPricesActions = createActionGroup({
  source: 'Supplier Prices',
  events: {
    'Load Prices': props<{ page?: number; perPage?: number; force?: boolean }>(),
    'Load Prices Success': props<{ prices: SupplierPrice[]; meta: PaginationMeta }>(),
    'Load Prices Failure': props<{ error: string }>(),

    'Create Price': props<{ data: CreateSupplierPrice }>(),
    'Create Price Success': props<{ price: SupplierPrice }>(),
    'Create Price Failure': props<{ error: string }>(),

    'Update Price': props<{ id: number; data: UpdateSupplierPrice }>(),
    'Update Price Success': props<{ price: SupplierPrice }>(),
    'Update Price Failure': props<{ error: string }>(),

    'Delete Price': props<{ id: number }>(),
    'Delete Price Success': props<{ id: number }>(),
    'Delete Price Failure': props<{ error: string }>(),

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