);
}
// ─── Advertisements ───────────────────────────────────────────────────────────
const AD_OPTIONS = [
{
key: "show_popup_ads",
label: "Popup ads",
description: "Show promotional popups when you open pages like the dashboard.",
},
{
key: "show_other_ads",
label: "Other ads",
description: "Show banner, hero, and sidebar advertisements across the site.",
},
];
function AdvertisementsSection() {
const { profile, getProfile, updateProfile, profileLoading } = useProfile();
const [confirmPopupOff, setConfirmPopupOff] = useState(false);
useEffect(() => {
getProfile();
}, []);
const showPopupAds = profile?.personal_info?.show_popup_ads ?? true;
const showOtherAds = profile?.personal_info?.show_other_ads ?? true;
// No separate stored flag — "hidden" just means both underlying toggles are off,
// so it can never drift out of sync with them.
const hideAllAds = !showPopupAds && !showOtherAds;
const handleToggle = async (key, value) => {
// Turning popup ads off also turns off other ads — confirm first since
// it's a bigger change than the switch being flipped suggests.
if (key === "show_popup_ads" && value === false) {
setConfirmPopupOff(true);
return;
}
const result = await updateProfile({ [key]: value });
if (result?.success) {
toast("Preference saved.", {
description: "Reload the page for this to take effect."
});
}
};
const confirmTurnOffPopupAndOther = async () => {
setConfirmPopupOff(false);
const result = await updateProfile({ show_popup_ads: false, show_other_ads: false });
if (result?.success) {
toast("Preference saved.", {
description: "Reload the page for this to take effect."
});
}
};
const handleHideAllToggle = async (hide) => {
const result = await updateProfile({ show_popup_ads: !hide, show_other_ads: !hide });
if (result?.success) {
toast("Preference saved.", {
description: "Reload the page for this to take effect."
});
}
};
return (
<>
Hide all ads
Turn off every advertisement across the platform, popups included.
Turn off popup ads?
This will also turn off Other ads (banner, hero, and sidebar advertisements).
You can turn either back on here anytime.
Cancel
Turn off both
>
);
}
// ─── Delete Account ───────────────────────────────────────────────────────────
// Disabled while still in development — keep implemented for when we're ready
// to expose self-service account deletion.
//
// function DeleteAccountSection({ logout }) {
// const navigate = useNavigate();
// const [open, setOpen] = useState(false);
// const [loading, setLoading] = useState(false);
//
// const handleDelete = async () => {
// setLoading(true);
// try {
// await api.delete("/client/profile");
// toast("Account deleted. Goodbye!", {
// action: {
// label: "Close",
// onClick: () => {}
// }
// });
// await logout();
// navigate("/login");
// } catch (err) {
// toast(err?.response?.data?.message ?? "Could not delete account.", {
// action: {
// label: "Close",
// onClick: () => {}
// }
// });
// setLoading(false);
// }
// };
//
// return (
// <>
//
//
//
Delete account
//
// Permanently remove your account and all associated data. This action cannot be undone.
//
//
//
//
//
//
//
//
// Delete your account?
//
// This will permanently delete your account and sign you out of all sessions.
// Your data cannot be recovered after deletion.
//
//
//
// Cancel
//
// {loading ? "Deleting…" : "Yes, delete my account"}
//
//
//
//
// >
// );
// }
// ─── Page ─────────────────────────────────────────────────────────────────────
export default function AccountSettings() {
const { user, logout } = useAuth();
return (
Account Settings
Manage your security, subscription, and preferences.