diff --git a/src/components/shared/health-worker/AnnotateConversation.tsx b/src/components/shared/health-worker/AnnotateConversation.tsx index dd70b79..97ba6ca 100644 --- a/src/components/shared/health-worker/AnnotateConversation.tsx +++ b/src/components/shared/health-worker/AnnotateConversation.tsx @@ -1,6 +1,6 @@ import Button from '@/components/partials/buttons/Button'; import { IChat } from '@/interfaces/question.answer.type'; -import { Rate, chatRatings } from '@/interfaces/rating.type'; +import { IAnnotation } from '@/interfaces/rating.type'; import { annotate, getRandomChat, @@ -16,6 +16,8 @@ import { updateRating } from '@/redux/features/ratings/rating.thunk'; import { Link, useNavigate } from 'react-router-dom'; import Secure from '@/helpers/secureLS'; import { roleToPath } from '@/helpers/isAuth'; +import { RATE_VALUES } from '@/constants/rating'; +import { Label, Radio } from 'flowbite-react'; const AnnotateConversation = ({ data }: { data: IChat }) => { const profile = Secure.getProfile(); @@ -23,8 +25,7 @@ const AnnotateConversation = ({ data }: { data: IChat }) => { const [currentLanguage, setCurrentLanguage] = useState<'en' | 'rw'>( 'en', ); - const [annotation, setAnnotation] = useState({ - rating: '' as Rate, + const [annotation, setAnnotation] = useState({ comment: '', }); const { loading } = useAppSelector(state => state.chat); @@ -58,7 +59,6 @@ const AnnotateConversation = ({ data }: { data: IChat }) => { 'The conversation has been annotated successfully.', ); setAnnotation({ - rating: '' as Rate, comment: '', }); onRefresh(); @@ -73,8 +73,10 @@ const AnnotateConversation = ({ data }: { data: IChat }) => { if (data.ratings?.length) { const [first] = data.ratings; setAnnotation({ - rating: first.rating, comment: first.comment || '', + reponse_helpfulness: first.reponse_helpfulness, + response_correctness: first.response_correctness, + response_coherence: first.response_coherence, }); } }, [data]); @@ -149,46 +151,98 @@ const AnnotateConversation = ({ data }: { data: IChat }) => { onSubmit={handleAnnotation} className="md:w-[40%] lg:w-[30%] bg-white rounded-2xl border" > -

- Rate conversation +

+ Rate Question

-
- {chatRatings.map(item => ( - +

+ Helpfulness +

+
+ {RATE_VALUES.map(item => ( +
+ + setAnnotation(prev => ({ + ...prev, + reponse_helpfulness: item, + })) + } + className="checked:bg-yellow-400 checked:ring-yellow-500 focus:ring-yellow-500" + /> + +
+ ))} +
+ +

+ Correctness +

+
+ {RATE_VALUES.map(item => ( +
+ + setAnnotation(prev => ({ + ...prev, + response_correctness: item, + })) + } + className="checked:bg-yellow-400 checked:ring-yellow-500 focus:ring-yellow-500" + /> + +
+ ))} +
+ +

+ Coherence +

+
+ {RATE_VALUES.map(item => ( +
+ + setAnnotation(prev => ({ + ...prev, + response_coherence: item, + })) + } + className="checked:bg-yellow-400 checked:ring-yellow-500 focus:ring-yellow-500" + /> + +
))}
-
+