Skip to content

Commit

Permalink
fix: apply code rabbit suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
adkif committed Oct 11, 2024
1 parent f0eb44a commit 2fc8b6a
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ <h2 id="title" class="title">{{ 'LOGIN_PAGE.TITLE' | translate }}</h2>
nbInput
fullWidth
formControlName="email"
noSpaceEdges
[placeholder]="'LOGIN_PAGE.PLACEHOLDERS.EMAIL' | translate"
[status]="email.dirty ? (email.invalid ? 'danger' : 'success') : 'basic'"
[attr.aria-invalid]="email.invalid && email.touched ? true : null"
Expand Down Expand Up @@ -83,7 +82,7 @@ <h2 id="title" class="title">{{ 'LOGIN_PAGE.TITLE' | translate }}</h2>
[attr.aria-invalid]="code.invalid && code.touched ? true : null"
maxlength="6"
autofocus
autocomplete-off
autocomplete="off"
/>
<ng-container *ngIf="code.invalid && code.touched">
<p class="caption status-danger" *ngIf="code.errors?.required">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ $button-color: #fa754e;
}

& .custom-btn {
-webkit-box-shadow: 3px 11px 30px -17px #3366ff;
box-shadow: 3px 11px 30px -17px #3366ff;
-webkit-box-shadow: 3px 11px 30px -17px nb-theme(color-primary-500);
box-shadow: 3px 11px 30px -17px nb-theme(color-primary-500);
width: auto;
padding: 13px 28px;
display: inline-flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeDetectorRef, Component, Inject, OnInit } from '@angular/core';
import { AbstractControl, FormBuilder, FormGroup, UntypedFormBuilder, Validators } from '@angular/forms';
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { NB_AUTH_OPTIONS, NbAuthService, NbLoginComponent } from '@nebular/auth';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
Expand Down Expand Up @@ -59,7 +59,7 @@ export class NgxLoginMagicComponent extends NbLoginComponent implements OnInit {
}

constructor(
private readonly _fb: UntypedFormBuilder,
private readonly _fb: FormBuilder,
private readonly _activatedRoute: ActivatedRoute,
public readonly nbAuthService: NbAuthService,
public readonly cdr: ChangeDetectorRef,
Expand Down Expand Up @@ -179,14 +179,12 @@ export class NgxLoginMagicComponent extends NbLoginComponent implements OnInit {
* Confirms the sign-in code.
*/
async confirmSignInCode(): Promise<void> {
this.isLoading = true;
// Check if the form is invalid
if (this.form.invalid) {
this.isLoading = false;
return;
}

this.isLoading = true;

// Get the email and code values from the form
const { email, code } = this.form.getRawValue();

Expand All @@ -211,6 +209,8 @@ export class NgxLoginMagicComponent extends NbLoginComponent implements OnInit {
* Starts a timer for a countdown.
*/
startTimer() {
this.stopTimer();

this.isCodeResent = true;
this.countdown = 30;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ <h1 class="title">{{ 'WORKSPACES.SIGN_IN_TITLE' | translate }}</h1>

<ng-template #signInForm>
<form [formGroup]="form" class="form" (ngSubmit)="onSubmit()" autocomplete="off">
<div style="height: 0; overflow: hidden">
<input style="opacity: 0" type="email" value="" class="" />
<input style="opacity: 0" type="password" value="" class="d-" />
</div>
<div class="row">
<div class="col">
<div class="form-group">
Expand Down Expand Up @@ -71,7 +67,7 @@ <h1 class="title">{{ 'WORKSPACES.SIGN_IN_TITLE' | translate }}</h1>
fieldSize="large"
[status]="password.dirty ? (password.invalid ? 'danger' : 'success') : 'basic'"
[attr.aria-invalid]="password.invalid && password.touched ? true : null"
autocomplete="off"
autocomplete="current-password"
/>
<a
nbSuffix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
background: nb-theme(gauzy-card-2);
border-radius: nb-theme(border-radius);
padding: 1rem 0;
width: 100%;

&>* {
padding-left: 15px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, UntypedFormBuilder, Validators } from '@angular/forms';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { HttpStatus, IAuthResponse, IUser, IUserSigninWorkspaceResponse, IWorkspaceResponse } from '@gauzy/contracts';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { asyncScheduler, catchError, EMPTY, filter, tap } from 'rxjs';
Expand Down Expand Up @@ -38,7 +38,7 @@ export class NgxLoginWorkspaceComponent {

constructor(
private readonly _store: Store,
private readonly _fb: UntypedFormBuilder,
private readonly _fb: FormBuilder,
private readonly _authService: AuthService,
private readonly _errorHandlingService: ErrorHandlerService
) {}
Expand All @@ -55,7 +55,7 @@ export class NgxLoginWorkspaceComponent {
this.loading = true;

// Get the values of email and password from the form
const email = this.form.get('email').value;
const email = this.email.value;
const password = this.password.value;

// Send a request to sign in to workspaces using the authentication service
Expand Down Expand Up @@ -149,4 +149,8 @@ export class NgxLoginWorkspaceComponent {
public get password() {
return this.form.get('password');
}

public get email() {
return this.form.get('email');
}
}
2 changes: 1 addition & 1 deletion packages/desktop-ui-lib/src/lib/login/login.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ const shared = [
AvatarModule
],
declarations: [LogoComponent, SocialLinksComponent, WorkspaceSelectionComponent, ...shared],
exports: [shared]
exports: [...shared]
})
export class NgxLoginModule {}
Loading

0 comments on commit 2fc8b6a

Please sign in to comment.