mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 13:47:15 +01:00
Updated WebsiteSelect behavior. Fixed date select.
This commit is contained in:
parent
f9442001e4
commit
8d5e8b072d
4 changed files with 23 additions and 12 deletions
|
|
@ -1,6 +1,12 @@
|
|||
import { useState } from 'react';
|
||||
import { Select, SelectProps, ListItem, Text } from '@umami/react-zen';
|
||||
import { useUserWebsitesQuery, useWebsiteQuery, useNavigation } from '@/components/hooks';
|
||||
import {
|
||||
useUserWebsitesQuery,
|
||||
useWebsiteQuery,
|
||||
useNavigation,
|
||||
useMessages,
|
||||
} from '@/components/hooks';
|
||||
import { Empty } from '@/components/common/Empty';
|
||||
|
||||
export function WebsiteSelect({
|
||||
websiteId,
|
||||
|
|
@ -10,6 +16,7 @@ export function WebsiteSelect({
|
|||
websiteId?: string;
|
||||
teamId?: string;
|
||||
} & SelectProps) {
|
||||
const { formatMessage, messages } = useMessages();
|
||||
const { router, renderUrl } = useNavigation();
|
||||
const [search, setSearch] = useState('');
|
||||
const { data: website } = useWebsiteQuery(websiteId);
|
||||
|
|
@ -23,6 +30,10 @@ export function WebsiteSelect({
|
|||
setSearch(value);
|
||||
};
|
||||
|
||||
const handleOpenChange = () => {
|
||||
setSearch('');
|
||||
};
|
||||
|
||||
return (
|
||||
<Select
|
||||
{...props}
|
||||
|
|
@ -35,6 +46,10 @@ export function WebsiteSelect({
|
|||
searchValue={search}
|
||||
onSearch={handleSearch}
|
||||
onChange={handleSelect}
|
||||
onOpenChange={handleOpenChange}
|
||||
listProps={{
|
||||
renderEmptyState: () => <Empty message={formatMessage(messages.noResultsFound)} />,
|
||||
}}
|
||||
renderValue={() => (
|
||||
<Text truncate weight="bold" style={{ maxWidth: 160, lineHeight: 1 }}>
|
||||
{website?.name}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue