agmission/Development/client/src/app/customers/actions/customer.actions.ts

86 lines
2.6 KiB
TypeScript

import { Action } from "@ngrx/store";
import { Customer } from "../models/customer.model";
export const FETCH = '[CUSTOMERS] Fetch customers';
export class Fetch implements Action {
type: typeof FETCH = FETCH;
constructor(readonly payload?: { filters?: string; useCache?: boolean }) {}
}
export const FETCH_SUCCESS = '[CUSTOMERS] Fetch customers success';
export class FetchSuccess implements Action {
type: typeof FETCH_SUCCESS = FETCH_SUCCESS;
constructor(readonly payload: Customer[]) { }
}
export const FETCH_FAILED = '[CUSTOMERS] Fetch customers failed';
export class FetchError implements Action {
type: typeof FETCH_FAILED = FETCH_FAILED;
}
export const CREATE = '[CUSTOMERS] Create a customer';
export class Create implements Action {
type: typeof CREATE = CREATE;
constructor(readonly payload: Customer) { }
}
export const CREATE_SUCCESS = '[CUSTOMERS] Create customer success';
export class CreateSuccess implements Action {
type: typeof CREATE_SUCCESS = CREATE_SUCCESS;
constructor(readonly payload: Customer) { }
}
export const CREATE_FAILED = '[CUSTOMERS] Create customer failed';
export class CreateFailed implements Action {
type: typeof CREATE_FAILED = CREATE_FAILED;
}
export const UPDATE = '[CUSTOMERS] Update customer';
export class Update implements Action {
type: typeof UPDATE = UPDATE;
constructor(readonly payload: Customer) { }
}
export const UPDATE_SUCCESS = '[CUSTOMERS] Update customer success';
export class UpdateSuccess implements Action {
type: typeof UPDATE_SUCCESS = UPDATE_SUCCESS;
constructor(readonly payload: Customer) { }
}
export const UPDATE_FAILED = '[CUSTOMERS] Update customer failed';
export class UpdateFailed implements Action {
type: typeof UPDATE_FAILED = UPDATE_FAILED;
}
export const DELETE = '[CUSTOMERS] Delete customer';
export class Delete implements Action {
type: typeof DELETE = DELETE;
constructor(readonly payload: Customer) { }
}
export const DELETE_SUCCESS = '[CUSTOMERS] Delete customer success';
export class DeleteSuccess implements Action {
type: typeof DELETE_SUCCESS = DELETE_SUCCESS;
constructor(readonly payload: Customer) { }
}
export const DELETE_FAILED = '[CUSTOMERS] Delete customer failed';
export class DeleteError implements Action {
type: typeof DELETE_FAILED = DELETE_FAILED;
}
export const SELECT = '[CUSTOMERS] Select customer';
export class Select implements Action {
type: typeof SELECT = SELECT;
constructor(readonly payload: Customer) { }
}
export type All =
| Fetch | FetchSuccess | FetchError
| Create | CreateSuccess | CreateFailed
| Update | UpdateSuccess | UpdateFailed
| Delete | DeleteSuccess | DeleteError
| Select