mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
More updates to realtime.
This commit is contained in:
parent
28921a7cd5
commit
93b77672f3
28 changed files with 218 additions and 263 deletions
28
components/input/WebsiteSelect.js
Normal file
28
components/input/WebsiteSelect.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { useIntl } from 'react-intl';
|
||||
import { Dropdown, Item } from 'react-basics';
|
||||
import { labels } from 'components/messages';
|
||||
import useApi from 'hooks/useApi';
|
||||
|
||||
export default function WebsiteSelect({ websiteId, onSelect }) {
|
||||
const { formatMessage } = useIntl();
|
||||
const { get, useQuery } = useApi();
|
||||
const { data } = useQuery(['websites:me'], () => get('/me/websites'));
|
||||
|
||||
const renderValue = value => {
|
||||
return data?.find(({ id }) => id === value)?.name;
|
||||
};
|
||||
|
||||
return (
|
||||
<Dropdown
|
||||
items={data}
|
||||
value={websiteId}
|
||||
renderValue={renderValue}
|
||||
onChange={onSelect}
|
||||
alignment="end"
|
||||
placeholder={formatMessage(labels.selectWebsite)}
|
||||
style={{ width: 200 }}
|
||||
>
|
||||
{item => <Item key={item.id}>{item.name}</Item>}
|
||||
</Dropdown>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue