IbrahimNour месяцев назад: 8
Родитель
Сommit
c95f10bbf3

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

@@ -55,7 +55,9 @@
     }}</a>
   </p>
 
-  <button type="submit">{{ "SIGN_IN" | translate }}</button>
+  <button type="submit" [disabled]="loading" [class.spinner]="loading">
+    {{ "SIGN_IN" | translate }}
+  </button>
   <h5>
     {{ "DONT_HAVE_ACCOUNT" | translate }}
     <span [routerLink]="['/auth/signUp']">{{ "SIGN_UP" | translate }}</span>

+ 13 - 6
src/app/authentication/auth-sign-in/sign-in/sign-in.component.ts

@@ -49,15 +49,22 @@ export class SignInComponent extends ComponentBase implements BaseForm, OnInit {
 
   onSubmit(): void {
     if (super.submitValidity(this.form)) {
+      this.loading = true;
       this.authService
         .Login(this.form.value)
         .pipe(takeUntil(this.destroy$))
-        .subscribe((response) => {
-          localStorage.setItem('token', response.token!);
-          localStorage.setItem('id', response.id!);
-          this.store.dispatch(ADD_PROFILE({ user: response }));
-          this.router.navigate(['/modules']);
-        });
+        .subscribe(
+          (response) => {
+            localStorage.setItem('token', response.token!);
+            localStorage.setItem('id', response.id!);
+            this.store.dispatch(ADD_PROFILE({ user: response }));
+            this.router.navigate(['/modules']);
+            this.loading = false;
+          },
+          (err) => {
+            this.loading = false;
+          }
+        );
     }
   }
 }

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

@@ -105,10 +105,10 @@ export class SignupBusinessComponent
 
     const formData = {
       ...this.form.value,
-      CompanyUser: {
+      CompanyUser: JSON.stringify({
         ...this.form.get('companyUser')?.value,
         userAddress: this.form.get('userAddress')?.value,
-      },
+      }),
     };
 
     delete formData.userAddress;

+ 78 - 0
src/app/core/models/home.model.ts

@@ -0,0 +1,78 @@
+export interface MEETING {
+  id: number;
+  readOnly: boolean;
+  title: string;
+  description: string;
+  startDate: string;
+  endDate: string;
+  location: string;
+  meetingLink: string;
+  meetingUsers: MEETING_USER[];
+}
+
+export interface MEETING_USER {
+  id: number;
+  readOnly: boolean;
+  meetingId: number;
+  assignedUserId: string;
+  assignedUserName: string;
+}
+
+export interface USER_TASKS {
+  id: number;
+  readOnly: boolean;
+  assignedUserId: number;
+  assignedUserName: string;
+  title: string;
+  description: string;
+  dueDate: string;
+  priority: number;
+  projectId: number;
+  statusId: number;
+  taskAttachments: TASK_ATTACH[];
+  userTaskHistories: USER_TASK_HISTORY[];
+}
+
+export interface USER_TASK_HISTORY {
+  id: number;
+  readOnly: boolean;
+  assignedToUserId: number;
+  comment: string;
+  taskId: number;
+  currentStatusId: number;
+  isDeleted: boolean;
+}
+
+export interface TASK_ATTACH {
+  id: number;
+  readOnly: boolean;
+  attachmentTypeId: number;
+  taskId: number;
+  attachmentTypeName: string;
+  fileData: string;
+  fileName: string;
+  originalName: string;
+}
+export interface TEAM {
+  id: number;
+  readOnly: boolean;
+  nameAr: string;
+  nameEn: string;
+  teamUsers: TEAM_USER[];
+}
+
+export interface TEAM_USER {
+  id: number;
+  readOnly: boolean;
+  teamId: number;
+  isAdmin: boolean;
+  assignedUserId: string;
+  assignedUserName: string;
+}
+
+export interface PROJECT {
+  id: number;
+  readOnly: boolean;
+  nameAr: string;
+  nameEn: string;
+}

+ 4 - 0
src/app/core/models/response.model.ts

@@ -0,0 +1,4 @@
+export interface RESPONSE<T> {
+  result: T;
+  total: number;
+}

+ 28 - 0
src/app/core/services/home.service.ts

@@ -0,0 +1,28 @@
+import { Injectable } from '@angular/core';
+import { MEETING, PROJECT, TEAM, USER_TASKS } from '@core/models/home.model';
+import { Observable } from 'rxjs';
+import { ApiService } from './api.service';
+import { RESPONSE } from '../models/response.model';
+
+@Injectable({
+  providedIn: 'root',
+})
+export class HomeService {
+  constructor(private readonly apiService: ApiService) {}
+
+  getMeetings(): Observable<RESPONSE<MEETING[]>> {
+    return this.apiService.get<RESPONSE<MEETING[]>>('Meeting/GetAll');
+  }
+
+  getUserTasks(): Observable<RESPONSE<USER_TASKS[]>> {
+    return this.apiService.get<RESPONSE<USER_TASKS[]>>('UserTask/GetAll');
+  }
+
+  getTeam(): Observable<RESPONSE<TEAM[]>> {
+    return this.apiService.get<RESPONSE<TEAM[]>>('Team/GetAll');
+  }
+
+  getProjects(): Observable<RESPONSE<PROJECT[]>> {
+    return this.apiService.get<RESPONSE<PROJECT[]>>('Project/GetAll');
+  }
+}

