// "Is this you?" — claim an official's profile and propose edits (#1062). // Verified claims (sign-in email matches the official address) can propose a new // title, biography or photo URL; any claimant can send feedback. Every submission // is stored pending for review — nothing is published automatically or emailed. import { useEffect, useState, type FormEvent } from 'react' import { useAuth } from '../contexts/AuthContext' import { claimErrorMessage, claimProfile, fetchMyClaim, proposeProfileEdit, type PersonClaim, type ProfileEditField, } from '../api/personClaims' const PROVIDERS: { id: string; name: string }[] = [ { id: 'google', name: 'Google' }, { id: 'facebook', name: 'Facebook' }, { id: 'github', name: 'GitHub' }, ] const buttonClass = 'min-h-[44px] rounded-lg border border-slate-300 bg-white px-4 py-2 text-sm font-semibold text-slate-800 shadow-sm hover:bg-slate-100 focus:outline-none focus:ring-2 focus:ring-teal-600 disabled:opacity-50' const primaryClass = 'min-h-[44px] rounded-lg bg-teal-700 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-teal-800 focus:outline-none focus:ring-2 focus:ring-teal-600 disabled:opacity-50' function EditField({ claimId, field, label, multiline, placeholder, inputType = 'text', }: { claimId: number field: ProfileEditField label: string multiline?: boolean placeholder?: string inputType?: string }) { const [value, setValue] = useState('') const [state, setState] = useState<'idle' | 'sending' | 'sent'>('idle') const [error, setError] = useState(null) const inputId = `claim-${field}` const submit = async (e: FormEvent) => { e.preventDefault() if (!value.trim()) return setState('sending') setError(null) try { await proposeProfileEdit(claimId, field, value.trim()) setState('sent') setValue('') } catch (err) { setError(claimErrorMessage(err, 'Could not send this. Please try again.')) setState('idle') } } const inputClass = 'w-full rounded-md border border-slate-300 px-3 py-2 text-sm text-slate-900 focus:outline-none focus:ring-2 focus:ring-teal-600' return (
{multiline ? (