feat: ability to edit suggestions when accepting

This commit is contained in:
2026-02-04 21:37:57 -08:00
parent 729f410443
commit 800b9f6c2d
5 changed files with 383 additions and 11 deletions
+12 -4
View File
@@ -75,10 +75,18 @@ export class ApiService {
delete<T>(endpoint: string): Observable<T> {
return this.ensureCsrfToken().pipe(
switchMap(() => this.http.delete<T>(`${this.apiUrl}${endpoint}`, {
headers: this.getHeaders(),
withCredentials: true
}))
switchMap(() => {
// Don't send Content-Type for DELETE requests as they have no body
const headers: Record<string, string> = {};
const token = this.csrfToken();
if (token) {
headers['X-CSRF-Token'] = token;
}
return this.http.delete<T>(`${this.apiUrl}${endpoint}`, {
headers: new HttpHeaders(headers),
withCredentials: true
});
})
);
}
@@ -49,6 +49,10 @@ export class SuggestionService {
return firstValueFrom(this.api.put<Suggestion>(`/suggestions/${id}/accept`, {}));
}
async acceptSuggestionWithEdits(id: string, data: any): Promise<Suggestion> {
return firstValueFrom(this.api.put<Suggestion>(`/suggestions/${id}/accept-with-edits`, data));
}
async declineSuggestion(id: string, data: DeclineSuggestionDto): Promise<Suggestion> {
return firstValueFrom(this.api.put<Suggestion>(`/suggestions/${id}/decline`, data));
}