import React, { useEffect, useMemo, useState } from 'react'; import { __ } from '@wordpress/i18n'; import { api } from '../api'; import { Card, Button, Badge, Notice, ScoreRing, MediaPicker, PageState } from './ui'; import Explain from './Explain'; /** * Comma-separated list editor. * * A repeater with add/remove buttons per row looks more serious and is slower * to use for exactly the fields people paste from somewhere else. One field, * commas, and a live chip preview so nothing is silently mangled. */ function ListField({ label, hint, value, onChange, placeholder }) { const [text, setText] = useState((value || []).join(', ')); useEffect(() => { setText((value || []).join(', ')); // eslint-disable-next-line react-hooks/exhaustive-deps }, [JSON.stringify(value || [])]); const commit = (raw) => { setText(raw); onChange( raw .split(',') .map((s) => s.trim()) .filter(Boolean) ); }; const chips = text .split(',') .map((s) => s.trim()) .filter(Boolean); return (
commit(e.target.value)} /> {hint && (

{hint}

)} {chips.length > 0 && (
{chips.map((c, i) => ( {c} ))}
)}
); } export default function Identity() { const [data, setData] = useState(null); const [id, setId] = useState(null); const [busy, setBusy] = useState(false); const [saved, setSaved] = useState(false); const [error, setError] = useState(null); const [showJson, setShowJson] = useState(false); useEffect(() => { api .get('/settings/schema') .then((d) => { setData(d); setId(d.settings.identity || {}); }) .catch((e) => setError(e.message)); }, []); const set = (patch) => setId((prev) => ({ ...prev, ...patch })); const save = async () => { setBusy(true); setError(null); try { // Only the fields this screen owns. Spreading the whole settings // snapshot would revert anything changed on the Overview tab since // this component mounted — the same clobber, in the other direction. const next = await api.put('/settings/schema', { identity: id, org_type: data.settings.org_type, org_name: data.settings.org_name, }); setData(next); setId(next.settings.identity || {}); setSaved(true); setTimeout(() => setSaved(false), 2400); } catch (e) { setError(e.message); } finally { setBusy(false); } }; const typeGroups = useMemo(() => Object.entries(data?.types || {}), [data]); if (!data || !id) return ; const entity = data.entity || { score: 0, missing: [] }; const identifiers = Object.entries(data.identifiers || {}); const policies = Object.entries(data.policies || {}); const contactTypes = data.contactTypes || {}; const contacts = id.contacts || []; const setContact = (i, patch) => set({ contacts: contacts.map((c, j) => (i === j ? { ...c, ...patch } : c)) }); return (
{__('Save identity', 'ai-rank-suite')} } >

{__('A search engine ranks pages. An assistant answers a question, and to answer it, it has to decide whose answer to repeat. That decision runs on entities — a resolved, cross-referenced thing in a knowledge graph — not on keywords.', 'ai-rank-suite')}

{__('Organization + name + logo', 'ai-rank-suite')} {__('does not resolve to anything; it is a label. Registration identifiers, links to profiles the graph already holds, and an explicit list of the subjects you claim expertise in are what turn a label into an entity that can be cited by name.', 'ai-rank-suite')}

{entity.missing.length > 0 && (
{__('Worth adding, strongest first', 'ai-rank-suite')}
{entity.missing.slice(0, 4).map((m) => (
{m.label}
{m.why}
))}
)} {entity.missing.length === 0 && {__('Every high-value entity field is filled in.', 'ai-rank-suite')}}
{error && {error}} {saved && ✓ Saved}
setData({ ...data, settings: { ...data.settings, org_name: e.target.value } })} />
set({ logo: url })} hint={__('What Google shows beside your name in a Knowledge Panel. Square, at least 112×112px. Without one, the site icon (favicon) is used — rarely how a brand wants to appear.', 'ai-rank-suite')} />
set({ legal_name: e.target.value })} />
set({ alt_name: e.target.value })} />