import PostCoreDataFields from '@/components/posts/PostCoreDataFields'
import PostTextField from '@/components/posts/PostTextField'

import type { FC, ReactNode } from 'react'

import type { PostCoreDataFieldsProps } from '@/components/posts/PostCoreDataFields'

type TextMessages = string[] | undefined

type Props = {
  url: {
    value:       string
    onChange:    (value: string) => void
    errors?:     TextMessages
    warnings?:   TextMessages
    disabled?:   boolean
    type?:       string
    placeholder?: string }
  thumbnailField: ReactNode
  core:           PostCoreDataFieldsProps
  extraFields?:   ReactNode }


const PostCreationDataFields: FC<Props> = (
    { url,
      thumbnailField,
      core,
      extraFields },
) => (
    <>
      <PostTextField
          label="URL"
          type={url.type}
          value={url.value}
          disabled={url.disabled}
          warnings={url.warnings}
          errors={url.errors}
          placeholder={url.placeholder}
          onChange={url.onChange}/>

      {thumbnailField}

      <PostCoreDataFields {...core}/>

      {extraFields}
    </>)

export default PostCreationDataFields
