2023-01-06 00:39:49 -08:00
|
|
|
import type { ICellRendererParams } from '@ag-grid-community/core';
|
2025-05-18 14:03:18 -07:00
|
|
|
|
2023-01-06 00:39:49 -08:00
|
|
|
import { CellContainer } from '/@/renderer/components/virtual-table/cells/generic-cell';
|
2023-04-30 22:01:52 -07:00
|
|
|
import { useSetRating } from '/@/renderer/features/shared';
|
2025-06-24 00:04:36 -07:00
|
|
|
import { Rating } from '/@/shared/components/rating/rating';
|
2023-01-06 00:39:49 -08:00
|
|
|
|
2025-05-18 14:03:18 -07:00
|
|
|
export const RatingCell = ({ node, value }: ICellRendererParams) => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const updateRatingMutation = useSetRating({});
|
2023-02-05 05:19:01 -08:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
const handleUpdateRating = (rating: number) => {
|
|
|
|
|
updateRatingMutation.mutate(
|
|
|
|
|
{
|
|
|
|
|
query: {
|
|
|
|
|
item: [value],
|
|
|
|
|
rating,
|
|
|
|
|
},
|
|
|
|
|
serverId: value?.serverId,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
onSuccess: () => {
|
|
|
|
|
node.setData({ ...node.data, userRating: rating });
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
};
|
2023-02-05 05:19:01 -08:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
return (
|
2025-06-24 00:04:36 -07:00
|
|
|
<CellContainer position="center">
|
2023-07-01 19:10:05 -07:00
|
|
|
<Rating
|
2025-05-18 14:03:18 -07:00
|
|
|
onChange={handleUpdateRating}
|
2023-07-01 19:10:05 -07:00
|
|
|
size="xs"
|
|
|
|
|
value={value?.userRating}
|
|
|
|
|
/>
|
|
|
|
|
</CellContainer>
|
|
|
|
|
);
|
2023-01-06 00:39:49 -08:00
|
|
|
};
|