ui
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { Component, inject, OnInit } from '@angular/core';
|
||||
import { Component, inject, Injector, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
|
||||
import { UserService } from '../auth/user.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { CardComponent } from './components/card/card.component';
|
||||
import { ClientCardComponent } from './components/card/card.component';
|
||||
import { Client } from '../model/client.interface';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
@@ -10,11 +10,12 @@ import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
import { CreateClientComponent } from './components/create-client/create-client.component';
|
||||
import { CreateHotToastRef, HotToastService } from '@ngxpert/hot-toast';
|
||||
import {MatBottomSheet, MatBottomSheetModule, MatBottomSheetRef} from '@angular/material/bottom-sheet';
|
||||
import { ClientAdminsComponent } from './components/client-admins/client-admins.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard',
|
||||
standalone: true,
|
||||
imports: [CardComponent, MatButtonModule, MatIconModule, MatDialogModule, MatBottomSheetModule],
|
||||
imports: [ClientCardComponent, MatButtonModule, MatIconModule, MatDialogModule, MatBottomSheetModule],
|
||||
templateUrl: './dashboard.component.html',
|
||||
styleUrl: './dashboard.component.scss'
|
||||
})
|
||||
@@ -26,7 +27,9 @@ export class DashboardComponent implements OnInit {
|
||||
private dialog: MatDialog = inject(MatDialog);
|
||||
private toast: HotToastService = inject(HotToastService);
|
||||
private bottomSheet = inject(MatBottomSheet);
|
||||
private injector: Injector = inject(Injector);
|
||||
|
||||
@ViewChild('listSection', { read: ViewContainerRef, static: true }) clientList!: ViewContainerRef;
|
||||
clients: Client[] = [];
|
||||
|
||||
|
||||
@@ -42,6 +45,18 @@ export class DashboardComponent implements OnInit {
|
||||
load() {
|
||||
this.http.get<Client[]>('api/app/user/clients').subscribe(res => {
|
||||
this.clients = res;
|
||||
this.createList();
|
||||
})
|
||||
}
|
||||
|
||||
createList() {
|
||||
this.clientList.clear();
|
||||
this.clients.forEach(c => {
|
||||
const ref = this.clientList.createComponent(ClientCardComponent);
|
||||
ref.instance.client = c;
|
||||
ref.instance.onDelete.subscribe(() => {
|
||||
this.openDeleteDialog(c)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -102,6 +117,7 @@ export class DashboardComponent implements OnInit {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user