private store = inject(Store);
form: FormGroup;
- error: string|null = null;
+ error: string|undefined = undefined;
isLoading : boolean = false;
constructor(private fb: FormBuilder) {
export const login = createAction(
'[Login] User Login',
- props<{ username: string|null, password: string|null }>()
+ props<{ username: string|undefined, password: string|undefined }>()
);
export const loginSuccess = createAction(
import { login, loginFailure, loginSuccess } from './login.actions';
export interface State {
- token: string|null;
- error: string|null;
+ token: string|undefined;
+ error: string|undefined;
isLoading: boolean;
}
const initialState: State = {
- token: null,
- error: null,
+ token: undefined,
+ error: undefined,
isLoading: false
};
export const loginReducers = createReducer(initialState,
on(login, state => ({ ...state, isLoading: true })),
- on(loginSuccess, (state, { token }) => ({ ...state, token, error: null, isLoading: false })),
- on(loginFailure, (state, { error }) => ({ ...state, token: null, error, isLoading: false }))
+ on(loginSuccess, (state, { token }) => ({ ...state, token, error: undefined, isLoading: false })),
+ on(loginFailure, (state, { error }) => ({ ...state, token: undefined, error, isLoading: false }))
);