feat: cho phép người dùng và người quản lí xóa bình luận

This commit is contained in:
2026-06-16 12:21:44 +07:00
parent fc96ee9eb8
commit 047170d4be
4 changed files with 120 additions and 29 deletions
@@ -80,6 +80,19 @@ export const ItineraryTimeline = ({
useTourStore.setState({ legs: updatedLegs });
};
const handleCommentDecrement = (locationId: string) => {
const currentLegs = useTourStore.getState().legs;
const updatedLegs = currentLegs.map(leg => ({
...leg,
locations: leg.locations.map(loc =>
loc.id === locationId
? { ...loc, _count: { ...loc._count, comments: Math.max(0, (loc._count?.comments || 1) - 1) } }
: loc
)
}));
useTourStore.setState({ legs: updatedLegs });
};
// State cho Modal sửa chặng
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
const [editingLegData, setEditingLegData] = useState({
@@ -575,6 +588,7 @@ export const ItineraryTimeline = ({
locationName={commentLocationName}
isPublicView={isPublicView}
onCommentAdded={() => handleCommentIncrement(commentLocationId)}
onCommentDeleted={() => handleCommentDecrement(commentLocationId)}
/>
</div>
);