All files / src/app/core/store/customer/user user.actions.ts

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

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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168415x                 415x   415x   415x   415x   415x   415x   415x   415x   415x     415x   415x   415x   415x   415x   415x         415x         415x         415x   415x         415x         415x         415x   415x         415x         415x   415x   415x   415x   415x   415x   415x         415x   415x   415x         415x         415x         415x   415x         415x   415x         415x   415x         415x       415x         415x   415x               415x                  
import { createAction, createActionGroup, emptyProps } from '@ngrx/store';
 
import { Credentials } from 'ish-core/models/credentials/credentials.model';
import { Customer, CustomerLoginType, CustomerRegistrationType } from 'ish-core/models/customer/customer.model';
import { PasswordReminder } from 'ish-core/models/password-reminder/password-reminder.model';
import { PaymentMethod } from 'ish-core/models/payment-method/payment-method.model';
import { UserCostCenter } from 'ish-core/models/user-cost-center/user-cost-center.model';
import { User } from 'ish-core/models/user/user.model';
import { MessagesPayloadType } from 'ish-core/store/core/messages';
import { httpError, payload } from 'ish-core/utils/ngrx-creators';
 
export const loginUser = createAction('[User] Login User', payload<{ credentials: Credentials }>());
 
export const loginUserWithToken = createAction('[User] Login User With Token', payload<{ token: string }>());
 
export const loginUserFail = createAction('[User API] Login User Failed', httpError());
 
export const loginUserSuccess = createAction('[User API] Login User Success', payload<CustomerLoginType>());
 
export const loadCompanyUser = createAction('[User Internal] Load Company User');
 
export const loadCompanyUserFail = createAction('[User API] Load Company User Fail', httpError());
 
export const loadCompanyUserSuccess = createAction('[User API] Load Company User Success', payload<{ user: User }>());
 
export const logoutUser = createAction('[User] Logout User');
 
// TODO: this should be an API action
export const logoutUserSuccess = createAction('[User] Logout User Success');
 
export const logoutUserFail = createAction('[User API] Logout User Failed', httpError());
 
export const createUser = createAction('[User] Create User', payload<CustomerRegistrationType>());
 
export const createUserSuccess = createAction('[User API] Create User Success', payload<{ email: string }>());
 
export const createUserFail = createAction('[User API] Create User Failed', httpError());
 
export const createUserApprovalRequired = createAction(
  '[User Internal] Create User Approval Required',
  payload<{ email: string }>()
);
 
export const updateUser = createAction(
  '[User] Update User',
  payload<{ user: User; credentials?: Credentials; successMessage?: MessagesPayloadType }>()
);
 
export const updateUserSuccess = createAction(
  '[User API] Update User Succeeded',
  payload<{ user: User; successMessage?: MessagesPayloadType }>()
);
 
export const updateUserFail = createAction('[User API] Update User Failed', httpError());
 
export const updateUserPreferredPayment = createAction(
  '[User] Update User Preferred Payment',
  payload<{ user: User; paymentMethodId: string; successMessage?: MessagesPayloadType }>()
);
 
export const updateUserPassword = createAction(
  '[User] Update User Password',
  payload<{ password: string; currentPassword: string; successMessage?: MessagesPayloadType }>()
);
 
export const updateUserPasswordSuccess = createAction(
  '[User API] Update User Password Succeeded',
  payload<{ successMessage?: MessagesPayloadType }>()
);
 
export const updateUserPasswordFail = createAction('[User API] Update User Password Failed', httpError());
 
export const updateCustomer = createAction(
  '[User] Update Customer',
  payload<{ customer: Customer; successMessage?: MessagesPayloadType }>()
);
 
export const updateCustomerSuccess = createAction(
  '[User API] Update Customer Succeeded',
  payload<{ customer: Customer; successMessage?: MessagesPayloadType }>()
);
 
export const updateCustomerFail = createAction('[User API] Update Customer Failed', httpError());
 
export const userErrorReset = createAction('[User Internal] Reset User Error');
 
export const loadUserByAPIToken = createAction('[User] Load User by API Token');
 
export const personalizationStatusDetermined = createAction('[User Internal] Personalization Status Determined');
 
export const loadUserCostCenters = createAction('[User] Load User Cost Centers');
 
export const loadUserCostCentersFail = createAction('[User API] Load User Cost Centers Fail', httpError());
 
export const loadUserCostCentersSuccess = createAction(
  '[User API] Load User Cost Centers Success',
  payload<{ costCenters: UserCostCenter[] }>()
);
 
export const loadUserPaymentMethods = createAction('[User] Load User Payment Methods');
 
export const loadUserPaymentMethodsFail = createAction('[User API] Load User Payment Methods Fail', httpError());
 
export const loadUserPaymentMethodsSuccess = createAction(
  '[User API] Load User Payment Methods Success',
  payload<{ paymentMethods: PaymentMethod[] }>()
);
 
export const deleteUserPaymentInstrument = createAction(
  '[User] Delete User Instrument Payment ',
  payload<{ id: string; successMessage?: MessagesPayloadType }>()
);
 
export const deleteUserPaymentInstrumentFail = createAction(
  '[User API] Delete User Payment Instrument Fail',
  httpError()
);
 
export const deleteUserPaymentInstrumentSuccess = createAction('[User API] Delete User Payment Instrument Success');
 
export const requestPasswordReminder = createAction(
  '[Password Reminder] Request Password Reminder',
  payload<{ data: PasswordReminder }>()
);
 
export const requestPasswordReminderSuccess = createAction('[Password Reminder API] Request Password Reminder Success');
 
export const requestPasswordReminderFail = createAction(
  '[Password Reminder API] Request Password Reminder Fail',
  httpError()
);
 
export const resetPasswordReminder = createAction('[Password Reminder] Reset Password Reminder Data');
 
export const updateUserPasswordByPasswordReminder = createAction(
  '[Password Reminder] Update User Password',
  payload<{ password: string; userID: string; secureCode: string }>()
);
 
export const updateUserPasswordByPasswordReminderSuccess = createAction(
  '[Password Reminder API] Update User Password Succeeded'
);
 
export const updateUserPasswordByPasswordReminderFail = createAction(
  '[Password Reminder API] Update User Password Failed',
  httpError()
);
 
export const fetchAnonymousUserToken = createAction('[Token API] Fetch Anonymous User Token');
 
export const userNewsletterActions = createActionGroup({
  source: 'User Newsletter',
  events: {
    'Load User Newsletter Subscription': emptyProps(),
    'Update User Newsletter Subscription': payload<{ subscriptionStatus: boolean; userEmail?: string }>(),
  },
});
 
export const userNewsletterApiActions = createActionGroup({
  source: 'User Newsletter API',
  events: {
    'Load User Newsletter Subscription Success': payload<{ subscribed: boolean }>(),
    'Load User Newsletter Subscription Fail': httpError<{}>(),
    'Update User Newsletter Subscription Success': payload<{ subscriptionStatus: boolean }>(),
    'Update User Newsletter Subscription Fail': httpError<{}>(),
  },
});