import { ReactSelectProps } from '@/types';
import { Select } from './Select';

const OPTION_PENGHASILAN = [
    { label: '1 : < Rp 500.000', value: '1' },
    { label: '2 : Rp 500.000 - Rp 999.999', value: '2' },
    { label: '3 : Rp 1.000.000 - Rp 1.999.999', value: '3' },
    { label: '4 : Rp 2.000.000 - Rp 4.999.999', value: '4' },
    { label: '5 : Rp 5.000.000 - Rp 9.999.999', value: '5' },
    { label: '6 : ≥ Rp 10.000.000', value: '6' },
    { label: '9 : Tidak Berpenghasilan', value: '9' },
];

export const SelectPenghasilan = (props: ReactSelectProps) => {
    return (
        <Select
            value={OPTION_PENGHASILAN?.find((item: { label: string; value: string }) => item.value == props.value) ?? ''}
            options={OPTION_PENGHASILAN}
            isDisabled={props.disable}
            menuPlacement={props.menuPlacement}
            placeholder="Pilih Penghasilan"
            onChange={(newValue: unknown) => {
                const option = newValue as { label: string; value: string };
                props.onChange?.(option?.value ?? '');
            }}
        />
    );
};
