forked from hotosm/fAIr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-feedbacks.ts
More file actions
92 lines (84 loc) · 2.06 KB
/
create-feedbacks.ts
File metadata and controls
92 lines (84 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { FeedbackType } from "@/enums/start-mapping";
import { API_ENDPOINTS, apiClient } from "@/services";
import { Feature, TModelPredictionFeature } from "@/types";
export type TCreateFeedbackPayload = {
comments: string;
feedback_type: string;
geom: string;
source_imagery: string;
zoom_level: number;
training: number;
};
export const createFeedback = async ({
comments,
feedback_type,
geom,
source_imagery,
zoom_level,
training,
}: TCreateFeedbackPayload): Promise<Feature & { id: number }> => {
return await (
await apiClient.post(API_ENDPOINTS.CREATE_FEEDBACK, {
comments,
feedback_type,
geom,
source_imagery,
zoom_level,
training,
action: FeedbackType.REJECT
})
).data;
};
export type TCreateApprovedPredictionPayload = {
config: {
area_threshold: number;
use_josm_q: boolean;
max_angle_change: number;
skew_tolerance: number;
zoom_level: number;
confidence: number;
tolerance: number;
source_imagery: string;
};
geom: string;
training: number;
user: number;
};
export const createApprovedPrediction = async ({
config,
geom,
training,
user,
}: TCreateApprovedPredictionPayload): Promise<TModelPredictionFeature> => {
return await (
await apiClient.post(API_ENDPOINTS.CREATE_FEEDBACK, {
config,
training,
geom,
user,
action: FeedbackType.ACCEPT
})
).data;
};
export type TDeleteModelPredictionFeedbackPayload = {
id: number;
approvePrediction?: boolean;
};
export const deleteModelPredictionFeedback = async ({
id,
}: TDeleteModelPredictionFeedbackPayload): Promise<TModelPredictionFeature> => {
return await (
await apiClient.delete(API_ENDPOINTS.DELETE_FEEDBACK(id))
).data;
};
export type TDeleteApprovedModelPredictionPayload = {
id: number;
createFeedback?: boolean;
};
export const deleteApprovedModelPrediction = async ({
id,
}: TDeleteApprovedModelPredictionPayload): Promise<TModelPredictionFeature> => {
return await (
await apiClient.delete(API_ENDPOINTS.DELETE_FEEDBACK(id))
).data;
};