"use client";

import { FormControl, InputLabel, Select, MenuItem } from "@mui/material";
import { RANGE_DAYS } from "./constants";

export default function DateRangeSelect({
  value,
  onChange,
  label = "日期範圍",
}: {
  value: number;
  onChange: (v: number) => void;
  label?: string;
}) {
  return (
    <FormControl size="small" sx={{ minWidth: 130 }}>
      <InputLabel>{label}</InputLabel>
      <Select
        value={value}
        label={label}
        onChange={(e) => onChange(Number(e.target.value))}
      >
        {RANGE_DAYS.map((d) => (
          <MenuItem key={d} value={d}>
            最近 {d} 天
          </MenuItem>
        ))}
      </Select>
    </FormControl>
  );
}
