import { DateInput } from '@based/ui'
import { useState } from 'react'

export const meta: Based.UI.Extractor.MetaDescriptor = {
  name: 'Date Input',
  group: 'Inputs',
  section: 'components',
  icon: 'edit',
  component: DateInput,
  subtitle:
    'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
  showApi: true,
  showUsage: true,
}

export const blocks: Based.UI.Extractor.BlocksDescriptor[] = [
  {
    name: 'Date',
    type: 'component',
    description: 'Date input with placeholder and date variant.',
    style: {
      frame: false,
      size: 'small',
      flex: {
        alignItems: 'center',
        justifyContent: 'center',
      },
    },
    render: () => {
      const [value, setValue] = useState<number>()
      return (
        <div style={{ width: 360 }}>
          <DateInput
            value={value}
            onChange={setValue}
            placeholder="Pick date"
            variant="date"
          />
        </div>
      )
    },
  },
  {
    name: 'Date & Time',
    type: 'component',
    description: 'Date input with placeholder and date-time variant.',
    style: {
      frame: false,
      size: 'small',
      flex: {
        alignItems: 'center',
        justifyContent: 'center',
      },
    },
    render: () => {
      const [value, setValue] = useState<number>()
      return (
        <div style={{ width: 360 }}>
          <DateInput
            variant="date-time"
            value={value}
            onChange={setValue}
            placeholder="Pick date & time"
          />
        </div>
      )
    },
  },
]
