import { DateTimePicker } from "@mui/x-date-pickers/DateTimePicker"
import { Dayjs } from "dayjs"

import { DateOrTimeView } from "@mui/x-date-pickers"
const xx = "日一二三四五六"
function trans(d: number) {
  return xx.charAt(d)
}

export default function CustomDateTimePicker({
  value,
  onChange,
  views,
}: {
  value?: Dayjs
  onChange: (newValue: Dayjs) => void
  views?: DateOrTimeView[]
}) {
  return (
    <DateTimePicker
      views={views}
      slotProps={{ textField: { size: "small" } }}
      value={value}
      onChange={newValue => newValue && onChange(newValue)}
      dayOfWeekFormatter={date => {
        return trans(date.day())
      }}
    />
  )
}
