mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 20:57:17 +01:00
Moved code into src folder. Added build for component library.
This commit is contained in:
parent
7a7233ead4
commit
ede658771e
490 changed files with 749 additions and 442 deletions
28
src/components/input/WebsiteSelect.js
Normal file
28
src/components/input/WebsiteSelect.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { Dropdown, Item } from 'react-basics';
|
||||
import useApi from 'components/hooks/useApi';
|
||||
import useMessages from 'components/hooks/useMessages';
|
||||
|
||||
export function WebsiteSelect({ websiteId, onSelect }) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { get, useQuery } = useApi();
|
||||
const { data } = useQuery(['websites:me'], () => get('/me/websites'));
|
||||
|
||||
const renderValue = value => {
|
||||
return data?.data?.find(({ id }) => id === value)?.name;
|
||||
};
|
||||
|
||||
return (
|
||||
<Dropdown
|
||||
items={data?.data}
|
||||
value={websiteId}
|
||||
renderValue={renderValue}
|
||||
onChange={onSelect}
|
||||
alignment="end"
|
||||
placeholder={formatMessage(labels.selectWebsite)}
|
||||
>
|
||||
{({ id, name }) => <Item key={id}>{name}</Item>}
|
||||
</Dropdown>
|
||||
);
|
||||
}
|
||||
|
||||
export default WebsiteSelect;
|
||||
Loading…
Add table
Add a link
Reference in a new issue