import React, { useCallback, useState } from 'react'; import { Link } from 'react-router-dom'; import { useAuth } from '../auth-context'; import ConfirmationModal from '../components/confirmation-modal'; import ErrorBox from '../components/error-box'; import { SpinnerIcon } from '../components/icons'; export const MyAccountPage: React.FC = () => { const { isLoading, user, userError, logout, generateApiKey, deleteAccount } = useAuth(); const [showDeleteConfirm, setShowDeleteConfirm] = useState(false); const [error, setError] = useState(undefined); const handleLogout = useCallback((e) => { e.preventDefault(); logout(setError); }, [logout]); const handleGenerateKey = useCallback(async (e) => { e.preventDefault(); setError(undefined); generateApiKey(setError); }, [generateApiKey]); const handleDeleteAccount = useCallback(() => { setError(undefined); deleteAccount(setError); }, [deleteAccount]) if(!user && isLoading) { return (
Loading user info...
); } return (
{ !isLoading && } {!userError && (<>

Welcome, {user.username}!

Colouring London is under active development. Please discuss suggestions for improvements and report issues or problems.

For reference, here are the privacy policy, contributor agreement and data accuracy agreement.

Start colouring

My Details

Username

{user.username}

Email Address

{user.email || '-'}

Registered

{user.registered.toString()}


Technical details

Are you a software developer? If so, you might be interested in these.

API key

{user.api_key || '-'}

Open Source Code

Colouring London site code is developed at colouring-london on Github

Account actions

{ e.preventDefault(); setShowDeleteConfirm(true); }} className="form-group mb-3" >
handleDeleteAccount()} onCancel={() => setShowDeleteConfirm(false)} /> )}
); };