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

export const SalesOrdersActions = createActionGroup({
  source: 'Sales Orders',
  events: {
    'Load Orders': props<{ page?: number; perPage?: number; force?: boolean }>(),
    'Load Orders Success': props<{ orders: SalesOrder[]; meta: PaginationMeta }>(),
    'Load Orders Failure': props<{ error: string }>(),
    'Create Order': props<{ data: any }>(),
    'Create Order Success': props<{ order: SalesOrder }>(),
    'Create Order Failure': props<{ error: string }>(),
    'Update Order': props<{ id: number; data: any }>(),
    'Update Order Success': props<{ order: SalesOrder }>(),
    'Update Order Failure': props<{ error: string }>(),
    'Delete Order': props<{ id: number }>(),
    'Delete Order Success': props<{ id: number }>(),
    'Delete Order Failure': props<{ error: string }>(),
    'Submit Order Approval': props<{ id: number }>(),
    'Submit Order Approval Success': props<{ order: SalesOrder }>(),
    'Submit Order Approval Failure': props<{ error: string }>(),
    'Approve Order': props<{ id: number }>(),
    'Approve Order Success': props<{ order: SalesOrder }>(),
    'Approve Order Failure': props<{ error: string }>(),
    'Reject Order': props<{ id: number }>(),
    'Reject Order Success': props<{ order: SalesOrder }>(),
    'Reject Order Failure': props<{ error: string }>(),
    'Confirm Order': props<{ id: number }>(),
    'Confirm Order Success': props<{ order: SalesOrder }>(),
    'Confirm Order Failure': props<{ error: string }>(),
    'Create Order Delivery': props<{ id: number; data?: any }>(),
    'Create Order Delivery Success': props<{ order: SalesOrder }>(),
    'Create Order Delivery Failure': props<{ error: string }>(),
    'Create Order Invoice': props<{ id: number; data?: any }>(),
    'Create Order Invoice Success': props<{ order: SalesOrder }>(),
    'Create Order Invoice Failure': props<{ error: string }>(),
    'Cancel Order': props<{ id: number }>(),
    'Cancel Order Success': props<{ order: SalesOrder }>(),
    'Cancel Order Failure': props<{ error: string }>(),
    'Close Order': props<{ id: number }>(),
    'Close Order Success': props<{ order: SalesOrder }>(),
    'Close Order Failure': props<{ error: string }>(),
    'Duplicate Order': props<{ id: number }>(),
    'Duplicate Order Success': props<{ order: SalesOrder }>(),
    'Duplicate Order Failure': props<{ error: string }>(),
    'Clear Orders Error': emptyProps(),
  },
});
