forked from hotosm/fAIr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
77 additions
and
10 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
frontend/src/components/Layout/AIModels/AIModelEditor/Feedback.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { IconButton, Tooltip } from "@mui/material"; | ||
import React, { useContext } from "react"; | ||
import InfoIcon from "@mui/icons-material/Info"; | ||
import FeedbackIcon from "@mui/icons-material/Feedback"; | ||
import { useQuery } from "react-query"; | ||
import axios from "../../../../axios"; | ||
import AuthContext from "../../../../Context/AuthContext"; | ||
import FindReplaceIcon from "@mui/icons-material/FindReplace"; | ||
const Feedback = ({ trainingId }) => { | ||
const { accessToken } = useContext(AuthContext); | ||
const getFeedback = async () => { | ||
try { | ||
const headers = { | ||
"access-token": accessToken, | ||
}; | ||
const res = await axios.get(`/feedback/?training=${trainingId}`, null, { | ||
headers, | ||
}); | ||
|
||
if (res.error) { | ||
} else { | ||
console.log(`/feedback/?training=${trainingId}`, res.data); | ||
return res.data; | ||
} | ||
} catch (e) { | ||
console.log("isError", e); | ||
} finally { | ||
} | ||
}; | ||
const { data: feedbackData, isLoading } = useQuery( | ||
"getFeedback" + trainingId, | ||
getFeedback, | ||
{ | ||
refetchInterval: 10000, | ||
} | ||
); | ||
|
||
return ( | ||
<> | ||
{feedbackData && | ||
feedbackData.features && | ||
feedbackData.features.length > 0 && ( | ||
<Tooltip | ||
title={`Total number of feedback on this training is ${feedbackData.features.length}`} | ||
placement="left" | ||
> | ||
<IconButton aria-label="popup"> | ||
<FeedbackIcon size="small" /> | ||
</IconButton> | ||
</Tooltip> | ||
)} | ||
{isLoading && ( | ||
<IconButton aria-label="popup"> | ||
<FindReplaceIcon size="small" /> | ||
</IconButton> | ||
)} | ||
</> | ||
); | ||
}; | ||
export default Feedback; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters