// src/pages/admin/components/ProfileManager.tsx import React, { useState, useEffect } from 'react'; import type { Profile, Address, UserProfile } from '../../../types'; import { useApi } from '../../../hooks/useApi'; import * as apiClient from '../../../services/apiClient'; import { notifySuccess, notifyError } from '../../../services/notificationService'; import { logger } from '../../../services/logger.client'; import { LoadingSpinner } from '../../../components/LoadingSpinner'; import { XMarkIcon } from '../../../components/icons/XMarkIcon'; import { GoogleIcon } from '../../../components/icons/GoogleIcon'; import { GithubIcon } from '../../../components/icons/GithubIcon'; import { ConfirmationModal } from '../../../components/ConfirmationModal'; // This path is correct import { PasswordInput } from '../../../components/PasswordInput'; import { MapView } from '../../../components/MapView'; import type { AuthStatus } from '../../../hooks/useAuth'; import { AuthView } from './AuthView'; import { AddressForm } from './AddressForm'; import { useProfileAddress } from '../../../hooks/useProfileAddress'; export interface ProfileManagerProps { isOpen: boolean; onClose: () => void; authStatus: AuthStatus; userProfile: UserProfile | null; // Can be null for login/register onProfileUpdate: (updatedProfile: Profile) => void; onSignOut: () => void; onLoginSuccess: (user: UserProfile, token: string, rememberMe: boolean) => void; // Add login handler } // --- API Hook Wrappers --- // These wrappers adapt the apiClient functions (which expect an ApiOptions object) // to the signature expected by the useApi hook (which passes a raw AbortSignal). // They are defined outside the component to ensure they have a stable identity // across re-renders, preventing infinite loops in useEffect hooks. const updateAddressWrapper = (data: Partial
, signal?: AbortSignal) => apiClient.updateUserAddress(data, { signal }); const updatePasswordWrapper = (password: string, signal?: AbortSignal) => apiClient.updateUserPassword(password, { signal }); const exportDataWrapper = (signal?: AbortSignal) => apiClient.exportUserData({ signal }); const deleteAccountWrapper = (password: string, signal?: AbortSignal) => apiClient.deleteUserAccount(password, { signal }); const updatePreferencesWrapper = (prefs: PartialManage your profile, preferences, and security.
Download a JSON file of your profile, watched items, and shopping lists.
This action is permanent and cannot be undone. All your data will be erased.
{!isConfirmingDelete ? ( ) : ( )}Choose your preferred visual theme.
Select your preferred system of measurement.