IbrahimNour 8 månader sedan
förälder
incheckning
f0df6a1277

+ 1 - 1
src/app/app-routing.module.ts

@@ -28,7 +28,7 @@ const routes: Routes = [
         path: 'modules',
         loadChildren: () =>
           import('./modules/modules.module').then((m) => m.ModulesModule),
-        canActivate: [AuthGuard],
+        // canActivate: [AuthGuard],
       },
     ],
   },

+ 1 - 1
src/app/authentication/auth-sign-in/auth-sign-in.component.html

@@ -5,7 +5,7 @@
       fxLayout="row"
       fxLayoutAlign="space-between center"
     >
-      <img src="assets/images/logo.svg" alt="" title="" />
+      <img src="assets/images/logo.svg" alt="" title="" [routerLink]="['/']" />
       <select
         (change)="onChangeLanguage($event)"
         [(ngModel)]="lang"

+ 3 - 1
src/app/authentication/auth-sign-in/change-password/change-password.component.html

@@ -46,5 +46,7 @@
     [control]="form.get('password')!"
   ></app-error-form>
 
-  <button type="submit">{{ "CONFIRM" | translate }}</button>
+  <button type="submit" [disabled]="loading" [class.spinner]="loading">
+    {{ "CONFIRM" | translate }}
+  </button>
 </form>

+ 13 - 2
src/app/authentication/auth-sign-in/change-password/change-password.component.ts

@@ -44,12 +44,23 @@ export class ChangePasswordComponent
 
   onSubmit(): void {
     if (super.submitValidity(this.form)) {
+      if (
+        this.form.get('password')?.value !==
+        this.form.get('confirm_password')?.value
+      ) {
+        this.toastr.warning('Password not equla confirm password !');
+        return;
+      }
+      this.loading = true;
       this.authSer
-        .ChnagePassword(this.form.value)
+        .ChnagePassword({
+          userId: sessionStorage.getItem('userId')!,
+          password: this.form.get('password')?.value,
+        })
         .pipe(takeUntil(this.destroy$))
         .subscribe((res) => {
-          console.log('res => ', res);
           this.toastr.success('Password Changes Successfully');
+          this.loading = false;
           this.router.navigate(['/']);
         });
     }

+ 1 - 1
src/app/authentication/auth-sign-in/forget-password/forget-password.component.ts

@@ -54,10 +54,10 @@ export class ForgetPasswordComponent
           (response) => {
             this.loading = false;
             this.toastr.success('Successfully !');
+            sessionStorage.setItem('userId', response.userId);
             this.router.navigate(['../verify'], { relativeTo: this.route });
           },
           (error) => {
-            console.log(error);
             this.loading = false;
           }
         );

+ 7 - 2
src/app/authentication/auth-sign-in/verify-otp/verify-otp.component.html

@@ -15,7 +15,12 @@
     <span>{{ "CLICK_TO_RESEND" | translate }}</span>
   </p>
 
-  <!-- <button type="submit" (click)="onSubmit()">
+  <button
+    type="submit"
+    (click)="onSubmit()"
+    [disabled]="loading"
+    [class.spinner]="loading"
+  >
     {{ "VERIFY" | translate }}
-  </button> -->
+  </button>
 </form>

+ 20 - 8
src/app/authentication/auth-sign-in/verify-otp/verify-otp.component.ts

@@ -6,6 +6,7 @@ import { ComponentBase } from '@core/base/common-base';
 import { AuthService } from '@core/services/authentication/auth.service';
 import { NgxOtpInputConfig } from 'ngx-otp-input';
 import { takeUntil } from 'rxjs';
