import { createAction, props } from '@ngrx/store';

import { Login2Response } from '@ucap-webmessenger/pi';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';

import { LoginInfo } from '@app/types';
import {
  UserPasswordSetRequest,
  UserPasswordSetResponse
} from '@ucap-webmessenger/protocol-service';

export const webLogin = createAction(
  '[Account::Authentication] Web Login',
  props<{
    loginInfo: LoginInfo;
    rememberMe: boolean;
  }>()
);

export const webLoginSuccess = createAction(
  '[Account::Authentication] Web Login Success',
  props<{
    loginInfo: LoginInfo;
    rememberMe: boolean;
    login2Response: Login2Response;
  }>()
);

export const webLoginFailure = createAction(
  '[Account::Authentication] Web Login Failure',
  props<{ error: any }>()
);

export const loginSuccess = createAction(
  '[Account::Authentication] Login Success',
  props<{
    loginRes: LoginResponse;
  }>()
);

export const loginFailure = createAction(
  '[Account::Authentication] Login Failure',
  props<{ error: any }>()
);

export const increaseLoginFailCount = createAction(
  '[Account::Authentication] Increase Login Failure Count',
  props()
);
export const initialLoginFailCount = createAction(
  '[Account::Authentication] Initialize Login Failure Count',
  props()
);

export const loginRedirect = createAction(
  '[Account::Authentication] Login Redirect'
);

export const logout = createAction('[Account::Authentication] Logout');

export const logoutConfirmation = createAction(
  '[Account::Authentication] Logout Confirmation'
);

export const logoutConfirmationDismiss = createAction(
  '[Account::Authentication] Logout Confirmation Dismiss'
);

export const logoutInitialize = createAction(
  '[Account::Authentication] Logout Initialize'
);

export const postLogin = createAction(
  '[Account::Authentication] Post Login',
  props<{
    loginRes: LoginResponse;
  }>()
);

export const privacyAgree = createAction(
  '[Account::Authentication] Privacy Agree',
  props<{
    loginRes: LoginResponse;
  }>()
);

export const privacyAgreeSuccess = createAction(
  '[Account::Authentication] Privacy Agree Success'
);

export const privacyAgreeFailure = createAction(
  '[Account::Authentication] Privacy Agree Failure',
  props<{ error: any }>()
);

export const privacyDisagree = createAction(
  '[Account::Authentication] Privacy Disagree'
);

export const changePassword = createAction(
  '[Account::Authentication] Change Password',
  props<{ req: UserPasswordSetRequest }>()
);

export const changePasswordSuccess = createAction(
  '[Account::Authentication] Change Password Success',
  props<{
    res: UserPasswordSetResponse;
  }>()
);

export const changePasswordFailure = createAction(
  '[Account::Authentication] Change Password Failure',
  props<{ error: any }>()
);
