Fixed filter parameters.

This commit is contained in:
Mike Cao 2023-10-16 20:44:22 -07:00
parent b1d3970ea7
commit 81a810bd73
9 changed files with 36 additions and 44 deletions

View File

@ -97,7 +97,7 @@
"node-fetch": "^3.2.8",
"npm-run-all": "^4.1.5",
"react": "^18.2.0",
"react-basics": "^0.102.0",
"react-basics": "^0.105.0",
"react-beautiful-dnd": "^13.1.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.4",

View File

@ -7,7 +7,7 @@ import FieldAggregateForm from './FieldAggregateForm';
import FieldFilterForm from './FieldFilterForm';
import styles from './FieldAddForm.module.css';
export function FieldAddForm({ fields = [], group, element, onAdd, onClose }) {
export function FieldAddForm({ fields = [], group, onAdd, onClose }) {
const [selected, setSelected] = useState();
const handleSelect = value => {
@ -28,7 +28,7 @@ export function FieldAddForm({ fields = [], group, element, onAdd, onClose }) {
};
return createPortal(
<PopupForm className={styles.popup} element={element} onClose={onClose}>
<PopupForm className={styles.popup}>
{!selected && <FieldSelectForm fields={fields} onSelect={handleSelect} />}
{selected && group === REPORT_PARAMETERS.fields && (
<FieldAggregateForm {...selected} onSelect={handleSave} />

View File

@ -1,20 +1,20 @@
import { useState } from 'react';
import { Loading } from 'react-basics';
import { subDays } from 'date-fns';
import FieldSelectForm from './FieldSelectForm';
import FieldFilterForm from './FieldFilterForm';
import { useApi, useDateRange } from 'components/hooks';
import { Loading } from 'react-basics';
import { useApi } from 'components/hooks';
function useValues(websiteId, type) {
const now = Date.now();
const { get, useQuery } = useApi();
const [dateRange] = useDateRange(websiteId);
const { startDate, endDate } = dateRange;
const { data, error, isLoading } = useQuery(
['websites:values', websiteId, type],
() =>
get(`/websites/${websiteId}/values`, {
type,
startAt: +startDate,
endAt: +endDate,
startAt: +subDays(now, 90),
endAt: now,
}),
{ enabled: !!(websiteId && type) },
);

View File

@ -74,7 +74,7 @@ export function EventDataParameters() {
<Icons.Plus />
</Icon>
<Popup position="bottom" alignment="start">
{(close, element) => {
{close => {
return (
<FieldAddForm
fields={data.map(({ eventKey, eventDataType }) => ({
@ -82,7 +82,6 @@ export function EventDataParameters() {
type: DATA_TYPES[eventDataType],
}))}
group={group}
element={element}
onAdd={handleAdd}
onClose={close}
/>

View File

@ -52,14 +52,10 @@ export function FunnelParameters() {
<Icon>
<Icons.Plus />
</Icon>
<Popup position="bottom" alignment="start">
{(close, element) => {
return (
<PopupForm element={element} onClose={close}>
<UrlAddForm onAdd={handleAddUrl} />
</PopupForm>
);
}}
<Popup position="right" alignment="start">
<PopupForm>
<UrlAddForm onAdd={handleAddUrl} />
</PopupForm>
</Popup>
</PopupTrigger>
);

View File

@ -81,26 +81,22 @@ export function InsightsParameters() {
</Icon>
</TooltipPopup>
<Popup position="bottom" alignment="start" className={styles.popup}>
{close => {
return (
<PopupForm onClose={close}>
{id === 'fields' && (
<FieldSelectForm
items={fieldOptions}
onSelect={handleAdd.bind(null, id)}
showType={false}
/>
)}
{id === 'filters' && (
<FilterSelectForm
websiteId={websiteId}
items={fieldOptions}
onSelect={handleAdd.bind(null, id)}
/>
)}
</PopupForm>
);
}}
<PopupForm>
{id === 'fields' && (
<FieldSelectForm
items={fieldOptions}
onSelect={handleAdd.bind(null, id)}
showType={false}
/>
)}
{id === 'filters' && (
<FilterSelectForm
websiteId={websiteId}
items={fieldOptions}
onSelect={handleAdd.bind(null, id)}
/>
)}
</PopupForm>
</Popup>
</PopupTrigger>
);

View File

@ -5,7 +5,6 @@
position: relative;
width: 100%;
max-width: 1320px;
min-height: calc(100vh - 60px);
margin: 0 auto;
padding: 0 20px;
}

View File

@ -22,6 +22,7 @@ async function relationalQuery(websiteId: string, column: string, startDate: Dat
on session.session_id = website_event.session_id
where website_event.website_id = {{websiteId::uuid}}
and website_event.created_at between {{startDate}} and {{endDate}}
limit 100
`,
{
websiteId,
@ -40,6 +41,7 @@ async function clickhouseQuery(websiteId: string, column: string, startDate: Dat
from website_event
where website_id = {websiteId:UUID}
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
limit 100
`,
{
websiteId,

View File

@ -7557,10 +7557,10 @@ rc@^1.2.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"
react-basics@^0.102.0:
version "0.102.0"
resolved "https://registry.yarnpkg.com/react-basics/-/react-basics-0.102.0.tgz#61dbc837963facb2d409044046eb55f7c689411e"
integrity sha512-MhLHgjVnOwdm1YX1Lwkyg37kPCTOk+b3NXWGORlh4dJThq/qq/s0lF09yqEq09Gye5yyTDbeNDPXlkXIPtadog==
react-basics@^0.105.0:
version "0.105.0"
resolved "https://registry.yarnpkg.com/react-basics/-/react-basics-0.105.0.tgz#94eda703b3c0728e817b6e9d086e5d1c6c68f25c"
integrity sha512-iKYtfB0A2vsmO+X4jaX64XdmHE836w8TG2jFQ0pi5Qp0ktL0lAL9/q0IrWUjNr86hi0apg46aeJWxY+qQO+T1g==
dependencies:
"@react-spring/web" "^9.7.3"
classnames "^2.3.1"