'use client'
import * as React from 'react';
import OutlinedInput from '@mui/material/OutlinedInput';
import InputLabel from '@mui/material/InputLabel';
import MenuItem from '@mui/material/MenuItem';
import FormControl from '@mui/material/FormControl';
import ListItemText from '@mui/material/ListItemText';
import Select, { SelectChangeEvent } from '@mui/material/Select';
import Checkbox from '@mui/material/Checkbox';

const ITEM_HEIGHT = 48;
const ITEM_PADDING_TOP = 8;
const MenuProps = {
  PaperProps: {
    style: {
      maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,
      width: 250,
    },
  },
};

const names = [
  'Under $25k',
  '$25k – $100k',
  '$100k – $500k',
  '$500k – $1M',
  '$1M+',
];

export default function MultipleSelection() {
  const [personName, setPersonName] = React.useState<string[]>([]);

  const handleChange = (event: SelectChangeEvent<typeof personName>) => {
    const {
      target: { value },
    } = event;
    setPersonName(
      // On autofill we get a stringified value.
      typeof value === 'string' ? value.split(',') : value,
    );
  };

  return (
    <div>
      <FormControl sx={{ width: '100%' }}>
        <InputLabel id="monthly-online-revenue">Current Monthly Online Revenue</InputLabel>
        <Select
          labelId="monthly-online-revenue"
          id="monthly-online-revenue"
          multiple
          fullWidth
          value={personName}
          onChange={handleChange}
          input={<OutlinedInput label="Current Monthly Online Revenue" />}
          renderValue={(selected) => selected.join(', ')}
          MenuProps={MenuProps}
          sx={{
            borderRadius:'50px',
            backgroundColor:'white',
            '& .MuiInputBase-root': {
              borderRadius:'50px',
            },
            '& .MuiInputBase-input': {
              borderRadius:'50px',
            },
          }}
        >
          {names.map((name) => (
            <MenuItem key={name} value={name}>
              <Checkbox checked={personName.includes(name)} />
              <ListItemText primary={name} />
            </MenuItem>
          ))}
        </Select>
      </FormControl>
    </div>
  );
}