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';
import { UserRequest, UserResponse } from '@ucap-webmessenger/protocol-info';
import { MessageUpdateResponse } from '@ucap-webmessenger/protocol-status';

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

export const webLoginSuccess = createAction(
  '[Account::Authentication] Web Login Success',
  props<{
    loginInfo: LoginInfo;
    rememberMe: boolean;
    autoLogin: 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 userPasswordSet = createAction(
  '[Account::Authentication] User Password Set',
  props<{ req: UserPasswordSetRequest }>()
);

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

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

export const updateLoginRes = createAction(
  '[Account::Authentication] Update LoginRes',
  props<{
    loginRes: LoginResponse;
  }>()
);

export const infoUser = createAction(
  '[Account::Authentication] Info User',
  props<{ req: UserRequest }>()
);

export const infoUserSuccess = createAction(
  '[Account::Authentication] Info User Success',
  props<{
    res: UserResponse;
  }>()
);

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

export const updateStatusMessageSuccess = createAction(
  '[Account::Authentication] Status message update Success',
  props<{
    res: MessageUpdateResponse;
  }>()
);
