import { useState } from 'react';
import { Select } from './Select';
import { ReactSelectProps } from '@/types';
import { JENIS_TRANSAKSI_BANK } from '@/const';

export const SelectTransaksiBank = (props: ReactSelectProps) => {
    const [value, setValue] = useState(JENIS_TRANSAKSI_BANK.find((item) => item.value === props.value) ?? '');

    return (
        <Select
            value={value}
            isDisabled={props.disable}
            options={JENIS_TRANSAKSI_BANK}
            placeholder="Transaksi Bank"
            onChange={(newValue: unknown) => {
                const option = newValue as { label: string; value: string };
                setValue(option);
                props.onChange?.(option?.value);
            }}
        />
    );
};
