diff --git a/src/lib/components/admin/Evaluations.svelte b/src/lib/components/admin/Evaluations.svelte index 82d5a1347..cae1fd66c 100644 --- a/src/lib/components/admin/Evaluations.svelte +++ b/src/lib/components/admin/Evaluations.svelte @@ -6,7 +6,7 @@ dayjs.extend(relativeTime); import { models } from '$lib/stores'; - import { getAllFeedbacks } from '$lib/apis/evaluations'; + import { deleteFeedbackById, getAllFeedbacks } from '$lib/apis/evaluations'; import FeedbackMenu from './Evaluations/FeedbackMenu.svelte'; import EllipsisHorizontal from '../icons/EllipsisHorizontal.svelte'; @@ -91,9 +91,17 @@ return stats; } - let loaded = false; - onMount(async () => { - feedbacks = await getAllFeedbacks(localStorage.token); + const deleteFeedbackHandler = async (feedbackId: string) => { + const response = await deleteFeedbackById(localStorage.token, feedbackId).catch((err) => { + toast.error(err); + return null; + }); + if (response) { + feedbacks = feedbacks.filter((f) => f.id !== feedbackId); + } + }; + + const rankHandler = async () => { const modelStats = calculateModelStats(feedbacks); rankedModels = $models @@ -121,6 +129,15 @@ // If both ratings are '-', sort alphabetically (by 'name') return a.name.localeCompare(b.name); }); + }; + + $: if (feedbacks) { + rankHandler(); + } + + let loaded = false; + onMount(async () => { + feedbacks = await getAllFeedbacks(localStorage.token); loaded = true; }); @@ -340,7 +357,11 @@ - + { + deleteFeedbackHandler(feedback.id); + }} + >