import { createAction, props } from '@ngrx/store';
import {
  StrictHttpResponse,
  ListResponseArgsOfCustomerInfoDTO,
  ResponseArgsOfCustomerDTO,
  ListResponseArgsOfShippingAddressDTO,
  ListResponseArgsOfAssignedPayerDTO,
} from '@swagger/crm';
import { Customer } from './defs';

const prefix = `[Customer] [Customers]`;

export const fetchCustomer = createAction(`${prefix} Fetch Customer`, props<{ id: number }>());

export const fetchCustomerDone = createAction(
  `${prefix} Fetch Customer Done`,
  props<{
    id: number;
    response: StrictHttpResponse<ResponseArgsOfCustomerDTO>;
  }>()
);

export const fetchCustomers = createAction(`${prefix} Fetch Customers`, props<{ query: any }>());

export const fetchCustomersDone = createAction(
  `${prefix} Fetch Customers Done`,
  props<{
    id: number;
    response: StrictHttpResponse<ListResponseArgsOfCustomerInfoDTO>;
  }>()
);

export const addCustomer = createAction(
  `${prefix} Add Customer`,
  props<{
    id: number;
    customer: Customer;
  }>()
);

export const addCustomers = createAction(
  `${prefix} Add Customers`,
  props<{
    ids: number[];
    customers: Customer[];
  }>()
);

export const updateCustomer = createAction(
  `${prefix} Add Customers`,
  props<{
    id: number;
    customers: Partial<Customer>;
  }>()
);

export const fetchPayerAddresses = createAction(
  `${prefix} Fetch Payer Address`,
  props<{
    id: number;
  }>()
);

export const fetchPayerAddressesDone = createAction(
  `${prefix} Fetch Payer Address Done`,
  props<{
    id: number;
    response: StrictHttpResponse<ListResponseArgsOfAssignedPayerDTO>;
  }>()
);

export const fetchShippingyAddresses = createAction(
  `${prefix} Fetch Shipping Address`,
  props<{
    id: number;
  }>()
);

export const fetchShippingAddressesDone = createAction(
  `${prefix} Fetch Shipping Address Done`,
  props<{
    id: number;
    response: StrictHttpResponse<ListResponseArgsOfShippingAddressDTO>;
  }>()
);
