Skip to content

Commit

Permalink
feat: finalized feedback popup logic:
Browse files Browse the repository at this point in the history
|
  • Loading branch information
jeafreezy committed Nov 28, 2024
1 parent b0dfe2c commit 563aae1
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 113 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/map/legend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const FillLegendStyle = ({
};

const Legend = () => {
const [expandLegend, setExpandLegend] = useState<boolean>(true);
const [expandLegend, setExpandLegend] = useState<boolean>(false);
const { map } = useMap();

const activeLayers = map
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/contents/toast-notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export const TOAST_NOTIFICATIONS = {
approvedPrediction: {
success: "Saved successfully.",
},
resolved: {
success: "Action resolved successfully.",
},
modelPrediction: {
success: "Model predictions retrieved successfully.",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ const TrainingAreaItem: React.FC<
? "Fetching labels..."
: trainingArea.properties.label_fetched !== null
? truncateString(
`Fetched ${timeSinceLabelFetch === "0 sec" ? "just now" : `${timeSinceLabelFetch} ago`}`,
20,
)
`Fetched ${timeSinceLabelFetch === "0 sec" ? "just now" : `${timeSinceLabelFetch} ago`}`,
20,
)
: "No labels yet"}
</p>
</div>
Expand Down
30 changes: 28 additions & 2 deletions frontend/src/features/start-mapping/api/create-feedbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const createFeedback = async ({
source_imagery,
zoom_level,
training,
}: TCreateFeedbackPayload): Promise<Feature> => {
}: TCreateFeedbackPayload): Promise<Feature & { id: number }> => {
return await (
await apiClient.post(API_ENDPOINTS.CREATE_FEEDBACK, {
comments,
Expand All @@ -42,7 +42,7 @@ export const createApprovedPrediction = async ({
geom,
training,
user,
}: TCreateApprovedPredictionPayload): Promise<Feature> => {
}: TCreateApprovedPredictionPayload): Promise<Feature & { id: number }> => {
return await (
await apiClient.post(API_ENDPOINTS.CREATE_APPROVED_PREDICTION, {
config,
Expand All @@ -52,3 +52,29 @@ export const createApprovedPrediction = async ({
})
).data;
};

export type TDeleteModelPredictionFeedbackPayload = {
id: number;
approvePrediction?: boolean;
};

export const deleteModelPredictionFeedback = async ({
id,
}: TDeleteModelPredictionFeedbackPayload) => {
return await (
await apiClient.delete(API_ENDPOINTS.DELETE_FEEDBACK(id))
).data;
};

export type TDeleteApprovedModelPredictionPayload = {
id: number;
createFeedback?: boolean;
};

export const deleteApprovedModelPrediction = async ({
id,
}: TDeleteApprovedModelPredictionPayload) => {
return await (
await apiClient.delete(API_ENDPOINTS.DELETE_APPROVED_PREDICTION(id))
).data;
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Feature, TModelPredictions } from "@/types";
import { TModelPredictions } from "@/types";
import {
MIN_ZOOM_LEVEL_FOR_PREDICTION,
showErrorToast,
Expand Down
Loading

0 comments on commit 563aae1

Please sign in to comment.