diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 9f60cad..1d8ce7c 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -11,7 +11,7 @@ import { PrivacyPolicyComponent } from './components/privacy-policy/privacy-poli
// Toutes les routes de l'application sont définies ici
const routes: Routes = [
{ path: '', component: LandingPageComponent },
- { path: 'work', component: WorkComponent },
+ { path: 'work/:id', component: WorkComponent },
{ path: 'editor', component: EditorComponent },
{ path: 'documentation', component: DocumentationComponent },
{ path: 'contact', component: FormComponent },
diff --git a/src/app/components/works-list/works-list.component.css b/src/app/components/works-list/works-list.component.css
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/components/works-list/works-list.component.html b/src/app/components/works-list/works-list.component.html
new file mode 100644
index 0000000..0d10fc6
--- /dev/null
+++ b/src/app/components/works-list/works-list.component.html
@@ -0,0 +1,21 @@
+
Works
+
+
+ -
+ {{ work.id_work }} - {{ work.link }} - {{ work.content }}
+
+
+
+
\ No newline at end of file
diff --git a/src/app/components/works-list/works-list.component.spec.ts b/src/app/components/works-list/works-list.component.spec.ts
new file mode 100644
index 0000000..113215e
--- /dev/null
+++ b/src/app/components/works-list/works-list.component.spec.ts
@@ -0,0 +1,23 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { WorksListComponent } from './works-list.component';
+
+describe('WorksListComponent', () => {
+ let component: WorksListComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ imports: [WorksListComponent]
+ })
+ .compileComponents();
+
+ fixture = TestBed.createComponent(WorksListComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/components/works-list/works-list.component.ts b/src/app/components/works-list/works-list.component.ts
new file mode 100644
index 0000000..4735cc3
--- /dev/null
+++ b/src/app/components/works-list/works-list.component.ts
@@ -0,0 +1,30 @@
+import {Component} from '@angular/core';
+import {Work} from "../../models/work.model";
+import {WorkService} from "../../services/work.service";
+import {NgForOf} from "@angular/common";
+import {FormsModule, NgForm} from "@angular/forms";
+
+@Component({
+ selector: 'app-works-list',
+ standalone: true,
+ imports: [
+ NgForOf,
+ FormsModule
+ ],
+ templateUrl: './works-list.component.html',
+ styleUrl: './works-list.component.css'
+})
+export class WorksListComponent {
+ works: Work[] = [];
+
+ constructor(protected workService: WorkService) {
+ }
+
+ ngOnInit() {
+ this.workService.getWorks().subscribe((response: Work[]) => this.works = response)
+ }
+
+ onSubmit(form: NgForm) {
+ this.workService.postWork(form);
+ }
+}
diff --git a/src/app/services/work.service.ts b/src/app/services/work.service.ts
index 2081c68..df2406e 100644
--- a/src/app/services/work.service.ts
+++ b/src/app/services/work.service.ts
@@ -20,7 +20,7 @@ export class WorkService {
return this.http.get(`${this.API_URL}/works`);
}
- //je veux return un work en fonction d'un link passé en param
+ //je veux return un work en fonction d'un link passé en param getWorksByUser
getWorkByLink(link: string): Observable {
return this.http.get(`${this.API_URL}/work/${link}`);
}
@@ -30,6 +30,7 @@ export class WorkService {
return this.http.get(`${this.API_URL}/work/${id_user}`);
}
+
postWork(form: NgForm): void {
let body = {link: crypto.randomUUID(), id_user: 1, id_language: 1, code: form.value.content, saveDate: new Date()}
this.http.post(`${this.API_URL}/works`, body).subscribe();