generated from nhcarrigan/template
feat: ability to edit suggestions when accepting
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user