fix: tạo tags cho ảnh public của guest

This commit is contained in:
2026-06-23 16:01:46 +07:00
parent 9f41400bd8
commit 28ea9abccd
28 changed files with 601 additions and 60 deletions
+13 -3
View File
@@ -3,6 +3,8 @@ import { X, Send, MessageSquare, User, Loader2, Calendar, MapPin, Download, Edit
import { io } from 'socket.io-client';
import { CoordinateSelectModal } from './CoordinateSelectModal';
import { useTranslation } from '../hooks/useTranslation';
import { useConfirm } from '../hooks/useConfirm';
import { useNotification } from '../hooks/useNotification';
interface Comment {
id: string;
@@ -48,6 +50,8 @@ export const PublicPhotoModal: React.FC<PublicPhotoModalProps> = ({
onUpdatePhoto
}) => {
const { t } = useTranslation();
const confirm = useConfirm();
const notify = useNotification();
const [comments, setComments] = useState<Comment[]>([]);
const [newComment, setNewComment] = useState('');
const [isLoading, setIsLoading] = useState(false);
@@ -358,7 +362,12 @@ export const PublicPhotoModal: React.FC<PublicPhotoModalProps> = ({
};
const handleDeleteComment = async (commentId: string) => {
if (!confirm(t('confirmDeleteComment') || 'Bạn có chắc chắn muốn xóa bình luận này không?')) return;
const shouldDelete = await confirm({
title: t('deleteComment') || 'Xóa bình luận',
message: t('confirmDeleteComment') || 'Bạn chắc chắn muốn xóa bình luận này không?'
});
if (!shouldDelete) return;
try {
const token = localStorage.getItem('token') || localStorage.getItem('guest_token');
const res = await fetch(`/api/v1/public-photos/comments/${commentId}`, {
@@ -369,13 +378,14 @@ export const PublicPhotoModal: React.FC<PublicPhotoModalProps> = ({
});
if (res.ok) {
setComments(prev => prev.filter(c => c.id !== commentId));
notify({ title: 'Thành công', message: 'Bình luận đã đưc xóa.', type: 'success' });
} else {
const err = await res.json();
alert(err.message || 'Lỗi khi xóa bình luận.');
notify({ title: 'Lỗi', message: err.message || 'Lỗi khi xóa bình luận.', type: 'error' });
}
} catch (error) {
console.error('Lỗi khi xóa bình luận:', error);
alert('Không thể kết nối đến máy chủ.');
notify({ title: 'Lỗi', message: 'Không thể kết nối đến máy chủ.', type: 'error' });
}
};