feat: bổ sung phần profile của user

This commit is contained in:
2026-07-22 18:55:25 +07:00
parent c4302da931
commit 0155abd0da
3 changed files with 103 additions and 24 deletions
+35 -11
View File
@@ -2752,6 +2752,9 @@ const ProfileModal = ({
const [filesList, setFilesList] = useState([]);
const [loadingFiles, setLoadingFiles] = useState(false);
// Confirmation modal state
const [confirmModal, setConfirmModal] = useState(null);
useEffect(() => {
if (isOpen) {
fetchProfile();
@@ -2821,15 +2824,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) => {
@@ -2883,8 +2891,24 @@ 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"
@@ -3024,7 +3048,7 @@ const ProfileModal = ({
className: "flex items-center justify-between p-3 bg-[#1e1e1e] rounded border border-zinc-800 text-xs"
}, [
/*#__PURE__*/React.createElement("div", { 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", className: "flex items-center gap-2" }, [