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

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

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