import { useState } from 'react' import { apiFetch } from '../api' import { useAuth } from '../context/AuthContext' import { WORKSHOP_SAMPLES_REMOVED_KEY } from '../lib/creations' const LS_KEYS = [ 'persona_draft_v1', 'advisor_draft_v1', 'persona_chat_v1', 'advisor_chat_v1', 'creations_v1', WORKSHOP_SAMPLES_REMOVED_KEY, ] type Props = { onClose: () => void } export function ClearDataModal({ onClose }: Props) { const { user } = useAuth() const [clearProfile, setClearProfile] = useState(true) const [clearLocal, setClearLocal] = useState(true) const run = async () => { if (clearLocal) { for (const k of LS_KEYS) localStorage.removeItem(k) } if (clearProfile && user) { const r = await apiFetch('/api/users/me/clear-data', { method: 'POST' }) if (!r.ok) { alert('Could not clear server data. You may need to sign in again.') } } onClose() window.location.reload() } return (

Clear User Data

) }