Add Property filters for booleans, dates, arrays
This commit is contained in:
1 parent
877945e721
commit
9da332c489
21 files changed
+499
-163
No files matched your search
@@ -7,6 +7,7 @@ export function useEventDataValuesQuery(
|
||||
websiteId: string,
|
||||
event: string,
|
||||
propertyName: string,
|
||||
dataType?: number,
|
||||
options?: ReactQueryOptions,
|
||||
) {
|
||||
const { get, useQuery } = useApi();
|
||||
@@ -16,7 +17,7 @@ export function useEventDataValuesQuery(
|
||||
return useQuery<any>({
|
||||
queryKey: [
|
||||
'websites:event-data:values',
|
||||
{ websiteId, startAt, endAt, unit, timezone, ...filters, event, propertyName },
|
||||
{ websiteId, startAt, endAt, unit, timezone, ...filters, event, propertyName, dataType },
|
||||
],
|
||||
queryFn: () =>
|
||||
get(`/websites/${websiteId}/event-data/values`, {
|
||||
@@ -27,6 +28,7 @@ export function useEventDataValuesQuery(
|
||||
...filters,
|
||||
event,
|
||||
propertyName,
|
||||
dataType,
|
||||
}),
|
||||
enabled: !!(websiteId && propertyName),
|
||||
...options,
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Dialog, ListItem, ListSeparator, Modal, Select, type SelectProps } from '@umami/react-zen';
|
||||
import { endOfYear } from 'date-fns';
|
||||
import { Fragment, type Key, useState } from 'react';
|
||||
import { DateDisplay } from '@/components/common/DateDisplay';
|
||||
import { useMessages, useMobile } from '@/components/hooks';
|
||||
import { DatePickerForm } from '@/components/metrics/DatePickerForm';
|
||||
import { parseDateRange } from '@/lib/date';
|
||||
import { getMaxSelectableDate, parseDateRange } from '@/lib/date';
|
||||
|
||||
export interface DateFilterProps extends SelectProps {
|
||||
value?: string;
|
||||
@@ -129,7 +128,7 @@ export function DateFilter({
|
||||
startDate={startDate}
|
||||
endDate={endDate}
|
||||
minDate={new Date(2000, 0, 1)}
|
||||
maxDate={endOfYear(new Date())}
|
||||
maxDate={getMaxSelectableDate()}
|
||||
onChange={handlePickerChange}
|
||||
onClose={() => setShowPicker(false)}
|
||||
/>
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
useFilters,
|
||||
useFormat,
|
||||
useMessages,
|
||||
useMobile,
|
||||
useNavigation,
|
||||
useWebsiteSegmentQuery,
|
||||
} from '@/components/hooks';
|
||||
@@ -22,6 +23,7 @@ import { isSearchOperator } from '@/lib/params';
|
||||
|
||||
export function FilterBar({ websiteId }: { websiteId?: string }) {
|
||||
const { t, labels } = useMessages();
|
||||
const { isMobile } = useMobile();
|
||||
const { formatValue } = useFormat();
|
||||
const {
|
||||
router,
|
||||
@@ -114,8 +116,19 @@ export function FilterBar({ websiteId }: { websiteId?: string }) {
|
||||
</Tooltip>
|
||||
</TooltipTrigger>
|
||||
)}
|
||||
<Modal>
|
||||
<Dialog title={t(labels.segment)} style={{ width: 800, minHeight: 300 }}>
|
||||
<Modal placement={isMobile ? 'fullscreen' : 'center'}>
|
||||
<Dialog
|
||||
variant={isMobile ? 'sheet' : undefined}
|
||||
title={t(labels.segment)}
|
||||
style={{
|
||||
width: isMobile ? '100%' : '800px',
|
||||
height: isMobile ? '100%' : undefined,
|
||||
minHeight: 300,
|
||||
maxHeight: isMobile ? '100%' : 'calc(100dvh - 40px)',
|
||||
overflowY: 'auto',
|
||||
padding: '32px',
|
||||
}}
|
||||
>
|
||||
{({ close }) => {
|
||||
return <SegmentEditForm websiteId={websiteId} onClose={close} filters={filters} />;
|
||||
}}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Button, Dialog, DialogTrigger, Icon, Modal, Text } from '@umami/react-zen';
|
||||
import { SegmentEditForm } from '@/app/(main)/websites/[websiteId]/segments/SegmentEditForm';
|
||||
import { useMessages } from '@/components/hooks';
|
||||
import { useMessages, useMobile } from '@/components/hooks';
|
||||
import { Plus } from '@/components/icons';
|
||||
|
||||
export function SegmentSaveButton({ websiteId }: { websiteId: string }) {
|
||||
const { t, labels } = useMessages();
|
||||
const { isMobile } = useMobile();
|
||||
|
||||
return (
|
||||
<DialogTrigger>
|
||||
@@ -14,8 +15,18 @@ export function SegmentSaveButton({ websiteId }: { websiteId: string }) {
|
||||
</Icon>
|
||||
<Text>{t(labels.segment)}</Text>
|
||||
</Button>
|
||||
<Modal>
|
||||
<Dialog title={t(labels.segment)} style={{ width: 800 }}>
|
||||
<Modal placement={isMobile ? 'fullscreen' : 'center'}>
|
||||
<Dialog
|
||||
variant={isMobile ? 'sheet' : undefined}
|
||||
title={t(labels.segment)}
|
||||
style={{
|
||||
width: isMobile ? '100%' : '800px',
|
||||
height: isMobile ? '100%' : undefined,
|
||||
maxHeight: isMobile ? '100%' : 'calc(100dvh - 40px)',
|
||||
overflowY: 'auto',
|
||||
padding: '32px',
|
||||
}}
|
||||
>
|
||||
{({ close }) => {
|
||||
return <SegmentEditForm websiteId={websiteId} onClose={close} />;
|
||||
}}
|
||||
|
||||
Reference in new issue
Block a user