import type { MeResponse } from '@features/auth'
import { FormField } from '@shared/ui'
import { ProfileSection } from './ProfileSection'
import styles from './fieldsGrid.module.css'

interface Props {
  data: MeResponse
}

// Legal-account fields. Organization data lives in the nested `legal_entity`
// object; person-level fields are null on these accounts.
// All read-only — organization data is managed admin-side, not by the user.
export function LegalEntityFields({ data }: Props) {
  const le = data.legal_entity
  if (!le) return null

  return (
    <>
      <ProfileSection title="Данные организации">
        <div className={styles.grid2}>
          <FormField label="Наименование" value={le.name ?? ''} placeholder="ООО «Ромашка»" readOnly />
          <FormField label="Краткое наименование" value={le.short_name ?? ''} placeholder="Ромашка" readOnly />
          <FormField label="ИНН" value={le.inn ?? ''} readOnly icon="lock" placeholder="000000000000" />
          <FormField label="ОГРН" value={le.ogrn ?? ''} placeholder="1027700132195" readOnly />
          <FormField label="КПП" value={le.kpp ?? ''} placeholder="770801001" readOnly />
          <FormField label="Адрес электронной почты" value={data.email ?? ''} type="email" icon="check" placeholder="org@mail.ru" readOnly />
        </div>
      </ProfileSection>

      <ProfileSection title="Адреса">
        <div className={styles.grid2}>
          <FormField label="Юридический адрес" value={le.legal_address ?? ''} placeholder="г. Москва, ул. Тверская, д. 1" readOnly />
          <FormField label="Фактический адрес" value={le.actual_address ?? ''} placeholder="г. Москва, ул. Тверская, д. 1" readOnly />
        </div>
      </ProfileSection>

      <ProfileSection title="Контакты и верификация">
        <div className={styles.grid2}>
          <FormField label="Контактное лицо" value={le.contact_person ?? ''} placeholder="Иванов Иван Иванович" readOnly />
          <FormField label="Контактный телефон" value={le.contact_phone ?? ''} type="tel" placeholder="+7 (999) 000-00-00" readOnly />
          <FormField label="Статус" value={le.status ?? ''} placeholder="active" readOnly />
          <FormField label="ID аккаунта" value={data.id ?? ''} readOnly icon="lock" placeholder="ECSA-00000000" />
        </div>
      </ProfileSection>
    </>
  )
}
