mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 02:13:33 +00:00
* [bugfix/feature]: Improve ratings Fix: add preventDefault/stopPropagation to prevent scrolling to top in queue Feat: instead of double click for clear, click on same value
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
/* eslint-disable import/no-cycle */
|
|
import type { ICellRendererParams } from '@ag-grid-community/core';
|
|
import { Rating } from '/@/renderer/components/rating';
|
|
import { CellContainer } from '/@/renderer/components/virtual-table/cells/generic-cell';
|
|
import { useSetRating } from '/@/renderer/features/shared';
|
|
|
|
export const RatingCell = ({ value, node }: ICellRendererParams) => {
|
|
const updateRatingMutation = useSetRating({});
|
|
|
|
const handleUpdateRating = (rating: number) => {
|
|
updateRatingMutation.mutate(
|
|
{
|
|
query: {
|
|
item: [value],
|
|
rating,
|
|
},
|
|
serverId: value?.serverId,
|
|
},
|
|
{
|
|
onSuccess: () => {
|
|
node.setData({ ...node.data, userRating: rating });
|
|
},
|
|
},
|
|
);
|
|
};
|
|
|
|
return (
|
|
<CellContainer $position="center">
|
|
<Rating
|
|
size="xs"
|
|
value={value?.userRating}
|
|
onChange={handleUpdateRating}
|
|
/>
|
|
</CellContainer>
|
|
);
|
|
};
|