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:
@@ -223,6 +223,19 @@ export const TourDetailPage = ({ onBack, tourId, isPublicView = false }: { onBac
|
||||
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 });
|
||||
};
|
||||
|
||||
const fetchPublicTours = useTourStore(state => state.fetchPublicTours);
|
||||
const setMapCenter = useTourStore(state => state.setMapCenter);
|
||||
const updateTourStartPoint = useTourStore(state => state.updateTourStartPoint);
|
||||
@@ -1199,6 +1212,7 @@ export const TourDetailPage = ({ onBack, tourId, isPublicView = false }: { onBac
|
||||
locationName={commentLocationName}
|
||||
isPublicView={isPublicView} // Pass isPublicView
|
||||
onCommentAdded={() => handleCommentIncrement(commentLocationId)}
|
||||
onCommentDeleted={() => handleCommentDecrement(commentLocationId)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user