mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 06:37:18 +01:00
Fixed editing and navigation issues.
This commit is contained in:
parent
bf6c9395c6
commit
8c26e310f7
52 changed files with 118 additions and 122 deletions
|
|
@ -42,16 +42,18 @@ export function Pager({ page, pageSize, count, onPageChange }: PagerProps) {
|
|||
total: maxPage.toLocaleString(),
|
||||
})}
|
||||
</Text>
|
||||
<Button onPress={() => handlePageChange(-1)} isDisabled={firstPage}>
|
||||
<Icon size="sm" rotate={180}>
|
||||
<Chevron />
|
||||
</Icon>
|
||||
</Button>
|
||||
<Button onPress={() => handlePageChange(1)} isDisabled={lastPage}>
|
||||
<Icon size="sm">
|
||||
<Chevron />
|
||||
</Icon>
|
||||
</Button>
|
||||
<Row gap="1">
|
||||
<Button variant="outline" onPress={() => handlePageChange(-1)} isDisabled={firstPage}>
|
||||
<Icon size="sm" rotate={180}>
|
||||
<Chevron />
|
||||
</Icon>
|
||||
</Button>
|
||||
<Button variant="outline" onPress={() => handlePageChange(1)} isDisabled={lastPage}>
|
||||
<Icon size="sm">
|
||||
<Chevron />
|
||||
</Icon>
|
||||
</Button>
|
||||
</Row>
|
||||
</Row>
|
||||
</Row>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ export function useTeamsQuery(params?: Record<string, any>, options?: ReactQuery
|
|||
queryKey: ['teams:admin', { modified, ...params }],
|
||||
queryFn: pageParams => {
|
||||
return get(`/admin/teams`, {
|
||||
...params,
|
||||
...pageParams,
|
||||
...params,
|
||||
});
|
||||
},
|
||||
...options,
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ export function useUserWebsitesQuery(
|
|||
queryKey: ['websites', { userId, teamId, modified, ...params }],
|
||||
queryFn: pageParams => {
|
||||
return get(teamId ? `/teams/${teamId}/websites` : `/users/${userId || user.id}/websites`, {
|
||||
...params,
|
||||
...pageParams,
|
||||
...params,
|
||||
});
|
||||
},
|
||||
...options,
|
||||
|
|
|
|||
|
|
@ -1,28 +1,24 @@
|
|||
import { useState } from 'react';
|
||||
import { Select, SelectProps, ListItem } from '@umami/react-zen';
|
||||
import { useUserWebsitesQuery, useMessages } from '@/components/hooks';
|
||||
import { useUserWebsitesQuery, useWebsiteQuery, useNavigation } from '@/components/hooks';
|
||||
|
||||
export function WebsiteSelect({
|
||||
websiteId,
|
||||
teamId,
|
||||
variant,
|
||||
onSelect,
|
||||
...props
|
||||
}: {
|
||||
websiteId?: string;
|
||||
teamId?: string;
|
||||
variant?: 'primary' | 'outline' | 'quiet' | 'danger' | 'zero';
|
||||
onSelect?: (key: any) => void;
|
||||
} & SelectProps) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { router, renderUrl } = useNavigation();
|
||||
const [search, setSearch] = useState('');
|
||||
const [selectedId, setSelectedId] = useState(websiteId);
|
||||
|
||||
const { data: website } = useWebsiteQuery(websiteId);
|
||||
const { data, isLoading } = useUserWebsitesQuery({ teamId }, { search, pageSize: 5 });
|
||||
|
||||
const handleSelect = (value: any) => {
|
||||
setSelectedId(value);
|
||||
onSelect?.(value);
|
||||
router.push(renderUrl(`/websites/${value}`));
|
||||
};
|
||||
|
||||
const handleSearch = (value: string) => {
|
||||
|
|
@ -33,14 +29,14 @@ export function WebsiteSelect({
|
|||
<Select
|
||||
{...props}
|
||||
items={data?.['data'] || []}
|
||||
value={selectedId}
|
||||
placeholder={formatMessage(labels.selectWebsite)}
|
||||
value={websiteId}
|
||||
isLoading={isLoading}
|
||||
buttonProps={{ variant }}
|
||||
allowSearch={true}
|
||||
searchValue={search}
|
||||
onSearch={handleSearch}
|
||||
onChange={handleSelect}
|
||||
renderValue={() => website?.name}
|
||||
>
|
||||
{({ id, name }: any) => <ListItem key={id}>{name}</ListItem>}
|
||||
</Select>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue