All files / src/app/extensions/order-templates/store/order-template order-template.actions.ts

100% Statements 25/25
100% Branches 0/0
100% Functions 0/0
100% Lines 25/25

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 11212x     12x       12x   12x         12x   12x         12x         12x   12x         12x         12x   12x         12x         12x   12x         12x         12x         12x         12x         12x         12x         12x         12x         12x             12x              
import { createAction, createActionGroup } from '@ngrx/store';
 
import { LineItem } from 'ish-core/models/line-item/line-item.model';
import { httpError, payload } from 'ish-core/utils/ngrx-creators';
 
import { OrderTemplate, OrderTemplateHeader } from '../../models/order-template/order-template.model';
 
export const loadOrderTemplates = createAction('[Order Templates Internal] Load Order Templates');
 
export const loadOrderTemplatesSuccess = createAction(
  '[Order Templates API] Load Order Templates Success',
  payload<{ orderTemplates: OrderTemplate[] }>()
);
 
export const loadOrderTemplatesFail = createAction('[Order Templates API] Load Order Templates Fail', httpError());
 
export const createOrderTemplate = createAction(
  '[Order Templates] Create Order Template',
  payload<{ orderTemplate: OrderTemplateHeader }>()
);
 
export const createOrderTemplateSuccess = createAction(
  '[Order Templates API] Create Order Template Success',
  payload<{ orderTemplate: OrderTemplate }>()
);
 
export const createOrderTemplateFail = createAction('[Order Templates API] Create Order Template Fail', httpError());
 
export const updateOrderTemplate = createAction(
  '[Order Templates] Update Order Template',
  payload<{ orderTemplate: OrderTemplate }>()
);
 
export const updateOrderTemplateSuccess = createAction(
  '[Order Templates API] Update Order Template Success',
  payload<{ orderTemplate: OrderTemplate }>()
);
 
export const updateOrderTemplateFail = createAction('[Order Templates API] Update Order Template Fail', httpError());
 
export const deleteOrderTemplate = createAction(
  '[Order Templates] Delete Order Template',
  payload<{ orderTemplateId: string }>()
);
 
export const deleteOrderTemplateSuccess = createAction(
  '[Order Templates API] Delete Order Template Success',
  payload<{ orderTemplateId: string }>()
);
 
export const deleteOrderTemplateFail = createAction('[Order Templates API] Delete Order Template Fail', httpError());
 
export const addProductToOrderTemplate = createAction(
  '[Order Templates] Add Product to Order Template',
  payload<{ orderTemplateId: string; sku: string; quantity?: number }>()
);
 
export const addProductToOrderTemplateSuccess = createAction(
  '[Order Templates API] Add Item to Order Template Success',
  payload<{ orderTemplate: OrderTemplate }>()
);
 
export const addProductToOrderTemplateFail = createAction(
  '[Order Templates API] Add Item to Order Template Fail',
  httpError()
);
 
export const addProductToNewOrderTemplate = createAction(
  '[Order Templates] Add Product To New Order Template',
  payload<{ title: string; sku: string; quantity?: number }>()
);
 
export const moveItemToOrderTemplate = createAction(
  '[Order Templates] Move Item to another Order Template',
  payload<{ source: { id: string }; target: { id?: string; title?: string; sku: string; quantity: number } }>()
);
 
export const removeItemFromOrderTemplate = createAction(
  '[Order Templates] Remove Item from Order Template',
  payload<{ orderTemplateId: string; sku: string }>()
);
 
export const removeItemFromOrderTemplateSuccess = createAction(
  '[Order Templates API] Remove Item from Order Template Success',
  payload<{ orderTemplate: OrderTemplate }>()
);
 
export const removeItemFromOrderTemplateFail = createAction(
  '[Order Templates API] Remove Item from Order Template Fail',
  httpError()
);
 
export const selectOrderTemplate = createAction(
  '[Order Templates Internal] Select Order Template',
  payload<{ id: string }>()
);
 
export const orderTemplatesActions = createActionGroup({
  source: 'Order Templates',
  events: {
    'Create Order Template from Line Items': payload<{ orderTemplate: OrderTemplateHeader; lineItems: LineItem[] }>(),
  },
});
 
export const orderTemplatesApiActions = createActionGroup({
  source: 'Order Templates API',
  events: {
    'Create Order Template from Line Items Success': payload<{ orderTemplate: OrderTemplate }>(),
    'Create Order Template from Line Items Fail': httpError<{}>(),
  },
});