import { createActionGroup, emptyProps, props } from '@ngrx/store';
import { PaginationMeta } from '../../../models/api.model';
import { PurchaseGrn, CreatePurchaseGrn, UpdatePurchaseGrn } from '../../../models/purchase-grn.model';

export const PurchaseGrnsActions = createActionGroup({
  source: 'Purchase GRNs',
  events: {
    'Load Grns': props<{ page?: number; perPage?: number; force?: boolean }>(),
    'Load Grns Success': props<{ grns: PurchaseGrn[]; meta: PaginationMeta }>(),
    'Load Grns Failure': props<{ error: string }>(),

    'Load Grn': props<{ id: number }>(),
    'Load Grn Success': props<{ grn: PurchaseGrn }>(),
    'Load Grn Failure': props<{ error: string }>(),

    'Create Grn': props<{ data: CreatePurchaseGrn }>(),
    'Create Grn Success': props<{ grn: PurchaseGrn }>(),
    'Create Grn Failure': props<{ error: string }>(),

    'Update Grn': props<{ id: number; data: UpdatePurchaseGrn }>(),
    'Update Grn Success': props<{ grn: PurchaseGrn }>(),
    'Update Grn Failure': props<{ error: string }>(),

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

    'Approve Grn': props<{ id: number }>(),
    'Cancel Grn': props<{ id: number }>(),

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

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