fix feedback emotion
This commit is contained in:
@ -102,8 +102,8 @@ const ManageFeedbackMemberProvider = ({ children }: { children: React.ReactNode
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.feedbacks_emotion,
|
accessorFn: (row) => row.emotion_label,
|
||||||
id: 'feedback_emotion',
|
id: 'emotion_label',
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Emotion" column={column} />,
|
header: ({ column }) => <DataGridColumnHeader title="Emotion" column={column} />,
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
@ -152,6 +152,17 @@ const ManageFeedbackMemberProvider = ({ children }: { children: React.ReactNode
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const getEmotionLabel = (emotion: string) => {
|
||||||
|
const emotions: Record<string, string> = {
|
||||||
|
'1': 'Very Dissatisfied',
|
||||||
|
'2': 'Dissatisfied',
|
||||||
|
'3': 'Neutral',
|
||||||
|
'4': 'Satisfied',
|
||||||
|
'5': 'Very Satisfied'
|
||||||
|
};
|
||||||
|
return emotions[emotion] || 'N/A';
|
||||||
|
};
|
||||||
|
|
||||||
const getfeedbackLists = async (page: number, limit: number, sorting: any, filter: any) => {
|
const getfeedbackLists = async (page: number, limit: number, sorting: any, filter: any) => {
|
||||||
try {
|
try {
|
||||||
setLastFetchParams({
|
setLastFetchParams({
|
||||||
@ -170,9 +181,13 @@ const ManageFeedbackMemberProvider = ({ children }: { children: React.ReactNode
|
|||||||
order_field: sorting[0].id,
|
order_field: sorting[0].id,
|
||||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
||||||
});
|
});
|
||||||
|
let resFeedback = response?.data.list.map((el: any) => {
|
||||||
|
el.emotion_label = getEmotionLabel(el.feedbacks_emotion)
|
||||||
|
return el;
|
||||||
|
});
|
||||||
// console.log(response?.data);
|
// console.log(response?.data);
|
||||||
setFeedback(response?.data.list);
|
setFeedback(resFeedback);
|
||||||
return { data: response?.data.list, totalCount: response?.data.total_count };
|
return { data: resFeedback, totalCount: response?.data.total_count };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching Feedback Member', error);
|
console.error('Error fetching Feedback Member', error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user