Add includeTeams param for fetching websites.
Some checks are pending
Node.js CI / build (postgresql, 18.18) (push) Waiting to run

This commit is contained in:
Mike Cao 2025-09-12 10:15:13 -07:00
parent 433ce98719
commit 9ccafc390a
6 changed files with 34 additions and 36 deletions

View file

@ -1,29 +1,25 @@
import { useState } from 'react';
import { Select, SelectProps, ListItem, Text } from '@umami/react-zen';
import {
useUserWebsitesQuery,
useWebsiteQuery,
useMessages,
useLoginQuery,
} from '@/components/hooks';
import { Select, SelectProps, ListItem } from '@umami/react-zen';
import { useUserWebsitesQuery, useMessages, useLoginQuery } from '@/components/hooks';
import { Empty } from '@/components/common/Empty';
export function WebsiteSelect({
websiteId,
teamId,
onChange,
includeTeams,
...props
}: {
websiteId?: string;
teamId?: string;
includeTeams?: boolean;
} & SelectProps) {
const { formatMessage, messages } = useMessages();
const [search, setSearch] = useState('');
const { data: website } = useWebsiteQuery(websiteId);
const { user } = useLoginQuery();
const { data, isLoading } = useUserWebsitesQuery(
{ userId: user?.id, teamId },
{ search, pageSize: 5 },
{ search, pageSize: 5, includeTeams },
);
const handleSearch = (value: string) => {
@ -37,11 +33,9 @@ export function WebsiteSelect({
return (
<Select
{...props}
placeholder=""
items={data?.['data'] || []}
value={websiteId}
isLoading={isLoading}
buttonProps={{ variant: 'outline' }}
allowSearch={true}
searchValue={search}
onSearch={handleSearch}
@ -50,11 +44,6 @@ export function WebsiteSelect({
listProps={{
renderEmptyState: () => <Empty message={formatMessage(messages.noResultsFound)} />,
}}
renderValue={() => (
<Text truncate weight="bold" style={{ maxWidth: 160, lineHeight: 1 }}>
{website?.name}
</Text>
)}
>
{({ id, name }: any) => <ListItem key={id}>{name}</ListItem>}
</Select>