mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
Fix: Currency Select.
This commit is contained in:
@@ -11,6 +11,7 @@ export default function CurrencySelectList({
|
|||||||
defaultSelectText = <T id={'select_currency_code'} />,
|
defaultSelectText = <T id={'select_currency_code'} />,
|
||||||
onCurrencySelected,
|
onCurrencySelected,
|
||||||
popoverFill = false,
|
popoverFill = false,
|
||||||
|
disabled = false,
|
||||||
}) {
|
}) {
|
||||||
const [selectedCurrency, setSelectedCurrency] = useState(null);
|
const [selectedCurrency, setSelectedCurrency] = useState(null);
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ export default function CurrencySelectList({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onCurrencySelect = useCallback((currency) => {
|
const onCurrencySelect = useCallback((currency) => {
|
||||||
setSelectedCurrency({ ...currency });
|
setSelectedCurrency({ ...currency });
|
||||||
onCurrencySelected && onCurrencySelected(currency);
|
onCurrencySelected && onCurrencySelected(currency);
|
||||||
@@ -45,6 +46,15 @@ export default function CurrencySelectList({
|
|||||||
);
|
);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (typeof selectedCurrencyCode !== 'undefined') {
|
||||||
|
const currency = selectedCurrencyCode
|
||||||
|
? currenciesList.find((a) => a.currency_code === selectedCurrencyCode)
|
||||||
|
: null;
|
||||||
|
setSelectedCurrency(currency);
|
||||||
|
}
|
||||||
|
}, [selectedCurrencyCode, currenciesList, setSelectedCurrency]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
items={currenciesList}
|
items={currenciesList}
|
||||||
@@ -62,8 +72,9 @@ export default function CurrencySelectList({
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
|
disabled={disabled}
|
||||||
text={
|
text={
|
||||||
selectedCurrency ? selectedCurrencyCode : defaultSelectText
|
selectedCurrency ? selectedCurrency.currency_code : defaultSelectText
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Select>
|
</Select>
|
||||||
|
|||||||
Reference in New Issue
Block a user