feat: bổ sung phần profile của user
This commit is contained in:
@@ -2788,6 +2788,9 @@ const ProfileModal = ({
|
||||
// Files list state
|
||||
const [filesList, setFilesList] = useState([]);
|
||||
const [loadingFiles, setLoadingFiles] = useState(false);
|
||||
|
||||
// Confirmation modal state
|
||||
const [confirmModal, setConfirmModal] = useState(null);
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
fetchProfile();
|
||||
@@ -2852,15 +2855,20 @@ const ProfileModal = ({
|
||||
};
|
||||
const handleDeleteProject = async (projectId, e) => {
|
||||
e.stopPropagation();
|
||||
if (!confirm("Bạn có chắc chắn muốn xóa dự án này khỏi Cloud?")) return;
|
||||
try {
|
||||
await window.SonicAPI.deleteCloudProject(projectId);
|
||||
showToast("Đã xóa dự án thành công!", "success");
|
||||
fetchProjects();
|
||||
fetchProfile();
|
||||
} catch (err) {
|
||||
showToast(err.message || "Lỗi khi xóa dự án", "error");
|
||||
}
|
||||
setConfirmModal({
|
||||
title: "Xóa dự án Cloud",
|
||||
message: "Bạn có chắc chắn muốn xóa dự án này khỏi Cloud? Hành động này không thể hoàn tác.",
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await window.SonicAPI.deleteCloudProject(projectId);
|
||||
showToast("Đã xóa dự án thành công!", "success");
|
||||
fetchProjects();
|
||||
fetchProfile();
|
||||
} catch (err) {
|
||||
showToast(err.message || "Lỗi khi xóa dự án", "error");
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
const handleDeleteFile = async fileId => {
|
||||
if (!confirm(`Bạn có chắc chắn muốn xóa tệp tin ${fileId}?`)) return;
|
||||
@@ -2910,8 +2918,28 @@ const ProfileModal = ({
|
||||
}
|
||||
};
|
||||
return /*#__PURE__*/React.createElement("div", {
|
||||
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/70 backdrop-blur-sm"
|
||||
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/70 backdrop-blur-sm relative"
|
||||
}, confirmModal && /*#__PURE__*/React.createElement("div", {
|
||||
className: "absolute inset-0 z-[60] flex items-center justify-center bg-black/50"
|
||||
}, /*#__PURE__*/React.createElement("div", {
|
||||
className: "bg-[#262626] border border-[#383838] rounded-lg shadow-2xl p-5 max-w-sm w-full text-slate-200"
|
||||
}, /*#__PURE__*/React.createElement("h4", {
|
||||
className: "text-sm font-bold text-rose-400 mb-2"
|
||||
}, confirmModal.title), /*#__PURE__*/React.createElement("p", {
|
||||
className: "text-xs text-slate-300 mb-4"
|
||||
}, confirmModal.message), /*#__PURE__*/React.createElement("div", {
|
||||
className: "flex justify-end gap-2"
|
||||
}, /*#__PURE__*/React.createElement("button", {
|
||||
onClick: () => setConfirmModal(null),
|
||||
className: "px-3 py-1.5 bg-zinc-700 hover:bg-zinc-600 text-slate-300 rounded text-xs font-semibold"
|
||||
}, "Hủy"), /*#__PURE__*/React.createElement("button", {
|
||||
onClick: () => {
|
||||
const fn = confirmModal.onConfirm;
|
||||
setConfirmModal(null);
|
||||
fn();
|
||||
},
|
||||
className: "px-3 py-1.5 bg-rose-700 hover:bg-rose-600 text-white rounded text-xs font-semibold"
|
||||
}, "Xác nhận xóa")))), /*#__PURE__*/React.createElement("div", {
|
||||
className: "bg-[#262626] border border-[#383838] rounded-xl shadow-2xl w-full max-w-2xl p-6 text-slate-200 flex flex-col max-h-[85vh]"
|
||||
}, /*#__PURE__*/React.createElement("div", {
|
||||
className: "flex justify-between items-center pb-3 border-b border-[#383838] shrink-0"
|
||||
@@ -3067,8 +3095,8 @@ const ProfileModal = ({
|
||||
key: "meta",
|
||||
className: "max-w-[70%]"
|
||||
}, [/*#__PURE__*/React.createElement("div", {
|
||||
className: "font-mono font-semibold text-slate-300 truncate"
|
||||
}, file.file_id.replace(/^user_[^_]+_/, '')), /*#__PURE__*/React.createElement("div", {
|
||||
className: "font-semibold text-slate-300 truncate"
|
||||
}, file.original_name || file.file_id), /*#__PURE__*/React.createElement("div", {
|
||||
className: "text-[10px] text-zinc-500 mt-0.5"
|
||||
}, `Loại: ${file.type} | Dung lượng: ${file.size_mb} MB | Tạo lúc: ${new Date(file.created_at * 1000).toLocaleString()}`)]), /*#__PURE__*/React.createElement("div", {
|
||||
key: "actions",
|
||||
|
||||
Reference in New Issue
Block a user