import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" import { faCheckCircle, faSpinner, faXmarkCircle } from "@fortawesome/free-solid-svg-icons" import { useMetadata, useMutateMetadata } from "../profile/hooks/useMetadata" import { useState, useEffect } from 'react' export default function UserMetadata() { const { status, data, error, isFetching, isPending } = useMetadata() const mutateMetadata = useMutateMetadata() const username = `${data?.metadata?.first_name || ''} ${data?.metadata?.last_name || ''}`.trim(); const { metadata } = data || {}; const [ isUsernamePublic, setIsUsernamePublic ] = useState(metadata?.isUsernamePublic || false) useEffect(() => { mutateMetadata.mutate({ isUsernamePublic }) }, [ isUsernamePublic ]) return ( <> {isPending && }
Display {username} publicly? setIsUsernamePublic(evt.target.checked)}/> {(mutateMetadata.status === 'success') && } {(mutateMetadata.status === 'pending') && } {(mutateMetadata.status === 'error') && }
) }