+import { ToastrService } from 'ngx-toastr';
 
 @Component({
   selector: 'app-verify-otp',
@@ -26,7 +27,8 @@ export class VerifyOtpComponent
 
   constructor(
     private readonly router: Router,
-    private readonly authService: AuthService
+    private readonly authService: AuthService,
+    private readonly toastr: ToastrService
   ) {
     super();
   }
@@ -37,17 +39,27 @@ export class VerifyOtpComponent
 
   handleFillEvent(event: string): void {
     this.code = event;
-    this.onSubmit();
   }
 
   onSubmit(): void {
-    console.log(this.code);
+    if (this.code.length < 4) {
+      this.toastr.warning('Please Enter Your OTP !');
+      return;
+    }
+
+    this.loading = true;
     this.authService
-      .SendCode({ email: sessionStorage.getItem('email')!, code: this.code })
+      .SendCode({ userId: sessionStorage.getItem('userId')!, code: this.code })
       .pipe(takeUntil(this.destroy$))
-      .subscribe((res) => {
-        console.log(res);
-        this.router.navigate(['../change-password']);
-      });
+      .subscribe(
+        (res) => {
+          console.log(res);
+          this.router.navigate(['../change-password']);
+          this.loading = false;
+        },
+        (err) => {
+          this.loading = false;
+        }
+      );
   }
 }

+ 2 - 2
src/app/authentication/auth-sign-up/signup-business/signup-business.component.html

@@ -249,7 +249,7 @@
         </div>
       </div>
 
-      <p class="bold mt-3">Payment</p>
+      <!-- <p class="bold mt-3">Payment</p>
       <div class="payment">
         <app-warning
           [message]="'Mandatory to pay 500$ to complete your registration'"
@@ -257,7 +257,7 @@
         <button type="button" class="add-payment bold ptr">
           + Add new card
         </button>
-      </div>
+      </div> -->
     </form>
   </div>
 </section>

+ 66 - 3
src/app/authentication/auth-sign-up/signup-business/signup-business.component.ts

@@ -1,10 +1,73 @@
-import { Component } from '@angular/core';
+import { Component, OnInit } from '@angular/core';
+import { BaseForm } from '@core/base/base-form';
+import { ComponentBase } from '@core/base/common-base';
+import {
+  FormGroup,
+  UntypedFormControl,
+  UntypedFormGroup,
+  Validators,
+} from '@angular/forms';
 
 @Component({
   selector: 'app-signup-business',
   templateUrl: './signup-business.component.html',
-  styleUrls: ['./signup-business.component.scss']
+  styleUrls: ['./signup-business.component.scss'],
 })
-export class SignupBusinessComponent {
+export class SignupBusinessComponent
+  extends ComponentBase
+  implements OnInit, BaseForm
+{
+  form!: FormGroup;
 
+  constructor() {
+    super();
+  }
+  ngOnInit(): void {
+    this.initForm();
+  }
+
+  initForm(): void {
+    this.form = new UntypedFormGroup({
+      companyName: new UntypedFormControl(null, [Validators.required]),
+      crNumber: new UntypedFormControl(null, [Validators.required]),
+      taxNumber: new UntypedFormControl(null, [Validators.required]),
+      companyUser: new UntypedFormGroup({
+        firstName: new UntypedFormControl(null, [Validators.required]),
+        dateOfBirth: new UntypedFormControl(null, [Validators.required]),
+        idNumber: new UntypedFormControl(null, [Validators.required]),
+        lastName: new UntypedFormControl(null, [Validators.required]),
+        email: new UntypedFormControl(null, [
+          Validators.required,
+          Validators.email,
+        ]),
+        passportNumber: new UntypedFormControl(null, [Validators.required]),
+        favoriteName: new UntypedFormControl(null, [Validators.required]),
+        phoneNumber: new UntypedFormControl(null, [Validators.required]),
+        linkedInLink: new UntypedFormControl(null, [Validators.required]),
+        userType: new UntypedFormControl(3, [Validators.required]),
+        userName: new UntypedFormControl(null, [Validators.required]),
+        password: new UntypedFormControl(null, [Validators.required]),
+        qualificationId: new UntypedFormControl(null, [Validators.required]),
+        universityId: new UntypedFormControl(null, [Validators.required]),
+        jobTitleId: new UntypedFormControl(null, [Validators.required]),
+        industryId: new UntypedFormControl(null, [Validators.required]),
+        countryId: new UntypedFormControl(null, [Validators.required]),
+        taxNumber: new UntypedFormControl(null, [Validators.required]),
+        incomeTaxValue: new UntypedFormControl(null, [Validators.required]),
+        cvAttach: new UntypedFormControl(null, [Validators.required]),
+        passportAttach: new UntypedFormControl(null, [Validators.required]),
+        eduCertificateAttach: new UntypedFormControl(null, [
+          Validators.required,
+        ]),
+        experienceCertificateAttach: new UntypedFormControl(null, [
+          Validators.required,
+        ]),
+        profCertificateAttach: new UntypedFormControl(null, [
+          Validators.required,
+        ]),
+      }),
+    });
+  }
+
+  onSubmit(): void {}
 }

+ 3 - 1
src/app/authentication/auth-sign-up/signup-contractor/signup-contractor.component.html

@@ -572,7 +572,9 @@
             <span><a>the terms and conditions for use.</a></span>
           </span></mat-checkbox
         >
-        <button type="submit">Sign Up</button>
+        <button type="submit" [disabled]="loading" [class.spinner]="loading">
+          Sign Up
+        </button>
       </div>
     </form>
   </div>

+ 10 - 5
src/app/authentication/auth-sign-up/signup-contractor/signup-contractor.component.ts

@@ -171,10 +171,9 @@ export class SignupContractorComponent
   }
 
   onSubmit(): void {
-    this.router.navigate(['/auth']);
-
     const multiPartForm = new FormData();
     if (this.submitValidity(this.form)) {
+      this.loading = true;
       for (const key in { ...this.form.value }) {
         if (this.form.value.hasOwnProperty(key)) {
           if (this.form.get(key)?.value) {
@@ -186,9 +185,15 @@ export class SignupContractorComponent
       this.authService
         .addEmployee(multiPartForm)
         .pipe(takeUntil(this.destroy$))
-        .subscribe((res) => {
-          this.toastr.success('Registeration Successfully !');
-        });
+        .subscribe(
+          (res) => {
+            this.toastr.success('Registeration Successfully !');
+            this.loading = false;
+          },
+          (error) => {
+            this.loading = false;
+          }
+        );
     }
   }
 }

+ 3 - 1
src/app/authentication/auth-sign-up/signup-employee/signup-employee.component.html

@@ -572,7 +572,9 @@
             <span><a>the terms and conditions for use.</a></span>
           </span></mat-checkbox
         >
-        <button type="submit">Sign Up</button>
+        <button type="submit" [disabled]="loading" [class.spinner]="loading">
+          Sign Up
+        </button>
       </div>
     </form>
   </div>

+ 11 - 4
src/app/authentication/auth-sign-up/signup-employee/signup-employee.component.ts

@@ -174,6 +174,7 @@ export class SignupEmployeeComponent
   onSubmit(): void {
     const multiPartForm = new FormData();
     if (this.submitValidity(this.form)) {
+      this.loading = true;
       for (const key in { ...this.form.value }) {
         if (this.form.value.hasOwnProperty(key)) {
           if (this.form.get(key)?.value) {
@@ -185,10 +186,16 @@ export class SignupEmployeeComponent
       this.authService
         .addEmployee(multiPartForm)
         .pipe(takeUntil(this.destroy$))
-        .subscribe((res) => {
-          this.toastr.success('Registeration Successfully !');
-          this.router.navigate(['/auth']);
-        });
+        .subscribe(
+          (res) => {
+            this.toastr.success('Registeration Successfully !');
+            this.router.navigate(['/auth']);
+            this.loading = false;
+          },
+          (error) => {
+            this.loading = false;
+          }
+        );
     }
   }
 }

+ 7 - 3
src/app/core/models/authenticcation.model.ts

@@ -15,19 +15,23 @@ export interface FORGET_PASSWORD {
 }
 
 export interface FORGET_PASSWORD_RESPONSE {
-  email?: string;
+  userId: string;
+  token: string;
+  password: string;
+  email: string;
+  otp: string;
 }
 
 export interface OTP {
   code?: string;
-  email?: string;
+  userId?: string;
 }
 
 export interface OTP_RESPONSE {}
 
 export interface CHANGE_PASSWORD {
   password: string;
-  confirm_password: string;
+  userId: string;
 }
 
 export interface CHANGE_PASSWORD_RESPONSE {}

+ 9 - 4
src/app/core/services/authentication/auth.service.ts

@@ -36,17 +36,22 @@ export class AuthService {
     });
   }
 
-  ForgetPassword(params: FORGET_PASSWORD): Observable<boolean> {
-    return this.apiService.get<boolean>('Auth/forgetPasswordMail', params);
+  ForgetPassword(
+    params: FORGET_PASSWORD
+  ): Observable<FORGET_PASSWORD_RESPONSE> {
+    return this.apiService.get<FORGET_PASSWORD_RESPONSE>(
+      'Auth/forgetPasswordMail',
+      params
+    );
   }
 
   SendCode(data: OTP): Observable<OTP_RESPONSE> {
-    return this.apiService.post<OTP, OTP_RESPONSE>('', data);
+    return this.apiService.post<OTP, OTP_RESPONSE>('Auth/VerifyOTP', data);
   }
 
   ChnagePassword(data: CHANGE_PASSWORD): Observable<CHANGE_PASSWORD_RESPONSE> {
     return this.apiService.post<CHANGE_PASSWORD, CHANGE_PASSWORD_RESPONSE>(
-      '',
+      'Auth/forgetPassword',
       data
     );
   }