import BottomSelect from "@/components/icons/BottomSelect";
import { Autocomplete, TextField } from "@mui/material";
import { styleTextSelectRight } from "@/mui";

function AutoCompleteSelect({ list, updateData, label }) {
    return (
        <Autocomplete
            disablePortal
            options={list}
            className="!rounded-lg !w-[344px]"
            onChange={(event) => updateData && updateData(event)}
            sx={{
                ...styleTextSelectRight,
                // Hide Icon Number
                '& input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button': {
                    display: 'none'
                },
                '& input[type=number]': {
                    MozAppearance: 'textfield'
                },
                '& .MuiInputBase-root': {
                    borderRadius: 2,
                    padding: '5px 16px !important'
                }
            }}
            renderInput={(params) =>
                <TextField
                    fullWidth
                    {...params}
                    InputProps={{
                        ...params.InputProps,
                        endAdornment: (
                            <div
                                className="absolute left-4"
                            >
                                <BottomSelect />
                            </div>
                        )
                    }}
                    placeholder={label}
                    sx={{
                        borderRadius: '8px',
                    }}
                />
            }
        />
    )
}

export default AutoCompleteSelect