add admin navbar and brand/platform management components

This commit is contained in:
Vincent Guillet
2025-10-31 18:32:24 +01:00
parent 6dc9f4ffea
commit 7531ea9453
50 changed files with 842 additions and 227 deletions

View File

@@ -1,8 +1,7 @@
<section class="auth-wrap">
<mat-card class="auth-card">
<mat-card-header>
<mat-card-title>Gestion des produits</mat-card-title>
<mat-card-subtitle>Create a new account</mat-card-subtitle>
<mat-card-title>Ajouter un produit</mat-card-title>
</mat-card-header>
<mat-card-content>
@@ -61,7 +60,7 @@
<mat-form-field appearance="outline">
<mat-label>Marque</mat-label>
<mat-select disableRipple>
@for (brand of brands; track brand.name) {
@for (brand of brands; track brand.id) {
<mat-option [value]="brand">{{ brand.name }}</mat-option>
}
</mat-select>
@@ -71,9 +70,9 @@
<mat-form-field appearance="outline">
<mat-label>Plateforme</mat-label>
<mat-select disableRipple>
<mat-option value="1">Option 1</mat-option>
<mat-option value="2">Option 2</mat-option>
<mat-option value="3">Option 3</mat-option>
@for (platform of platforms; track platform.id) {
<mat-option [value]="platform">{{ platform.name }}</mat-option>
}
</mat-select>
</mat-form-field>

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AddProductComponent } from './add-product.component';
describe('AddProductComponent', () => {
let component: AddProductComponent;
let fixture: ComponentFixture<AddProductComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AddProductComponent]
})
.compileComponents();
fixture = TestBed.createComponent(AddProductComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -12,7 +12,6 @@ import {
MatCardActions,
MatCardContent,
MatCardHeader,
MatCardSubtitle,
MatCardTitle
} from "@angular/material/card";
import {MatCheckbox} from "@angular/material/checkbox";
@@ -24,7 +23,9 @@ import {MatOption, MatSelect} from '@angular/material/select';
import {Router, RouterLink} from '@angular/router';
import {Subscription} from 'rxjs';
import {BrandService} from '../../services/brand/brand.service';
import {Brand} from '../../models/brand/brand';
import {Brand} from '../../interfaces/brand';
import {PlatformService} from '../../services/platform/platform.service';
import {Platform} from '../../interfaces/platform';
@Component({
selector: 'app-add-product',
@@ -36,7 +37,6 @@ import {Brand} from '../../models/brand/brand';
MatCardActions,
MatCardContent,
MatCardHeader,
MatCardSubtitle,
MatCardTitle,
MatCheckbox,
MatDivider,
@@ -60,11 +60,13 @@ export class AddProductComponent implements OnInit, OnDestroy {
isLoading = false;
brands: Brand[] = [];
platforms: Platform[] = [];
private readonly router: Router = inject(Router);
private addProductSubscription: Subscription | null = null;
private readonly addProductSubscription: Subscription | null = null;
private readonly brandService: BrandService = inject(BrandService);
private readonly platformService = inject(PlatformService);
constructor(private readonly formBuilder: FormBuilder) {
this.addProductForm = this.formBuilder.group({
@@ -126,6 +128,18 @@ export class AddProductComponent implements OnInit, OnDestroy {
console.log('Finished fetching brands:', this.brands);
}
});
this.platformService.getPlatforms().subscribe({
next: (platforms) => {
this.platforms = platforms;
},
error: (error) => {
console.error('Error fetching platforms:', error);
},
complete: () => {
console.log('Finished fetching platforms:', this.platforms);
}
});
}
ngOnDestroy(): void {

View File

@@ -1 +1 @@
<p>admin works!</p>
<app-admin-navbar></app-admin-navbar>

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AdminComponent } from './admin.component';
describe('AdminComponent', () => {
let component: AdminComponent;
let fixture: ComponentFixture<AdminComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AdminComponent]
})
.compileComponents();
fixture = TestBed.createComponent(AdminComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,12 +1,15 @@
import { Component } from '@angular/core';
import {AdminNavbarComponent} from '../../components/admin-navbar/admin-navbar.component';
@Component({
selector: 'app-admin',
standalone: true,
imports: [],
templateUrl: './admin.component.html',
styleUrl: './admin.component.css'
standalone: true,
imports: [
AdminNavbarComponent
],
styleUrls: ['./admin.component.scss']
})
export class AdminComponent {
export class AdminComponent{
}

View File

@@ -4,8 +4,8 @@ import {FormBuilder, ReactiveFormsModule, Validators} from '@angular/forms';
import {AuthService} from '../../services/auth/auth.service';
import {Router} from '@angular/router';
import {Subscription} from 'rxjs';
import {Credentials} from '../../interfaces/credentials/credentials';
import {User} from '../../models/user/user.model';
import {Credentials} from '../../interfaces/credentials';
import {User} from '../../interfaces/user';
import {MatInput} from '@angular/material/input';
import {MatButton} from '@angular/material/button';

View File

@@ -10,7 +10,7 @@ import {
import {MatIcon} from '@angular/material/icon';
import {MatButton} from '@angular/material/button';
import {AuthService} from '../../services/auth/auth.service';
import {User} from '../../models/user/user.model';
import {User} from '../../interfaces/user';
import {Router} from '@angular/router';
@Component({