aboutsummaryrefslogtreecommitdiff
path: root/src/components/input/CurrencySelect.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/input/CurrencySelect.tsx')
-rw-r--r--src/components/input/CurrencySelect.tsx34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/components/input/CurrencySelect.tsx b/src/components/input/CurrencySelect.tsx
new file mode 100644
index 0000000..2b6045b
--- /dev/null
+++ b/src/components/input/CurrencySelect.tsx
@@ -0,0 +1,34 @@
+import { ListItem, Select } from '@umami/react-zen';
+import { useState } from 'react';
+import { useMessages } from '@/components/hooks';
+import { CURRENCIES } from '@/lib/constants';
+
+export function CurrencySelect({ value, onChange }) {
+ const { formatMessage, labels } = useMessages();
+ const [search, setSearch] = useState('');
+
+ return (
+ <Select
+ items={CURRENCIES}
+ label={formatMessage(labels.currency)}
+ value={value}
+ defaultValue={value}
+ onChange={onChange}
+ listProps={{ style: { maxHeight: 300 } }}
+ onSearch={setSearch}
+ allowSearch
+ >
+ {CURRENCIES.map(({ id, name }) => {
+ if (search && !`${id}${name}`.toLowerCase().includes(search)) {
+ return null;
+ }
+
+ return (
+ <ListItem key={id} id={id}>
+ {id} &mdash; {name}
+ </ListItem>
+ );
+ }).filter(n => n)}
+ </Select>
+ );
+}