Allow getting team websites.

This commit is contained in:
Mike Cao 2025-09-12 08:21:29 -07:00
parent e610de383a
commit 433ce98719
10 changed files with 79 additions and 56 deletions

View file

@ -3,28 +3,28 @@ import { Select, SelectProps, ListItem, Text } from '@umami/react-zen';
import {
useUserWebsitesQuery,
useWebsiteQuery,
useNavigation,
useMessages,
useLoginQuery,
} from '@/components/hooks';
import { Empty } from '@/components/common/Empty';
export function WebsiteSelect({
websiteId,
teamId,
onChange,
...props
}: {
websiteId?: string;
teamId?: string;
} & SelectProps) {
const { formatMessage, messages } = useMessages();
const { router, renderUrl } = useNavigation();
const [search, setSearch] = useState('');
const { data: website } = useWebsiteQuery(websiteId);
const { data, isLoading } = useUserWebsitesQuery({ teamId }, { search, pageSize: 5 });
const handleSelect = (value: any) => {
router.push(renderUrl(`/websites/${value}`));
};
const { user } = useLoginQuery();
const { data, isLoading } = useUserWebsitesQuery(
{ userId: user?.id, teamId },
{ search, pageSize: 5 },
);
const handleSearch = (value: string) => {
setSearch(value);
@ -45,7 +45,7 @@ export function WebsiteSelect({
allowSearch={true}
searchValue={search}
onSearch={handleSearch}
onChange={handleSelect}
onChange={onChange}
onOpenChange={handleOpenChange}
listProps={{
renderEmptyState: () => <Empty message={formatMessage(messages.noResultsFound)} />,