-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved client details summary into a separate component
- Loading branch information
1 parent
4d62bf0
commit 03d5180
Showing
4 changed files
with
67 additions
and
13 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
...c/app/clients/client-details/client-details-summary/client-details-summary.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div> | ||
<h1 class="font-rajdhani font-semibold text-3xl">{{client?.name}}</h1> | ||
|
||
<div class="grid grid-flow-col gap-[30px] auto-cols-max pt-3"> | ||
<div class="text-gray-50">hourly rate: ${{client?.hourlyRate}}</div> | ||
<div class="text-gray-50">email: {{client?.billingEmail}}</div> | ||
<div class="text-gray-50">official name: {{client?.officialName}}</div> | ||
</div> | ||
@if(this.apiErrors) { | ||
@for (error of this.apiErrors; track $index) { | ||
<div class="text-red-700 text-xs leading-normal inline-block">{{ error }}</div> | ||
} | ||
} | ||
</div> |
50 changes: 50 additions & 0 deletions
50
...src/app/clients/client-details/client-details-summary/client-details-summary.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { ActivatedRoute, Router, RouterLink, RouterLinkActive, RouterModule, RouterOutlet } from '@angular/router'; | ||
import { firstValueFrom, switchMap, of, Observable, catchError, map } from 'rxjs'; | ||
import { HQService } from '../../../services/hq.service'; | ||
import { GetClientRecordV1 } from '../../../models/clients/get-client-v1'; | ||
import { APIError } from '../../../errors/apierror'; | ||
|
||
@Component({ | ||
selector: 'hq-client-details-summary', | ||
standalone: true, | ||
imports: [], | ||
templateUrl: './client-details-summary.component.html' | ||
}) | ||
export class ClientDetailsSummaryComponent implements OnInit { | ||
clientId?: string; | ||
client?: GetClientRecordV1; | ||
apiErrors: string[] = []; | ||
|
||
async ngOnInit(): Promise<void> { | ||
this.route.paramMap.pipe( | ||
switchMap(params => { | ||
this.clientId = params.get('clientId') || undefined; | ||
return this.getClient().pipe( | ||
catchError(error => { | ||
if (error instanceof APIError) { | ||
this.apiErrors = error.errors; | ||
} else { | ||
this.apiErrors = ['An unexpected error has occurred.']; | ||
} | ||
return of(null); | ||
}) | ||
); | ||
}) | ||
).subscribe(client => { | ||
this.client = client ?? undefined; | ||
}); | ||
} | ||
constructor(private hqService: HQService, private router: Router, private route: ActivatedRoute) { } | ||
|
||
|
||
private getClient(): Observable<GetClientRecordV1> { | ||
const request = { "id": this.clientId }; | ||
return this.hqService.getClientsV1(request).pipe( | ||
map(response => response.records[0]), | ||
catchError(error => { | ||
throw error; | ||
}) | ||
); | ||
} | ||
} |
13 changes: 1 addition & 12 deletions
13
src/angular/hq/src/app/clients/client-details/client-details.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters