// Расширенный интерфейс пользователя с аватаром
export interface UserData {
  id: string
  phone: string
  avatar?: string
  organization?: {
    id: string
    orgName?: string
    name?: string
    fullName?: string
    type?: 'FULFILLMENT' | 'SELLER' | 'LOGIST' | 'WHOLESALE'
    inn?: string
    [key: string]: any
  }
  [key: string]: any
}

export interface UserSettingsFormData {
  // Контактные данные организации
  orgPhone: string
  managerName: string
  telegram: string
  whatsapp: string
  email: string

  // Организация - данные могут быть заполнены из DaData
  orgName: string
  address: string

  // Юридические данные - могут быть заполнены из DaData
  fullName: string
  inn: string
  ogrn: string
  registrationPlace: string

  // Финансовые данные - требуют ручного заполнения
  bankName: string
  bik: string
  accountNumber: string
  corrAccount: string

  // API ключи маркетплейсов
  wildberriesApiKey: string
  ozonApiKey: string

  // Рынок для поставщиков
  market: string
}

export interface SaveMessage {
  type: 'success' | 'error'
  text: string
}

export interface UserSettingsState {
  isEditing: boolean
  saveMessage: SaveMessage | null
  isUploadingAvatar: boolean
  localAvatarUrl: string | null
}

export interface PhoneData {
  value?: string
  [key: string]: unknown
}

export interface OrganizationData {
  id?: string
  phones?: PhoneData[]
  emails?: PhoneData[]
  name?: string
  orgName?: string
  address?: string
  fullName?: string
  inn?: string
  ogrn?: string
  registrationPlace?: string
  registrationDate?: string
  bankName?: string
  bik?: string
  accountNumber?: string
  corrAccount?: string
  managerName?: string
  telegram?: string
  whatsapp?: string
  email?: string
  wildberriesApiKey?: string
  ozonApiKey?: string
  market?: string
  type?: 'FULFILLMENT' | 'SELLER' | 'LOGIST' | 'WHOLESALE'
  [key: string]: unknown
}

export interface ProfileBlockProps {
  user: UserData | null
  localAvatarUrl: string | null
  isUploadingAvatar: boolean
  onAvatarUpload: (file: File) => Promise<void>
}

export interface ContactsBlockProps {
  formData: UserSettingsFormData
  setFormData: (data: UserSettingsFormData) => void
  isEditing: boolean
  phoneInputRef: React.RefObject<HTMLInputElement | null>
  whatsappInputRef: React.RefObject<HTMLInputElement | null>
}

export interface OrganizationBlockProps {
  formData: UserSettingsFormData
  setFormData: (data: UserSettingsFormData) => void
  isEditing: boolean
  onDaDataSearch: (inn: string) => Promise<void>
}

export interface LegalBlockProps {
  formData: UserSettingsFormData
  setFormData: (data: UserSettingsFormData) => void
  isEditing: boolean
}

export interface FinancialBlockProps {
  formData: UserSettingsFormData
  setFormData: (data: UserSettingsFormData) => void
  isEditing: boolean
}

export interface IntegrationsBlockProps {
  formData: UserSettingsFormData
  setFormData: (data: UserSettingsFormData) => void
  isEditing: boolean
}

export interface MarketBlockProps {
  formData: UserSettingsFormData
  setFormData: (data: UserSettingsFormData) => void
  isEditing: boolean
}
