Updated cohort processing.
This commit is contained in:
@@ -90,7 +90,9 @@ export function CohortEditForm({
|
||||
<Form
|
||||
error={error}
|
||||
onSubmit={handleSubmit}
|
||||
defaultValues={data || { parameters: { filters, dateRange: '30day' } }}
|
||||
defaultValues={
|
||||
data || { parameters: { filters, dateRange: '30day', action: { type: 'path' } } }
|
||||
}
|
||||
>
|
||||
<FormField
|
||||
name="name"
|
||||
@@ -104,14 +106,19 @@ export function CohortEditForm({
|
||||
<Label>{formatMessage(labels.action)}</Label>
|
||||
<Grid columns="260px 1fr" gap>
|
||||
<Column>
|
||||
<Select value={action} onChange={setAction}>
|
||||
<ListItem id="path">{formatMessage(labels.viewedPage)}</ListItem>
|
||||
<ListItem id="event">{formatMessage(labels.triggeredEvent)}</ListItem>
|
||||
</Select>
|
||||
<FormField
|
||||
name="parameters.action.type"
|
||||
rules={{ required: formatMessage(labels.required) }}
|
||||
>
|
||||
<Select onSelectionChange={(value: any) => setAction(value)}>
|
||||
<ListItem id="path">{formatMessage(labels.viewedPage)}</ListItem>
|
||||
<ListItem id="event">{formatMessage(labels.triggeredEvent)}</ListItem>
|
||||
</Select>
|
||||
</FormField>
|
||||
</Column>
|
||||
<Column>
|
||||
<FormField
|
||||
name="parameters.action"
|
||||
name="parameters.action.value"
|
||||
rules={{ required: formatMessage(labels.required) }}
|
||||
>
|
||||
{({ field }) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { canViewWebsite } from '@/validations';
|
||||
import { EVENT_COLUMNS, FILTER_COLUMNS, FILTER_GROUPS, SESSION_COLUMNS } from '@/lib/constants';
|
||||
import { EVENT_COLUMNS, FILTER_COLUMNS, SEGMENT_TYPES, SESSION_COLUMNS } from '@/lib/constants';
|
||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||
import { badRequest, json, unauthorized } from '@/lib/response';
|
||||
import { getWebsiteSegments, getValues } from '@/queries';
|
||||
@@ -30,14 +30,16 @@ export async function GET(
|
||||
|
||||
const { type } = query;
|
||||
|
||||
if (!SESSION_COLUMNS.includes(type) && !EVENT_COLUMNS.includes(type) && !FILTER_GROUPS[type]) {
|
||||
if (!SESSION_COLUMNS.includes(type) && !EVENT_COLUMNS.includes(type) && !SEGMENT_TYPES[type]) {
|
||||
return badRequest();
|
||||
}
|
||||
|
||||
let values;
|
||||
let values: any[];
|
||||
|
||||
if (FILTER_GROUPS[type]) {
|
||||
values = (await getWebsiteSegments(websiteId, type)).map(segment => ({ value: segment.name }));
|
||||
if (SEGMENT_TYPES[type]) {
|
||||
values = (await getWebsiteSegments(websiteId, type))?.data?.map(segment => ({
|
||||
value: segment.name,
|
||||
}));
|
||||
} else {
|
||||
const filters = await getQueryFilters(query, websiteId);
|
||||
values = await getValues(websiteId, FILTER_COLUMNS[type], filters);
|
||||
|
||||
Reference in New Issue
Block a user