Updated WebsiteSelect behavior. Fixed date select.

This commit is contained in:
Mike Cao 2025-08-27 16:59:44 -07:00
parent f9442001e4
commit 8d5e8b072d
4 changed files with 23 additions and 12 deletions

View file

@ -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}