+ 9 - 3
src/app/modules/dashboard/company-dashboard/company-dashboard.component.ts

@@ -1,10 +1,16 @@
-import { Component } from '@angular/core';
+import { Component, OnInit } from '@angular/core';
+import { ComponentBase } from '@core/base/common-base';
+import { HomeService } from '@core/services/home.service';
 
 @Component({
   selector: 'app-company-dashboard',
   templateUrl: './company-dashboard.component.html',
-  styleUrls: ['./company-dashboard.component.scss']
+  styleUrls: ['./company-dashboard.component.scss'],
 })
-export class CompanyDashboardComponent {
+export class CompanyDashboardComponent extends ComponentBase implements OnInit {
+  constructor(private readonly homeService: HomeService) {
+    super();
+  }
 
+  ngOnInit(): void {}
 }

+ 2 - 1
src/app/modules/dashboard/dashboard.component.html

@@ -5,10 +5,11 @@
       <app-today-meetings
         fxFlex.lt-md="100"
         fxFlex.gt-sm="48"
+        [meetingList]="meetingList"
       ></app-today-meetings>
       <app-calender fxFlex.lt-md="100" fxFlex.gt-sm="25"></app-calender>
     </div>
-    <app-today-tasks></app-today-tasks>
+    <app-today-tasks [userTasksList]="userTasks"></app-today-tasks>
   </div>
 </section>
 <router-outlet></router-outlet>

+ 35 - 3
src/app/modules/dashboard/dashboard.component.ts

@@ -1,10 +1,42 @@
-import { Component } from '@angular/core';
+import { Component, OnInit } from '@angular/core';
+import { ComponentBase } from '@core/base/common-base';
+import { HomeService } from '@core/services/home.service';
+import { Observable, takeUntil } from 'rxjs';
+import { MEETING, USER_TASKS } from '../../core/models/home.model';
 
 @Component({
   selector: 'app-dashboard',
   templateUrl: './dashboard.component.html',
-  styleUrls: ['./dashboard.component.scss']
+  styleUrls: ['./dashboard.component.scss'],
 })
-export class DashboardComponent {
+export class DashboardComponent extends ComponentBase implements OnInit {
+  meetingList: MEETING[] = [];
+  userTasks: USER_TASKS[] = [];
+  constructor(private readonly homeService: HomeService) {
+    super();
+  }
 
+  ngOnInit(): void {
+    this.getMeetings();
+    this.getUserTaks();
+  }
+
+  getMeetings(): void {
+    this.homeService
+      .getMeetings()
+      .pipe(takeUntil(this.destroy$))
+      .subscribe((res) => {
+        this.meetingList = res.result;
+      });
+  }
+
+  getUserTaks(): void {
+    this.homeService
+      .getUserTasks()
+      .pipe(takeUntil(this.destroy$))
+      .subscribe((res) => {
+        console.log(res);
+        this.userTasks = res.result;
+      });
+  }
 }

+ 4 - 3
src/app/modules/dashboard/today-meetings/today-meetings.component.ts

@@ -1,10 +1,11 @@
-import { Component } from '@angular/core';
+import { Component, Input } from '@angular/core';
+import { MEETING } from '../../../core/models/home.model';
 
 @Component({
   selector: 'app-today-meetings',
   templateUrl: './today-meetings.component.html',
-  styleUrls: ['./today-meetings.component.scss']
+  styleUrls: ['./today-meetings.component.scss'],
 })
 export class TodayMeetingsComponent {
-
+  @Input() meetingList: MEETING[] = [];
 }

+ 4 - 3
src/app/modules/dashboard/today-tasks/today-tasks.component.ts

@@ -1,10 +1,11 @@
-import { Component } from '@angular/core';
+import { Component, Input } from '@angular/core';
+import { USER_TASKS } from '../../../core/models/home.model';
 
 @Component({
   selector: 'app-today-tasks',
   templateUrl: './today-tasks.component.html',
-  styleUrls: ['./today-tasks.component.scss']
+  styleUrls: ['./today-tasks.component.scss'],
 })
 export class TodayTasksComponent {
-
+  @Input() userTasksList: USER_TASKS[] = [];
 }

+ 0 - 6
src/app/shared/components/error-form/error-form.component.html

@@ -41,10 +41,4 @@
     *ngIf="name === 'password' && !control?.value?.match('(?=.*[!@#$%^&*])')"
     >At least one special character.</mat-error
   >
-
-  <mat-error
-    class="error-message"
-    *ngIf="name === 'password' && !control?.value?.match('(?=.*[!@#$%^&*])')"
-    >At least one special character.</mat-error
-  >
 </span>