Adapted some config for the api

This commit is contained in:
Marta Borgia Leiva 2026-02-09 22:46:16 +01:00
parent 773fa7ad6d
commit d1e016b7df
Signed by: a-mayb3
GPG key ID: 293AAC4FED165CE3
9 changed files with 74 additions and 54 deletions

View file

@ -26,7 +26,8 @@
name="description"
[(ngModel)]="description"
rows="4"
placeholder="Optional description"
placeholder="Enter a project description"
required
></textarea>
</div>

View file

@ -10,7 +10,7 @@ import { CreateProjectRequest, Project } from '../../models/projects.models';
standalone: true,
imports: [CommonModule, FormsModule],
templateUrl: './project-create.component.html',
styleUrl: './project-create.component.css'
styleUrl: './project-create.component.css',
})
export class ProjectCreateComponent {
private apiService = inject(ApiService);
@ -27,9 +27,14 @@ export class ProjectCreateComponent {
return;
}
if (!this.description.trim()) {
this.errorMessage.set('Project description is required.');
return;
}
const payload: CreateProjectRequest = {
name: this.name.trim(),
description: this.description.trim() || undefined
description: this.description.trim(),
};
this.isSaving.set(true);
@ -39,7 +44,7 @@ export class ProjectCreateComponent {
next: (project) => {
this.isSaving.set(false);
if (project?.id != null) {
this.router.navigate(['/projects', project.id]);
this.router.navigate(['/projects/', project.id]);
} else {
this.router.navigate(['/']);
}
@ -47,9 +52,9 @@ export class ProjectCreateComponent {
error: (error) => {
this.isSaving.set(false);
this.errorMessage.set(
error?.error?.message || 'Failed to create project. Please try again.'
error?.error?.message || 'Failed to create project. Please try again.',
);
}
},
});
}