'use client'; import React, { useState, useEffect } from 'react'; import { useRouter } from 'next/navigation'; import { reactivateAccount } from '@/app/API/profile/updateProfile'; import { getProfile } from '@/app/API/profile/getProfile'; import './reactivate.scss'; const ReactivateAccountPage = () => { const router = useRouter(); const [loading, setLoading] = useState(false); const [initialLoading, setInitialLoading] = useState(true); const [error, setError] = useState(null); const [deletionDate, setDeletionDate] = useState(null); useEffect(() => { const checkDeletionStatus = async () => { try { const response = await getProfile(); if (response.success && response.data) { if (response.data.marked_for_deletion && response.data.deletion_date) { setDeletionDate(new Date(response.data.deletion_date).toLocaleDateString()); } else { router.push('/profile'); } } } catch (err) { setError('Could not retrieve account information'); } finally { setInitialLoading(false); } }; checkDeletionStatus(); }, [router]); const handleReactivate = async () => { setLoading(true); setError(null); try { await reactivateAccount(); router.push('/profile'); } catch (err: any) { setError(err.message || 'Failed to reactivate account'); setLoading(false); } }; if (initialLoading) { return (
Loading...
); } return (

Reactivate Your Account

Your account is currently scheduled for deletion

{error && (
{error}
)}

Would you like to keep your account?

Your account is currently scheduled for deletion on {deletionDate}. You can reactivate your account to cancel the deletion process.

By reactivating your account:

  • Your account will no longer be scheduled for deletion
  • You'll regain full access to all features and your data
  • Any pending orders or transactions will continue to process normally
); }; export default ReactivateAccountPage;