mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
Compare commits
2 commits
d382ad2975
...
1852acc333
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1852acc333 | ||
|
|
cb63e49a9b |
4 changed files with 16 additions and 9 deletions
|
|
@ -56,7 +56,7 @@ export function FunnelEditForm({
|
||||||
const defaultValues = {
|
const defaultValues = {
|
||||||
name: data?.name || '',
|
name: data?.name || '',
|
||||||
window: data?.parameters?.window || 60,
|
window: data?.parameters?.window || 60,
|
||||||
steps: data?.parameters?.steps || [{ type: 'path', value: '/' }],
|
steps: data?.parameters?.steps || [{ type: 'path', value: '' }],
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -82,12 +82,10 @@ export function FunnelEditForm({
|
||||||
validate: value => value.length > 1 || 'At least two steps are required',
|
validate: value => value.length > 1 || 'At least two steps are required',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{({ fields, append, remove, getValues }) => {
|
{({ fields, append, remove }) => {
|
||||||
return (
|
return (
|
||||||
<Grid gap>
|
<Grid gap>
|
||||||
{fields.map(({ id }: { id: string }, index: number) => {
|
{fields.map(({ id }: { id: string }, index: number) => {
|
||||||
const type = getValues(`steps.${index}.type`);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid key={id} columns="260px 1fr auto" gap>
|
<Grid key={id} columns="260px 1fr auto" gap>
|
||||||
<Column>
|
<Column>
|
||||||
|
|
@ -103,7 +101,8 @@ export function FunnelEditForm({
|
||||||
name={`steps.${index}.value`}
|
name={`steps.${index}.value`}
|
||||||
rules={{ required: formatMessage(labels.required) }}
|
rules={{ required: formatMessage(labels.required) }}
|
||||||
>
|
>
|
||||||
{({ field }) => {
|
{({ field, context }) => {
|
||||||
|
const type = context.watch(`steps.${index}.type`);
|
||||||
return <LookupField websiteId={websiteId} type={type} {...field} />;
|
return <LookupField websiteId={websiteId} type={type} {...field} />;
|
||||||
}}
|
}}
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
@ -118,7 +117,7 @@ export function FunnelEditForm({
|
||||||
})}
|
})}
|
||||||
<Row>
|
<Row>
|
||||||
<Button
|
<Button
|
||||||
onPress={() => append({ type: 'path', value: '/' })}
|
onPress={() => append({ type: 'path', value: '' })}
|
||||||
isDisabled={fields.length >= FUNNEL_STEPS_MAX}
|
isDisabled={fields.length >= FUNNEL_STEPS_MAX}
|
||||||
>
|
>
|
||||||
<Icon>
|
<Icon>
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,8 @@ export function GoalAddButton({ websiteId }: { websiteId: string }) {
|
||||||
<Modal>
|
<Modal>
|
||||||
<Dialog
|
<Dialog
|
||||||
aria-label="add goal"
|
aria-label="add goal"
|
||||||
variant="modal"
|
|
||||||
title={formatMessage(labels.goal)}
|
title={formatMessage(labels.goal)}
|
||||||
style={{ minWidth: 800, minHeight: 300 }}
|
style={{ minWidth: 400, minHeight: 300 }}
|
||||||
>
|
>
|
||||||
{({ close }) => <GoalEditForm websiteId={websiteId} onClose={close} />}
|
{({ close }) => <GoalEditForm websiteId={websiteId} onClose={close} />}
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,18 @@
|
||||||
import { Text } from '@umami/react-zen';
|
import { Text } from '@umami/react-zen';
|
||||||
import { formatDistanceToNow } from 'date-fns';
|
import { formatDistanceToNow } from 'date-fns';
|
||||||
import { useLocale, useTimezone } from '@/components/hooks';
|
import { useLocale, useTimezone } from '@/components/hooks';
|
||||||
|
import { isInvalidDate } from '@/lib/date';
|
||||||
|
|
||||||
export function DateDistance({ date }: { date: Date }) {
|
export function DateDistance({ date }: { date: Date }) {
|
||||||
const { formatTimezoneDate } = useTimezone();
|
const { formatTimezoneDate } = useTimezone();
|
||||||
const { dateLocale } = useLocale();
|
const { dateLocale } = useLocale();
|
||||||
|
|
||||||
|
if (!isInvalidDate(date)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text title={formatTimezoneDate(date.toISOString(), 'PPPpp')}>
|
<Text title={formatTimezoneDate(date?.toISOString(), 'PPPpp')}>
|
||||||
{formatDistanceToNow(date, { addSuffix: true, locale: dateLocale })}
|
{formatDistanceToNow(date, { addSuffix: true, locale: dateLocale })}
|
||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -369,3 +369,7 @@ export function getDateRangeValue(startDate: Date, endDate: Date) {
|
||||||
export function getMonthDateRangeValue(date: Date) {
|
export function getMonthDateRangeValue(date: Date) {
|
||||||
return getDateRangeValue(startOfMonth(date), endOfMonth(date));
|
return getDateRangeValue(startOfMonth(date), endOfMonth(date));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isInvalidDate(date: any) {
|
||||||
|
return date instanceof Date && isNaN(date.getTime());
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue