import {
  CreateAlwaysInvalid,
  CreateAlwaysValid,
} from "@theme/JSONSchemaViewer/JSONSchemaElements"

import type { JSX } from "react"
import type { JSONSchema } from "@theme/JSONSchemaViewer/types"

type Props = {
  [x: string]: any
  schema: JSONSchema
}

// Handle the "true" / "false" cases we can find in schemas
export default function CreateValidOrInvalid(props: Props): JSX.Element {
  const { schema } = props

  /**
   * Cases to cover
   * CreateAlwaysValid = true / {}
   * CreateAlwaysInvalid = false
   */
  return (
    <>
      {schema && <CreateAlwaysValid schema={schema} />}
      {!schema && <CreateAlwaysInvalid />}
    </>
  )
}
