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

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

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