import CalendarEdit from "@/components/icons/CalendarEdit";
import { convertToJalali } from "@/helper";
import { Button } from "@mui/material";
import JalaliDatePicker from "@/components/common/JalaliDatePicker";

function DateBirthday({ data, changeData, error }) {
  return (
    <div className="w-full">
      <div className="relative">
        <JalaliDatePicker
          value={data}
          placeholder="تاریخ تولد"
          error={error}
          stepwise
          onChange={(e) => {
            changeData(convertToJalali(e._d), "birthday");
          }}
          textFieldProps={{
            InputProps: {
              endAdornment: (
                <Button className="!min-w-fit !p-1">
                  <CalendarEdit />
                </Button>
              ),
            },
          }}
        />
      </div>
    </div>
  );
}

export default DateBirthday;
