53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import { Injectable, inject } from '@angular/core';
|
|
import { HttpClient } from '@angular/common/http';
|
|
import { environment } from '../../environments/environment';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class ActivityService {
|
|
private http = inject(HttpClient);
|
|
private apiUrl = environment.apiUrl + '/activities';
|
|
|
|
getActivities(projectId?: number, specialtyId?: number) {
|
|
const params: any = {};
|
|
if (projectId) params.project_id = projectId;
|
|
if (specialtyId) params.specialty_id = specialtyId;
|
|
|
|
return this.http.get<any[]>(this.apiUrl, { params });
|
|
}
|
|
|
|
getActivity(id: number) {
|
|
return this.http.get<any>(`${this.apiUrl}/${id}`);
|
|
}
|
|
|
|
createActivity(activity: any) {
|
|
return this.http.post<any>(this.apiUrl, activity);
|
|
}
|
|
|
|
uploadEvidence(activityId: number, file: File, description?: string, capturedAt?: string) {
|
|
const formData = new FormData();
|
|
formData.append('file', file);
|
|
if (description) formData.append('description', description);
|
|
if (capturedAt) formData.append('captured_at', capturedAt);
|
|
|
|
return this.http.post<any>(`${this.apiUrl}/${activityId}/upload`, formData);
|
|
}
|
|
|
|
updateActivity(id: number, activity: any) {
|
|
return this.http.put<any>(`${this.apiUrl}/${id}`, activity);
|
|
}
|
|
|
|
retryTranscription(evidenceId: number) {
|
|
return this.http.post<any>(`${this.apiUrl}/evidence/${evidenceId}/retry-transcription`, {});
|
|
}
|
|
|
|
updateEvidence(evidenceId: number, data: any) {
|
|
return this.http.put<any>(`${this.apiUrl}/evidence/${evidenceId}`, data);
|
|
}
|
|
|
|
deleteEvidence(evidenceId: number) {
|
|
return this.http.delete<any>(`${this.apiUrl}/evidence/${evidenceId}`);
|
|
}
|
|
}
|