mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Pixel/links development. New validations folder. More refactoring.
This commit is contained in:
parent
88639dfe83
commit
247e14646b
136 changed files with 1395 additions and 516 deletions
|
|
@ -20,23 +20,25 @@ export function AdminTeamsTable({
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DataTable data={data}>
|
<DataTable data={data}>
|
||||||
<DataColumn id="name" label={formatMessage(labels.name)} width="2fr">
|
<DataColumn id="name" label={formatMessage(labels.name)} width="1fr">
|
||||||
{(row: any) => <Link href={`/admin/teams/${row.id}`}>{row.name}</Link>}
|
{(row: any) => <Link href={`/admin/teams/${row.id}`}>{row.name}</Link>}
|
||||||
</DataColumn>
|
</DataColumn>
|
||||||
<DataColumn id="websites" label={formatMessage(labels.members)}>
|
<DataColumn id="websites" label={formatMessage(labels.members)} width="140px">
|
||||||
{(row: any) => row?._count?.teamUser}
|
{(row: any) => row?._count?.members}
|
||||||
</DataColumn>
|
</DataColumn>
|
||||||
<DataColumn id="members" label={formatMessage(labels.websites)}>
|
<DataColumn id="members" label={formatMessage(labels.websites)} width="140px">
|
||||||
{(row: any) => row?._count?.website}
|
{(row: any) => row?._count?.websites}
|
||||||
</DataColumn>
|
</DataColumn>
|
||||||
<DataColumn id="owner" label={formatMessage(labels.owner)} width="200px">
|
<DataColumn id="owner" label={formatMessage(labels.owner)}>
|
||||||
{(row: any) => (
|
{(row: any) => {
|
||||||
<Text title={row?.teamUser?.[0]?.user?.username} truncate>
|
const name = row?.members?.[0]?.user?.username;
|
||||||
<Link href={`/admin/users/${row?.teamUser?.[0]?.user?.id}`}>
|
|
||||||
{row?.teamUser?.[0]?.user?.username}
|
return (
|
||||||
</Link>
|
<Text title={name} truncate>
|
||||||
</Text>
|
<Link href={`/admin/users/${row?.members?.[0]?.user?.id}`}>{name}</Link>
|
||||||
)}
|
</Text>
|
||||||
|
);
|
||||||
|
}}
|
||||||
</DataColumn>
|
</DataColumn>
|
||||||
<DataColumn id="created" label={formatMessage(labels.created)} width="160px">
|
<DataColumn id="created" label={formatMessage(labels.created)} width="160px">
|
||||||
{(row: any) => <DateDistance date={new Date(row.createdAt)} />}
|
{(row: any) => <DateDistance date={new Date(row.createdAt)} />}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ export function UsersTable({
|
||||||
}
|
}
|
||||||
</DataColumn>
|
</DataColumn>
|
||||||
<DataColumn id="websites" label={formatMessage(labels.websites)}>
|
<DataColumn id="websites" label={formatMessage(labels.websites)}>
|
||||||
{(row: any) => row._count.websiteUser}
|
{(row: any) => row._count.websites}
|
||||||
</DataColumn>
|
</DataColumn>
|
||||||
<DataColumn id="created" label={formatMessage(labels.created)}>
|
<DataColumn id="created" label={formatMessage(labels.created)}>
|
||||||
{(row: any) => <DateDistance date={new Date(row.createdAt)} />}
|
{(row: any) => <DateDistance date={new Date(row.createdAt)} />}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ export function LinkDeleteButton({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ActionButton tooltip={formatMessage(labels.delete)} icon={<Trash />}>
|
<ActionButton title={formatMessage(labels.delete)} icon={<Trash />}>
|
||||||
<Dialog title={formatMessage(labels.confirm)} style={{ width: 400 }}>
|
<Dialog title={formatMessage(labels.confirm)} style={{ width: 400 }}>
|
||||||
{({ close }) => (
|
{({ close }) => (
|
||||||
<ConfirmationForm
|
<ConfirmationForm
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ export function LinkEditButton({ linkId }: { linkId: string }) {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ActionButton tooltip={formatMessage(labels.edit)} icon={<Edit />}>
|
<ActionButton title={formatMessage(labels.edit)} icon={<Edit />}>
|
||||||
<Dialog title={formatMessage(labels.link)} style={{ width: 800 }}>
|
<Dialog title={formatMessage(labels.link)} style={{ width: 800 }}>
|
||||||
{({ close }) => {
|
{({ close }) => {
|
||||||
return <LinkEditForm linkId={linkId} onClose={close} />;
|
return <LinkEditForm linkId={linkId} onClose={close} />;
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
import { DataTable, DataColumn, Row } from '@umami/react-zen';
|
import { DataTable, DataColumn, Row } from '@umami/react-zen';
|
||||||
import { useMessages, useNavigation } from '@/components/hooks';
|
import { useConfig, useMessages, useNavigation } from '@/components/hooks';
|
||||||
import { Empty } from '@/components/common/Empty';
|
import { Empty } from '@/components/common/Empty';
|
||||||
import { DateDistance } from '@/components/common/DateDistance';
|
import { DateDistance } from '@/components/common/DateDistance';
|
||||||
|
import { ExternalLink } from '@/components/common/ExternalLink';
|
||||||
import { LinkEditButton } from './LinkEditButton';
|
import { LinkEditButton } from './LinkEditButton';
|
||||||
import { LinkDeleteButton } from './LinkDeleteButton';
|
import { LinkDeleteButton } from './LinkDeleteButton';
|
||||||
|
|
||||||
export function LinksTable({ data = [] }) {
|
export function LinksTable({ data = [] }) {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const { websiteId } = useNavigation();
|
const { websiteId } = useNavigation();
|
||||||
|
const { linksUrl } = useConfig();
|
||||||
|
const hostUrl = linksUrl || `${window.location.origin}/x`;
|
||||||
|
|
||||||
if (data.length === 0) {
|
if (data.length === 0) {
|
||||||
return <Empty />;
|
return <Empty />;
|
||||||
|
|
@ -16,14 +19,22 @@ export function LinksTable({ data = [] }) {
|
||||||
return (
|
return (
|
||||||
<DataTable data={data}>
|
<DataTable data={data}>
|
||||||
<DataColumn id="name" label={formatMessage(labels.name)} />
|
<DataColumn id="name" label={formatMessage(labels.name)} />
|
||||||
<DataColumn id="url" label={formatMessage(labels.destinationUrl)} />
|
<DataColumn id="slug" label={formatMessage(labels.link)}>
|
||||||
<DataColumn id="created" label={formatMessage(labels.created)}>
|
{({ slug }: any) => {
|
||||||
|
const url = `${hostUrl}/${slug}`;
|
||||||
|
return <ExternalLink href={url}>{url}</ExternalLink>;
|
||||||
|
}}
|
||||||
|
</DataColumn>
|
||||||
|
<DataColumn id="url" label={formatMessage(labels.destinationUrl)}>
|
||||||
|
{({ url }: any) => {
|
||||||
|
return <ExternalLink href={url}>{url}</ExternalLink>;
|
||||||
|
}}
|
||||||
|
</DataColumn>
|
||||||
|
<DataColumn id="created" label={formatMessage(labels.created)} width="200px">
|
||||||
{(row: any) => <DateDistance date={new Date(row.createdAt)} />}
|
{(row: any) => <DateDistance date={new Date(row.createdAt)} />}
|
||||||
</DataColumn>
|
</DataColumn>
|
||||||
<DataColumn id="action" align="end" width="100px">
|
<DataColumn id="action" align="end" width="100px">
|
||||||
{(row: any) => {
|
{({ id, name }: any) => {
|
||||||
const { id, name } = row;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row>
|
<Row>
|
||||||
<LinkEditButton linkId={id} />
|
<LinkEditButton linkId={id} />
|
||||||
|
|
|
||||||
0
src/app/(main)/links/[linkId]/route.ts
Normal file
0
src/app/(main)/links/[linkId]/route.ts
Normal file
|
|
@ -1,17 +1,16 @@
|
||||||
import { useMessages, useModified, useNavigation } from '@/components/hooks';
|
import { useMessages, useModified } from '@/components/hooks';
|
||||||
import { Button, Icon, Modal, Dialog, DialogTrigger, Text, useToast } from '@umami/react-zen';
|
import { Button, Icon, Modal, Dialog, DialogTrigger, Text, useToast } from '@umami/react-zen';
|
||||||
import { Plus } from '@/components/icons';
|
import { Plus } from '@/components/icons';
|
||||||
import { PixelAddForm } from './PixelAddForm';
|
import { PixelEditForm } from './PixelEditForm';
|
||||||
|
|
||||||
export function PixelAddButton() {
|
export function PixelAddButton({ teamId }: { teamId?: string }) {
|
||||||
const { formatMessage, labels, messages } = useMessages();
|
const { formatMessage, labels, messages } = useMessages();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const { touch } = useModified();
|
const { touch } = useModified();
|
||||||
const { teamId } = useNavigation();
|
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
toast(formatMessage(messages.saved));
|
toast(formatMessage(messages.saved));
|
||||||
touch('boards');
|
touch('pixels');
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -23,8 +22,8 @@ export function PixelAddButton() {
|
||||||
<Text>{formatMessage(labels.addPixel)}</Text>
|
<Text>{formatMessage(labels.addPixel)}</Text>
|
||||||
</Button>
|
</Button>
|
||||||
<Modal>
|
<Modal>
|
||||||
<Dialog title={formatMessage(labels.addPixel)} style={{ width: 400 }}>
|
<Dialog title={formatMessage(labels.addPixel)} style={{ width: 600 }}>
|
||||||
{({ close }) => <PixelAddForm teamId={teamId} onSave={handleSave} onClose={close} />}
|
{({ close }) => <PixelEditForm teamId={teamId} onSave={handleSave} onClose={close} />}
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</Modal>
|
</Modal>
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
|
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
import { Form, FormField, FormSubmitButton, Row, TextField, Button } from '@umami/react-zen';
|
|
||||||
import { useApi } from '@/components/hooks';
|
|
||||||
import { DOMAIN_REGEX } from '@/lib/constants';
|
|
||||||
import { useMessages } from '@/components/hooks';
|
|
||||||
|
|
||||||
export function PixelAddForm({
|
|
||||||
teamId,
|
|
||||||
onSave,
|
|
||||||
onClose,
|
|
||||||
}: {
|
|
||||||
teamId?: string;
|
|
||||||
onSave?: () => void;
|
|
||||||
onClose?: () => void;
|
|
||||||
}) {
|
|
||||||
const { formatMessage, labels, messages } = useMessages();
|
|
||||||
const { post, useMutation } = useApi();
|
|
||||||
const { mutate, error, isPending } = useMutation({
|
|
||||||
mutationFn: (data: any) => post('/pixels', { ...data, teamId }),
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleSubmit = async (data: any) => {
|
|
||||||
mutate(data, {
|
|
||||||
onSuccess: async () => {
|
|
||||||
onSave?.();
|
|
||||||
onClose?.();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Form onSubmit={handleSubmit} error={error?.message}>
|
|
||||||
<FormField
|
|
||||||
label={formatMessage(labels.name)}
|
|
||||||
name="name"
|
|
||||||
rules={{ required: formatMessage(labels.required) }}
|
|
||||||
>
|
|
||||||
<TextField autoComplete="off" />
|
|
||||||
</FormField>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
label={formatMessage(labels.domain)}
|
|
||||||
name="domain"
|
|
||||||
rules={{
|
|
||||||
required: formatMessage(labels.required),
|
|
||||||
pattern: { value: DOMAIN_REGEX, message: formatMessage(messages.invalidDomain) },
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<TextField autoComplete="off" />
|
|
||||||
</FormField>
|
|
||||||
<Row justifyContent="flex-end" paddingTop="3" gap="3">
|
|
||||||
{onClose && (
|
|
||||||
<Button isDisabled={isPending} onPress={onClose}>
|
|
||||||
{formatMessage(labels.cancel)}
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
<FormSubmitButton data-test="button-submit" isDisabled={false}>
|
|
||||||
{formatMessage(labels.save)}
|
|
||||||
</FormSubmitButton>
|
|
||||||
</Row>
|
|
||||||
</Form>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
55
src/app/(main)/pixels/PixelDeleteButton.tsx
Normal file
55
src/app/(main)/pixels/PixelDeleteButton.tsx
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
import { Dialog } from '@umami/react-zen';
|
||||||
|
import { ActionButton } from '@/components/input/ActionButton';
|
||||||
|
import { Trash } from '@/components/icons';
|
||||||
|
import { ConfirmationForm } from '@/components/common/ConfirmationForm';
|
||||||
|
import { messages } from '@/components/messages';
|
||||||
|
import { useApi, useMessages, useModified } from '@/components/hooks';
|
||||||
|
|
||||||
|
export function PixelDeleteButton({
|
||||||
|
pixelId,
|
||||||
|
websiteId,
|
||||||
|
name,
|
||||||
|
onSave,
|
||||||
|
}: {
|
||||||
|
pixelId: string;
|
||||||
|
websiteId: string;
|
||||||
|
name: string;
|
||||||
|
onSave?: () => void;
|
||||||
|
}) {
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
const { del, useMutation } = useApi();
|
||||||
|
const { mutate, isPending, error } = useMutation({
|
||||||
|
mutationFn: () => del(`/websites/${websiteId}/pixels/${pixelId}`),
|
||||||
|
});
|
||||||
|
const { touch } = useModified();
|
||||||
|
|
||||||
|
const handleConfirm = (close: () => void) => {
|
||||||
|
mutate(null, {
|
||||||
|
onSuccess: () => {
|
||||||
|
touch('pixels');
|
||||||
|
onSave?.();
|
||||||
|
close();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ActionButton title={formatMessage(labels.delete)} icon={<Trash />}>
|
||||||
|
<Dialog title={formatMessage(labels.confirm)} style={{ width: 400 }}>
|
||||||
|
{({ close }) => (
|
||||||
|
<ConfirmationForm
|
||||||
|
message={formatMessage(messages.confirmRemove, {
|
||||||
|
target: name,
|
||||||
|
})}
|
||||||
|
isLoading={isPending}
|
||||||
|
error={error}
|
||||||
|
onConfirm={handleConfirm.bind(null, close)}
|
||||||
|
onClose={close}
|
||||||
|
buttonLabel={formatMessage(labels.delete)}
|
||||||
|
buttonVariant="danger"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Dialog>
|
||||||
|
</ActionButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
19
src/app/(main)/pixels/PixelEditButton.tsx
Normal file
19
src/app/(main)/pixels/PixelEditButton.tsx
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { ActionButton } from '@/components/input/ActionButton';
|
||||||
|
import { Edit } from '@/components/icons';
|
||||||
|
import { Dialog } from '@umami/react-zen';
|
||||||
|
import { PixelEditForm } from './PixelEditForm';
|
||||||
|
import { useMessages } from '@/components/hooks';
|
||||||
|
|
||||||
|
export function PixelEditButton({ pixelId }: { pixelId: string }) {
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ActionButton title={formatMessage(labels.edit)} icon={<Edit />}>
|
||||||
|
<Dialog title={formatMessage(labels.pixel)} style={{ width: 800 }}>
|
||||||
|
{({ close }) => {
|
||||||
|
return <PixelEditForm pixelId={pixelId} onClose={close} />;
|
||||||
|
}}
|
||||||
|
</Dialog>
|
||||||
|
</ActionButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
105
src/app/(main)/pixels/PixelEditForm.tsx
Normal file
105
src/app/(main)/pixels/PixelEditForm.tsx
Normal file
|
|
@ -0,0 +1,105 @@
|
||||||
|
import {
|
||||||
|
Form,
|
||||||
|
FormField,
|
||||||
|
FormSubmitButton,
|
||||||
|
Row,
|
||||||
|
TextField,
|
||||||
|
Button,
|
||||||
|
Text,
|
||||||
|
Label,
|
||||||
|
Column,
|
||||||
|
Icon,
|
||||||
|
Loading,
|
||||||
|
} from '@umami/react-zen';
|
||||||
|
import { useConfig, usePixelQuery } from '@/components/hooks';
|
||||||
|
import { useMessages } from '@/components/hooks';
|
||||||
|
import { Refresh } from '@/components/icons';
|
||||||
|
import { getRandomChars } from '@/lib/crypto';
|
||||||
|
import { useUpdateQuery } from '@/components/hooks/queries/useUpdateQuery';
|
||||||
|
|
||||||
|
const generateId = () => getRandomChars(9);
|
||||||
|
|
||||||
|
export function PixelEditForm({
|
||||||
|
pixelId,
|
||||||
|
teamId,
|
||||||
|
onSave,
|
||||||
|
onClose,
|
||||||
|
}: {
|
||||||
|
pixelId?: string;
|
||||||
|
teamId?: string;
|
||||||
|
onSave?: () => void;
|
||||||
|
onClose?: () => void;
|
||||||
|
}) {
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
const { mutate, error, isPending } = useUpdateQuery('/pixels', { id: pixelId, teamId });
|
||||||
|
const { pixelDomain } = useConfig();
|
||||||
|
const { data, isLoading } = usePixelQuery(pixelId);
|
||||||
|
|
||||||
|
const handleSubmit = async (data: any) => {
|
||||||
|
mutate(data, {
|
||||||
|
onSuccess: async () => {
|
||||||
|
onSave?.();
|
||||||
|
onClose?.();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (pixelId && !isLoading) {
|
||||||
|
return <Loading position="page" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Form
|
||||||
|
onSubmit={handleSubmit}
|
||||||
|
error={error?.message}
|
||||||
|
defaultValues={{ slug: generateId(), ...data }}
|
||||||
|
>
|
||||||
|
{({ setValue }) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<FormField
|
||||||
|
label={formatMessage(labels.name)}
|
||||||
|
name="name"
|
||||||
|
rules={{ required: formatMessage(labels.required) }}
|
||||||
|
>
|
||||||
|
<TextField autoComplete="off" />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<Column>
|
||||||
|
<Label>{formatMessage(labels.pixel)}</Label>
|
||||||
|
<Row alignItems="center" gap>
|
||||||
|
<Text>{pixelDomain || window.location.origin}/</Text>
|
||||||
|
<FormField
|
||||||
|
name="slug"
|
||||||
|
rules={{
|
||||||
|
required: formatMessage(labels.required),
|
||||||
|
}}
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
>
|
||||||
|
<TextField autoComplete="off" isReadOnly />
|
||||||
|
</FormField>
|
||||||
|
<Button
|
||||||
|
variant="quiet"
|
||||||
|
onPress={() => setValue('slug', generateId(), { shouldDirty: true })}
|
||||||
|
>
|
||||||
|
<Icon>
|
||||||
|
<Refresh />
|
||||||
|
</Icon>
|
||||||
|
</Button>
|
||||||
|
</Row>
|
||||||
|
</Column>
|
||||||
|
|
||||||
|
<Row justifyContent="flex-end" paddingTop="3" gap="3">
|
||||||
|
{onClose && (
|
||||||
|
<Button isDisabled={isPending} onPress={onClose}>
|
||||||
|
{formatMessage(labels.cancel)}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<FormSubmitButton isDisabled={false}>{formatMessage(labels.save)}</FormSubmitButton>
|
||||||
|
</Row>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</Form>
|
||||||
|
);
|
||||||
|
}
|
||||||
14
src/app/(main)/pixels/PixelsDataTable.tsx
Normal file
14
src/app/(main)/pixels/PixelsDataTable.tsx
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { usePixelsQuery, useNavigation } from '@/components/hooks';
|
||||||
|
import { PixelsTable } from './PixelsTable';
|
||||||
|
import { DataGrid } from '@/components/common/DataGrid';
|
||||||
|
|
||||||
|
export function PixelsDataTable() {
|
||||||
|
const { teamId } = useNavigation();
|
||||||
|
const query = usePixelsQuery({ teamId });
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DataGrid query={query} allowSearch={true} autoFocus={false} allowPaging={true}>
|
||||||
|
{({ data }) => <PixelsTable data={data} />}
|
||||||
|
</DataGrid>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -3,17 +3,23 @@ import { PageBody } from '@/components/common/PageBody';
|
||||||
import { Column } from '@umami/react-zen';
|
import { Column } from '@umami/react-zen';
|
||||||
import { PageHeader } from '@/components/common/PageHeader';
|
import { PageHeader } from '@/components/common/PageHeader';
|
||||||
import { PixelAddButton } from './PixelAddButton';
|
import { PixelAddButton } from './PixelAddButton';
|
||||||
import { useMessages } from '@/components/hooks';
|
import { useMessages, useNavigation } from '@/components/hooks';
|
||||||
|
import { PixelsDataTable } from './PixelsDataTable';
|
||||||
|
import { Panel } from '@/components/common/Panel';
|
||||||
|
|
||||||
export function PixelsPage() {
|
export function PixelsPage() {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
const { teamId } = useNavigation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageBody>
|
<PageBody>
|
||||||
<Column>
|
<Column gap="6">
|
||||||
<PageHeader title={formatMessage(labels.pixels)}>
|
<PageHeader title={formatMessage(labels.pixels)}>
|
||||||
<PixelAddButton />
|
<PixelAddButton teamId={teamId} />
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
|
<Panel>
|
||||||
|
<PixelsDataTable />
|
||||||
|
</Panel>
|
||||||
</Column>
|
</Column>
|
||||||
</PageBody>
|
</PageBody>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
45
src/app/(main)/pixels/PixelsTable.tsx
Normal file
45
src/app/(main)/pixels/PixelsTable.tsx
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
import { DataTable, DataColumn, Row } from '@umami/react-zen';
|
||||||
|
import { useConfig, useMessages, useNavigation } from '@/components/hooks';
|
||||||
|
import { Empty } from '@/components/common/Empty';
|
||||||
|
import { DateDistance } from '@/components/common/DateDistance';
|
||||||
|
import { PixelEditButton } from './PixelEditButton';
|
||||||
|
import { PixelDeleteButton } from './PixelDeleteButton';
|
||||||
|
import Link from 'next/link';
|
||||||
|
|
||||||
|
export function PixelsTable({ data = [] }) {
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
const { websiteId } = useNavigation();
|
||||||
|
const { pixelsUrl } = useConfig();
|
||||||
|
const defaultUrl = `${window.location.origin}/p`;
|
||||||
|
|
||||||
|
if (data.length === 0) {
|
||||||
|
return <Empty />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DataTable data={data}>
|
||||||
|
<DataColumn id="name" label={formatMessage(labels.name)} />
|
||||||
|
<DataColumn id="url" label="URL">
|
||||||
|
{({ slug }: any) => {
|
||||||
|
const url = `${pixelsUrl || defaultUrl}/${slug}`;
|
||||||
|
return <Link href={url}>{url}</Link>;
|
||||||
|
}}
|
||||||
|
</DataColumn>
|
||||||
|
<DataColumn id="created" label={formatMessage(labels.created)}>
|
||||||
|
{(row: any) => <DateDistance date={new Date(row.createdAt)} />}
|
||||||
|
</DataColumn>
|
||||||
|
<DataColumn id="action" align="end" width="100px">
|
||||||
|
{(row: any) => {
|
||||||
|
const { id, name } = row;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Row>
|
||||||
|
<PixelEditButton pixelId={id} />
|
||||||
|
<PixelDeleteButton pixelId={id} websiteId={websiteId} name={name} />
|
||||||
|
</Row>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</DataColumn>
|
||||||
|
</DataTable>
|
||||||
|
);
|
||||||
|
}
|
||||||
0
src/app/(main)/pixels/[pixelId]/route.ts
Normal file
0
src/app/(main)/pixels/[pixelId]/route.ts
Normal file
|
|
@ -26,7 +26,7 @@ export function TeamMemberEditButton({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ActionButton tooltip={formatMessage(labels.edit)} icon={<Edit />}>
|
<ActionButton title={formatMessage(labels.edit)} icon={<Edit />}>
|
||||||
<Dialog title={formatMessage(labels.editMember)} style={{ width: 400 }}>
|
<Dialog title={formatMessage(labels.editMember)} style={{ width: 400 }}>
|
||||||
{({ close }) => (
|
{({ close }) => (
|
||||||
<TeamMemberEditForm
|
<TeamMemberEditForm
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ export function TeamMemberRemoveButton({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ActionButton tooltip={formatMessage(labels.delete)} icon={<Trash />}>
|
<ActionButton title={formatMessage(labels.delete)} icon={<Trash />}>
|
||||||
<Dialog title={formatMessage(labels.removeMember)} style={{ width: 400 }}>
|
<Dialog title={formatMessage(labels.removeMember)} style={{ width: 400 }}>
|
||||||
{({ close }) => (
|
{({ close }) => (
|
||||||
<ConfirmationForm
|
<ConfirmationForm
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
.website {
|
|
||||||
padding-bottom: 30px;
|
|
||||||
border-bottom: 1px solid var(--base300);
|
|
||||||
margin-bottom: 30px;
|
|
||||||
align-self: stretch;
|
|
||||||
}
|
|
||||||
|
|
||||||
.website:last-child {
|
|
||||||
border-bottom: 0;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
@ -23,8 +23,8 @@ export function WebsiteData({ websiteId, onSave }: { websiteId: string; onSave?:
|
||||||
const canTransferWebsite =
|
const canTransferWebsite =
|
||||||
(
|
(
|
||||||
(!teamId &&
|
(!teamId &&
|
||||||
teams?.data?.filter(({ teamUser }) =>
|
teams?.data?.filter(({ members }) =>
|
||||||
teamUser.find(
|
members.find(
|
||||||
({ role, userId }) =>
|
({ role, userId }) =>
|
||||||
[ROLES.teamOwner, ROLES.teamManager].includes(role) && userId === user.id,
|
[ROLES.teamOwner, ROLES.teamManager].includes(role) && userId === user.id,
|
||||||
),
|
),
|
||||||
|
|
@ -34,7 +34,7 @@ export function WebsiteData({ websiteId, onSave }: { websiteId: string; onSave?:
|
||||||
(teamId &&
|
(teamId &&
|
||||||
!!teams?.data
|
!!teams?.data
|
||||||
?.find(({ id }) => id === teamId)
|
?.find(({ id }) => id === teamId)
|
||||||
?.teamUser.find(({ role, userId }) => role === ROLES.teamOwner && userId === user.id));
|
?.members.find(({ role, userId }) => role === ROLES.teamOwner && userId === user.id));
|
||||||
|
|
||||||
const handleSave = () => {
|
const handleSave = () => {
|
||||||
touch('websites');
|
touch('websites');
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import { WebsiteShareForm } from './WebsiteShareForm';
|
||||||
import { WebsiteTrackingCode } from './WebsiteTrackingCode';
|
import { WebsiteTrackingCode } from './WebsiteTrackingCode';
|
||||||
import { WebsiteData } from './WebsiteData';
|
import { WebsiteData } from './WebsiteData';
|
||||||
import { WebsiteEditForm } from './WebsiteEditForm';
|
import { WebsiteEditForm } from './WebsiteEditForm';
|
||||||
import { SegmentsDataTable } from '@/app/(main)/websites/[websiteId]/segments/SegmentsDataTable';
|
|
||||||
|
|
||||||
export function WebsiteSettings({ websiteId }: { websiteId: string; openExternal?: boolean }) {
|
export function WebsiteSettings({ websiteId }: { websiteId: string; openExternal?: boolean }) {
|
||||||
const website = useContext(WebsiteContext);
|
const website = useContext(WebsiteContext);
|
||||||
|
|
@ -18,7 +17,6 @@ export function WebsiteSettings({ websiteId }: { websiteId: string; openExternal
|
||||||
<Tab id="details">{formatMessage(labels.details)}</Tab>
|
<Tab id="details">{formatMessage(labels.details)}</Tab>
|
||||||
<Tab id="tracking">{formatMessage(labels.trackingCode)}</Tab>
|
<Tab id="tracking">{formatMessage(labels.trackingCode)}</Tab>
|
||||||
<Tab id="share"> {formatMessage(labels.shareUrl)}</Tab>
|
<Tab id="share"> {formatMessage(labels.shareUrl)}</Tab>
|
||||||
<Tab id="segments"> {formatMessage(labels.segments)}</Tab>
|
|
||||||
<Tab id="manage">{formatMessage(labels.manage)}</Tab>
|
<Tab id="manage">{formatMessage(labels.manage)}</Tab>
|
||||||
</TabList>
|
</TabList>
|
||||||
<TabPanel id="details" style={{ width: 500 }}>
|
<TabPanel id="details" style={{ width: 500 }}>
|
||||||
|
|
@ -30,9 +28,6 @@ export function WebsiteSettings({ websiteId }: { websiteId: string; openExternal
|
||||||
<TabPanel id="share" style={{ width: 500 }}>
|
<TabPanel id="share" style={{ width: 500 }}>
|
||||||
<WebsiteShareForm websiteId={websiteId} shareId={website.shareId} />
|
<WebsiteShareForm websiteId={websiteId} shareId={website.shareId} />
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel id="segments">
|
|
||||||
<SegmentsDataTable websiteId={websiteId} />
|
|
||||||
</TabPanel>
|
|
||||||
<TabPanel id="manage">
|
<TabPanel id="manage">
|
||||||
<WebsiteData websiteId={websiteId} />
|
<WebsiteData websiteId={websiteId} />
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { DataGrid } from '@/components/common/DataGrid';
|
import { DataGrid } from '@/components/common/DataGrid';
|
||||||
import { TeamsTable } from '@/app/(main)/settings/teams/TeamsTable';
|
import { TeamsTable } from './TeamsTable';
|
||||||
import { useLoginQuery, useUserTeamsQuery } from '@/components/hooks';
|
import { useLoginQuery, useUserTeamsQuery } from '@/components/hooks';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
'use client';
|
'use client';
|
||||||
import { WebsitesDataTable } from '@/app/(main)/settings/websites/WebsitesDataTable';
|
import { WebsitesDataTable } from './WebsitesDataTable';
|
||||||
|
import { WebsiteAddButton } from './WebsiteAddButton';
|
||||||
import { useMessages, useNavigation } from '@/components/hooks';
|
import { useMessages, useNavigation } from '@/components/hooks';
|
||||||
import { Column } from '@umami/react-zen';
|
import { Column } from '@umami/react-zen';
|
||||||
import { PageHeader } from '@/components/common/PageHeader';
|
import { PageHeader } from '@/components/common/PageHeader';
|
||||||
import { WebsiteAddButton } from '@/app/(main)/settings/websites/WebsiteAddButton';
|
|
||||||
import { Panel } from '@/components/common/Panel';
|
import { Panel } from '@/components/common/Panel';
|
||||||
import { PageBody } from '@/components/common/PageBody';
|
import { PageBody } from '@/components/common/PageBody';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ import {
|
||||||
Tag,
|
Tag,
|
||||||
Money,
|
Money,
|
||||||
Network,
|
Network,
|
||||||
|
ChartPie,
|
||||||
|
UserPlus,
|
||||||
} from '@/components/icons';
|
} from '@/components/icons';
|
||||||
import { useMessages, useNavigation } from '@/components/hooks';
|
import { useMessages, useNavigation } from '@/components/hooks';
|
||||||
import { SideMenu } from '@/components/common/SideMenu';
|
import { SideMenu } from '@/components/common/SideMenu';
|
||||||
|
|
@ -87,6 +89,23 @@ export function WebsiteNav({ websiteId }: { websiteId: string }) {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: formatMessage(labels.audience),
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
id: 'segments',
|
||||||
|
label: formatMessage(labels.segments),
|
||||||
|
icon: <ChartPie />,
|
||||||
|
path: renderPath('/segments'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'cohorts',
|
||||||
|
label: formatMessage(labels.cohorts),
|
||||||
|
icon: <UserPlus />,
|
||||||
|
path: renderPath('/cohorts'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: formatMessage(labels.growth),
|
label: formatMessage(labels.growth),
|
||||||
items: [
|
items: [
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
import { Button, DialogTrigger, Modal, Text, Icon, Dialog } from '@umami/react-zen';
|
||||||
|
import { useMessages } from '@/components/hooks';
|
||||||
|
import { Plus } from '@/components/icons';
|
||||||
|
import { CohortEditForm } from './CohortEditForm';
|
||||||
|
|
||||||
|
export function CohortAddButton({ websiteId }: { websiteId: string }) {
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DialogTrigger>
|
||||||
|
<Button variant="primary">
|
||||||
|
<Icon>
|
||||||
|
<Plus />
|
||||||
|
</Icon>
|
||||||
|
<Text>{formatMessage(labels.cohort)}</Text>
|
||||||
|
</Button>
|
||||||
|
<Modal>
|
||||||
|
<Dialog title={formatMessage(labels.cohort)} style={{ width: 800 }}>
|
||||||
|
{({ close }) => {
|
||||||
|
return <CohortEditForm websiteId={websiteId} onClose={close} />;
|
||||||
|
}}
|
||||||
|
</Dialog>
|
||||||
|
</Modal>
|
||||||
|
</DialogTrigger>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
import { Dialog } from '@umami/react-zen';
|
||||||
|
import { ActionButton } from '@/components/input/ActionButton';
|
||||||
|
import { Trash } from '@/components/icons';
|
||||||
|
import { ConfirmationForm } from '@/components/common/ConfirmationForm';
|
||||||
|
import { messages } from '@/components/messages';
|
||||||
|
import { useApi, useMessages, useModified } from '@/components/hooks';
|
||||||
|
|
||||||
|
export function CohortDeleteButton({
|
||||||
|
cohortId,
|
||||||
|
websiteId,
|
||||||
|
name,
|
||||||
|
onSave,
|
||||||
|
}: {
|
||||||
|
cohortId: string;
|
||||||
|
websiteId: string;
|
||||||
|
name: string;
|
||||||
|
onSave?: () => void;
|
||||||
|
}) {
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
const { del, useMutation } = useApi();
|
||||||
|
const { mutate, isPending, error } = useMutation({
|
||||||
|
mutationFn: () => del(`/websites/${websiteId}/cohorts/${cohortId}`),
|
||||||
|
});
|
||||||
|
const { touch } = useModified();
|
||||||
|
|
||||||
|
const handleConfirm = (close: () => void) => {
|
||||||
|
mutate(null, {
|
||||||
|
onSuccess: () => {
|
||||||
|
touch('cohorts');
|
||||||
|
onSave?.();
|
||||||
|
close();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ActionButton title={formatMessage(labels.delete)} icon={<Trash />}>
|
||||||
|
<Dialog title={formatMessage(labels.confirm)} style={{ width: 400 }}>
|
||||||
|
{({ close }) => (
|
||||||
|
<ConfirmationForm
|
||||||
|
message={formatMessage(messages.confirmRemove, {
|
||||||
|
target: name,
|
||||||
|
})}
|
||||||
|
isLoading={isPending}
|
||||||
|
error={error}
|
||||||
|
onConfirm={handleConfirm.bind(null, close)}
|
||||||
|
onClose={close}
|
||||||
|
buttonLabel={formatMessage(labels.delete)}
|
||||||
|
buttonVariant="danger"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Dialog>
|
||||||
|
</ActionButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
import { ActionButton } from '@/components/input/ActionButton';
|
||||||
|
import { Edit } from '@/components/icons';
|
||||||
|
import { Dialog } from '@umami/react-zen';
|
||||||
|
import { CohortEditForm } from '@/app/(main)/websites/[websiteId]/cohorts/CohortEditForm';
|
||||||
|
import { useMessages } from '@/components/hooks';
|
||||||
|
|
||||||
|
export function CohortEditButton({
|
||||||
|
cohortId,
|
||||||
|
websiteId,
|
||||||
|
filters,
|
||||||
|
}: {
|
||||||
|
cohortId: string;
|
||||||
|
websiteId: string;
|
||||||
|
filters: any[];
|
||||||
|
}) {
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ActionButton title={formatMessage(labels.edit)} icon={<Edit />}>
|
||||||
|
<Dialog title={formatMessage(labels.cohort)} style={{ width: 800 }}>
|
||||||
|
{({ close }) => {
|
||||||
|
return (
|
||||||
|
<CohortEditForm
|
||||||
|
cohortId={cohortId}
|
||||||
|
websiteId={websiteId}
|
||||||
|
filters={filters}
|
||||||
|
onClose={close}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</Dialog>
|
||||||
|
</ActionButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
100
src/app/(main)/websites/[websiteId]/cohorts/CohortEditForm.tsx
Normal file
100
src/app/(main)/websites/[websiteId]/cohorts/CohortEditForm.tsx
Normal file
|
|
@ -0,0 +1,100 @@
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Form,
|
||||||
|
FormButtons,
|
||||||
|
FormField,
|
||||||
|
FormSubmitButton,
|
||||||
|
TextField,
|
||||||
|
Label,
|
||||||
|
Loading,
|
||||||
|
} from '@umami/react-zen';
|
||||||
|
import { subMonths, endOfDay } from 'date-fns';
|
||||||
|
import { FieldFilters } from '@/components/input/FieldFilters';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { useApi, useMessages, useModified, useWebsiteCohortQuery } from '@/components/hooks';
|
||||||
|
import { filtersArrayToObject } from '@/lib/params';
|
||||||
|
|
||||||
|
export function CohortEditForm({
|
||||||
|
cohortId,
|
||||||
|
websiteId,
|
||||||
|
filters = [],
|
||||||
|
showFilters = true,
|
||||||
|
onSave,
|
||||||
|
onClose,
|
||||||
|
}: {
|
||||||
|
cohortId?: string;
|
||||||
|
websiteId: string;
|
||||||
|
filters?: any[];
|
||||||
|
showFilters?: boolean;
|
||||||
|
onSave?: () => void;
|
||||||
|
onClose?: () => void;
|
||||||
|
}) {
|
||||||
|
const { data } = useWebsiteCohortQuery(websiteId, cohortId);
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
const [currentFilters, setCurrentFilters] = useState(filters);
|
||||||
|
const { touch } = useModified();
|
||||||
|
const startDate = subMonths(endOfDay(new Date()), 6);
|
||||||
|
const endDate = endOfDay(new Date());
|
||||||
|
|
||||||
|
const { post, useMutation } = useApi();
|
||||||
|
const { mutate, error, isPending } = useMutation({
|
||||||
|
mutationFn: (data: any) =>
|
||||||
|
post(`/websites/${websiteId}/cohorts${cohortId ? `/${cohortId}` : ''}`, {
|
||||||
|
...data,
|
||||||
|
type: 'cohort',
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleSubmit = async (data: any) => {
|
||||||
|
mutate(
|
||||||
|
{ ...data, parameters: filtersArrayToObject(currentFilters) },
|
||||||
|
{
|
||||||
|
onSuccess: async () => {
|
||||||
|
touch('cohorts');
|
||||||
|
onSave?.();
|
||||||
|
onClose?.();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (cohortId && !data) {
|
||||||
|
return <Loading position="page" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Form error={error} onSubmit={handleSubmit} defaultValues={data}>
|
||||||
|
<FormField
|
||||||
|
name="name"
|
||||||
|
label={formatMessage(labels.name)}
|
||||||
|
rules={{ required: formatMessage(labels.required) }}
|
||||||
|
>
|
||||||
|
<TextField autoFocus />
|
||||||
|
</FormField>
|
||||||
|
{showFilters && (
|
||||||
|
<>
|
||||||
|
<Label>{formatMessage(labels.filters)}</Label>
|
||||||
|
<FieldFilters
|
||||||
|
websiteId={websiteId}
|
||||||
|
filters={currentFilters}
|
||||||
|
startDate={startDate}
|
||||||
|
endDate={endDate}
|
||||||
|
onSave={setCurrentFilters}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
<FormButtons>
|
||||||
|
<Button isDisabled={isPending} onPress={onClose}>
|
||||||
|
{formatMessage(labels.cancel)}
|
||||||
|
</Button>
|
||||||
|
<FormSubmitButton
|
||||||
|
variant="primary"
|
||||||
|
data-test="button-submit"
|
||||||
|
isDisabled={isPending || currentFilters.length === 0}
|
||||||
|
>
|
||||||
|
{formatMessage(labels.save)}
|
||||||
|
</FormSubmitButton>
|
||||||
|
</FormButtons>
|
||||||
|
</Form>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { CohortAddButton } from './CohortAddButton';
|
||||||
|
import { useWebsiteCohortsQuery } from '@/components/hooks';
|
||||||
|
import { CohortsTable } from './CohortsTable';
|
||||||
|
import { DataGrid } from '@/components/common/DataGrid';
|
||||||
|
|
||||||
|
export function CohortsDataTable({ websiteId }: { websiteId?: string }) {
|
||||||
|
const query = useWebsiteCohortsQuery(websiteId, { type: 'cohort' });
|
||||||
|
|
||||||
|
const renderActions = () => {
|
||||||
|
return <CohortAddButton websiteId={websiteId} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DataGrid
|
||||||
|
query={query}
|
||||||
|
allowSearch={true}
|
||||||
|
autoFocus={false}
|
||||||
|
allowPaging={true}
|
||||||
|
renderActions={renderActions}
|
||||||
|
>
|
||||||
|
{({ data }) => <CohortsTable data={data} />}
|
||||||
|
</DataGrid>
|
||||||
|
);
|
||||||
|
}
|
||||||
16
src/app/(main)/websites/[websiteId]/cohorts/CohortsPage.tsx
Normal file
16
src/app/(main)/websites/[websiteId]/cohorts/CohortsPage.tsx
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
'use client';
|
||||||
|
import { Column } from '@umami/react-zen';
|
||||||
|
import { CohortsDataTable } from './CohortsDataTable';
|
||||||
|
import { WebsiteControls } from '@/app/(main)/websites/[websiteId]/WebsiteControls';
|
||||||
|
import { Panel } from '@/components/common/Panel';
|
||||||
|
|
||||||
|
export function CohortsPage({ websiteId }) {
|
||||||
|
return (
|
||||||
|
<Column gap="3">
|
||||||
|
<WebsiteControls websiteId={websiteId} allowFilter={false} allowDateFilter={false} />
|
||||||
|
<Panel>
|
||||||
|
<CohortsDataTable websiteId={websiteId} />
|
||||||
|
</Panel>
|
||||||
|
</Column>
|
||||||
|
);
|
||||||
|
}
|
||||||
41
src/app/(main)/websites/[websiteId]/cohorts/CohortsTable.tsx
Normal file
41
src/app/(main)/websites/[websiteId]/cohorts/CohortsTable.tsx
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
import { DataTable, DataColumn, Row } from '@umami/react-zen';
|
||||||
|
import { useMessages, useNavigation } from '@/components/hooks';
|
||||||
|
import { Empty } from '@/components/common/Empty';
|
||||||
|
import { DateDistance } from '@/components/common/DateDistance';
|
||||||
|
import { filtersObjectToArray } from '@/lib/params';
|
||||||
|
import { CohortEditButton } from '@/app/(main)/websites/[websiteId]/cohorts/CohortEditButton';
|
||||||
|
import { CohortDeleteButton } from '@/app/(main)/websites/[websiteId]/cohorts/CohortDeleteButton';
|
||||||
|
|
||||||
|
export function CohortsTable({ data = [] }) {
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
const { websiteId } = useNavigation();
|
||||||
|
|
||||||
|
if (data.length === 0) {
|
||||||
|
return <Empty />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DataTable data={data}>
|
||||||
|
<DataColumn id="name" label={formatMessage(labels.name)} />
|
||||||
|
<DataColumn id="created" label={formatMessage(labels.created)}>
|
||||||
|
{(row: any) => <DateDistance date={new Date(row.createdAt)} />}
|
||||||
|
</DataColumn>
|
||||||
|
<DataColumn id="action" align="end" width="100px">
|
||||||
|
{(row: any) => {
|
||||||
|
const { id, name, parameters } = row;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Row>
|
||||||
|
<CohortEditButton
|
||||||
|
cohortId={id}
|
||||||
|
websiteId={websiteId}
|
||||||
|
filters={filtersObjectToArray(parameters)}
|
||||||
|
/>
|
||||||
|
<CohortDeleteButton cohortId={id} websiteId={websiteId} name={name} />
|
||||||
|
</Row>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</DataColumn>
|
||||||
|
</DataTable>
|
||||||
|
);
|
||||||
|
}
|
||||||
12
src/app/(main)/websites/[websiteId]/cohorts/page.tsx
Normal file
12
src/app/(main)/websites/[websiteId]/cohorts/page.tsx
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { Metadata } from 'next';
|
||||||
|
import { CohortsPage } from './CohortsPage';
|
||||||
|
|
||||||
|
export default async function ({ params }: { params: Promise<{ websiteId: string }> }) {
|
||||||
|
const { websiteId } = await params;
|
||||||
|
|
||||||
|
return <CohortsPage websiteId={websiteId} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: 'Cohorts',
|
||||||
|
};
|
||||||
|
|
@ -34,7 +34,7 @@ export function SegmentDeleteButton({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ActionButton tooltip={formatMessage(labels.delete)} icon={<Trash />}>
|
<ActionButton title={formatMessage(labels.delete)} icon={<Trash />}>
|
||||||
<Dialog title={formatMessage(labels.confirm)} style={{ width: 400 }}>
|
<Dialog title={formatMessage(labels.confirm)} style={{ width: 400 }}>
|
||||||
{({ close }) => (
|
{({ close }) => (
|
||||||
<ConfirmationForm
|
<ConfirmationForm
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ export function SegmentEditButton({
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ActionButton tooltip={formatMessage(labels.edit)} icon={<Edit />}>
|
<ActionButton title={formatMessage(labels.edit)} icon={<Edit />}>
|
||||||
<Dialog title={formatMessage(labels.segment)} style={{ width: 800 }}>
|
<Dialog title={formatMessage(labels.segment)} style={{ width: 800 }}>
|
||||||
{({ close }) => {
|
{({ close }) => {
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ export type Config = {
|
||||||
telemetryDisabled: boolean;
|
telemetryDisabled: boolean;
|
||||||
trackerScriptName?: string;
|
trackerScriptName?: string;
|
||||||
updatesDisabled: boolean;
|
updatesDisabled: boolean;
|
||||||
linkDomain?: string;
|
linksUrl?: string;
|
||||||
pixelDomain?: string;
|
pixelsUrl?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function getConfig(): Promise<Config> {
|
export async function getConfig(): Promise<Config> {
|
||||||
|
|
@ -17,7 +17,7 @@ export async function getConfig(): Promise<Config> {
|
||||||
telemetryDisabled: !!process.env.DISABLE_TELEMETRY,
|
telemetryDisabled: !!process.env.DISABLE_TELEMETRY,
|
||||||
trackerScriptName: process.env.TRACKER_SCRIPT_NAME,
|
trackerScriptName: process.env.TRACKER_SCRIPT_NAME,
|
||||||
updatesDisabled: !!process.env.DISABLE_UPDATES,
|
updatesDisabled: !!process.env.DISABLE_UPDATES,
|
||||||
linkDomain: process.env.LINK_DOMAIN,
|
linksUrl: process.env.LINKS_URL,
|
||||||
pixelDomain: process.env.PIXEL_DOMAIN,
|
pixelsUrl: process.env.PIXELS_URL,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { z } from 'zod';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { json, unauthorized } from '@/lib/response';
|
import { json, unauthorized } from '@/lib/response';
|
||||||
import { pagingParams, searchParams } from '@/lib/schema';
|
import { pagingParams, searchParams } from '@/lib/schema';
|
||||||
import { canViewAllTeams } from '@/lib/auth';
|
import { canViewAllTeams } from '@/validations';
|
||||||
import { getTeams } from '@/queries/prisma/team';
|
import { getTeams } from '@/queries/prisma/team';
|
||||||
|
|
||||||
export async function GET(request: Request) {
|
export async function GET(request: Request) {
|
||||||
|
|
@ -26,11 +26,11 @@ export async function GET(request: Request) {
|
||||||
include: {
|
include: {
|
||||||
_count: {
|
_count: {
|
||||||
select: {
|
select: {
|
||||||
teamUser: true,
|
members: true,
|
||||||
website: true,
|
websites: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
teamUser: {
|
members: {
|
||||||
select: {
|
select: {
|
||||||
user: {
|
user: {
|
||||||
omit: {
|
omit: {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { z } from 'zod';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { json, unauthorized } from '@/lib/response';
|
import { json, unauthorized } from '@/lib/response';
|
||||||
import { pagingParams, searchParams } from '@/lib/schema';
|
import { pagingParams, searchParams } from '@/lib/schema';
|
||||||
import { canViewUsers } from '@/lib/auth';
|
import { canViewUsers } from '@/validations';
|
||||||
import { getUsers } from '@/queries/prisma/user';
|
import { getUsers } from '@/queries/prisma/user';
|
||||||
|
|
||||||
export async function GET(request: Request) {
|
export async function GET(request: Request) {
|
||||||
|
|
@ -26,7 +26,7 @@ export async function GET(request: Request) {
|
||||||
include: {
|
include: {
|
||||||
_count: {
|
_count: {
|
||||||
select: {
|
select: {
|
||||||
websiteUser: {
|
websites: {
|
||||||
where: { deletedAt: null },
|
where: { deletedAt: null },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { z } from 'zod';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { json, unauthorized } from '@/lib/response';
|
import { json, unauthorized } from '@/lib/response';
|
||||||
import { pagingParams, searchParams } from '@/lib/schema';
|
import { pagingParams, searchParams } from '@/lib/schema';
|
||||||
import { canViewAllWebsites } from '@/lib/auth';
|
import { canViewAllWebsites } from '@/validations';
|
||||||
import { getWebsites } from '@/queries/prisma/website';
|
import { getWebsites } from '@/queries/prisma/website';
|
||||||
import { ROLES } from '@/lib/constants';
|
import { ROLES } from '@/lib/constants';
|
||||||
|
|
||||||
|
|
@ -39,7 +39,7 @@ export async function GET(request: Request) {
|
||||||
deletedAt: null,
|
deletedAt: null,
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
teamUser: {
|
members: {
|
||||||
where: {
|
where: {
|
||||||
role: ROLES.teamOwner,
|
role: ROLES.teamOwner,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { checkPassword } from '@/lib/auth';
|
|
||||||
import { createSecureToken } from '@/lib/jwt';
|
import { createSecureToken } from '@/lib/jwt';
|
||||||
import redis from '@/lib/redis';
|
import redis from '@/lib/redis';
|
||||||
import { getUserByUsername } from '@/queries';
|
import { getUserByUsername } from '@/queries';
|
||||||
import { json, unauthorized } from '@/lib/response';
|
import { json, unauthorized } from '@/lib/response';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { saveAuth } from '@/lib/auth';
|
import { saveAuth, checkPassword } from '@/lib/auth';
|
||||||
import { secret } from '@/lib/crypto';
|
import { secret } from '@/lib/crypto';
|
||||||
import { ROLES } from '@/lib/constants';
|
import { ROLES } from '@/lib/constants';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { canUpdateWebsite, canDeleteWebsite, canViewWebsite } from '@/lib/auth';
|
import { canUpdateLink, canDeleteLink, canViewLink } from '@/validations';
|
||||||
import { SHARE_ID_REGEX } from '@/lib/constants';
|
import { SHARE_ID_REGEX } from '@/lib/constants';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { ok, json, unauthorized, serverError } from '@/lib/response';
|
import { ok, json, unauthorized, serverError } from '@/lib/response';
|
||||||
import { deleteWebsite, getWebsite, updateWebsite } from '@/queries';
|
import { deleteLink, getLink, updateLink } from '@/queries';
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
request: Request,
|
request: Request,
|
||||||
|
|
@ -17,11 +17,11 @@ export async function GET(
|
||||||
|
|
||||||
const { websiteId } = await params;
|
const { websiteId } = await params;
|
||||||
|
|
||||||
if (!(await canViewWebsite(auth, websiteId))) {
|
if (!(await canViewLink(auth, websiteId))) {
|
||||||
return unauthorized();
|
return unauthorized();
|
||||||
}
|
}
|
||||||
|
|
||||||
const website = await getWebsite(websiteId);
|
const website = await getLink(websiteId);
|
||||||
|
|
||||||
return json(website);
|
return json(website);
|
||||||
}
|
}
|
||||||
|
|
@ -45,12 +45,12 @@ export async function POST(
|
||||||
const { websiteId } = await params;
|
const { websiteId } = await params;
|
||||||
const { name, domain, shareId } = body;
|
const { name, domain, shareId } = body;
|
||||||
|
|
||||||
if (!(await canUpdateWebsite(auth, websiteId))) {
|
if (!(await canUpdateLink(auth, websiteId))) {
|
||||||
return unauthorized();
|
return unauthorized();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const website = await updateWebsite(websiteId, { name, domain, shareId });
|
const website = await updateLink(websiteId, { name, domain, shareId });
|
||||||
|
|
||||||
return Response.json(website);
|
return Response.json(website);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
|
@ -74,11 +74,11 @@ export async function DELETE(
|
||||||
|
|
||||||
const { websiteId } = await params;
|
const { websiteId } = await params;
|
||||||
|
|
||||||
if (!(await canDeleteWebsite(auth, websiteId))) {
|
if (!(await canDeleteLink(auth, websiteId))) {
|
||||||
return unauthorized();
|
return unauthorized();
|
||||||
}
|
}
|
||||||
|
|
||||||
await deleteWebsite(websiteId);
|
await deleteLink(websiteId);
|
||||||
|
|
||||||
return ok();
|
return ok();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { canCreateTeamWebsite, canCreateWebsite } from '@/lib/auth';
|
import { canCreateTeamWebsite, canCreateWebsite } from '@/validations';
|
||||||
import { json, unauthorized } from '@/lib/response';
|
import { json, unauthorized } from '@/lib/response';
|
||||||
import { uuid } from '@/lib/crypto';
|
import { uuid } from '@/lib/crypto';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
|
|
@ -20,9 +20,9 @@ export async function GET(request: Request) {
|
||||||
|
|
||||||
const filters = await getQueryFilters(query);
|
const filters = await getQueryFilters(query);
|
||||||
|
|
||||||
const result = await getUserLinks(auth.user.id, filters);
|
const links = await getUserLinks(auth.user.id, filters);
|
||||||
|
|
||||||
return json(result);
|
return json(links);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function POST(request: Request) {
|
export async function POST(request: Request) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
import { z } from 'zod';
|
||||||
|
import { canUpdateWebsite, canDeleteWebsite, canViewWebsite } from '@/validations';
|
||||||
|
import { SHARE_ID_REGEX } from '@/lib/constants';
|
||||||
|
import { parseRequest } from '@/lib/request';
|
||||||
|
import { ok, json, unauthorized, serverError } from '@/lib/response';
|
||||||
|
import { deleteWebsite, getWebsite, updateWebsite } from '@/queries';
|
||||||
|
|
||||||
|
export async function GET(
|
||||||
|
request: Request,
|
||||||
|
{ params }: { params: Promise<{ websiteId: string }> },
|
||||||
|
) {
|
||||||
|
const { auth, error } = await parseRequest(request);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return error();
|
||||||
|
}
|
||||||
|
|
||||||
|
const { websiteId } = await params;
|
||||||
|
|
||||||
|
if (!(await canViewWebsite(auth, websiteId))) {
|
||||||
|
return unauthorized();
|
||||||
|
}
|
||||||
|
|
||||||
|
const website = await getWebsite(websiteId);
|
||||||
|
|
||||||
|
return json(website);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function POST(
|
||||||
|
request: Request,
|
||||||
|
{ params }: { params: Promise<{ websiteId: string }> },
|
||||||
|
) {
|
||||||
|
const schema = z.object({
|
||||||
|
name: z.string().optional(),
|
||||||
|
domain: z.string().optional(),
|
||||||
|
shareId: z.string().regex(SHARE_ID_REGEX).nullable().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const { auth, body, error } = await parseRequest(request, schema);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return error();
|
||||||
|
}
|
||||||
|
|
||||||
|
const { websiteId } = await params;
|
||||||
|
const { name, domain, shareId } = body;
|
||||||
|
|
||||||
|
if (!(await canUpdateWebsite(auth, websiteId))) {
|
||||||
|
return unauthorized();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const website = await updateWebsite(websiteId, { name, domain, shareId });
|
||||||
|
|
||||||
|
return Response.json(website);
|
||||||
|
} catch (e: any) {
|
||||||
|
if (e.message.includes('Unique constraint') && e.message.includes('share_id')) {
|
||||||
|
return serverError(new Error('That share ID is already taken.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return serverError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function DELETE(
|
||||||
|
request: Request,
|
||||||
|
{ params }: { params: Promise<{ websiteId: string }> },
|
||||||
|
) {
|
||||||
|
const { auth, error } = await parseRequest(request);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return error();
|
||||||
|
}
|
||||||
|
|
||||||
|
const { websiteId } = await params;
|
||||||
|
|
||||||
|
if (!(await canDeleteWebsite(auth, websiteId))) {
|
||||||
|
return unauthorized();
|
||||||
|
}
|
||||||
|
|
||||||
|
await deleteWebsite(websiteId);
|
||||||
|
|
||||||
|
return ok();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
import { z } from 'zod';
|
||||||
|
import { canCreateTeamWebsite, canCreateWebsite } from '@/validations';
|
||||||
|
import { json, unauthorized } from '@/lib/response';
|
||||||
|
import { uuid } from '@/lib/crypto';
|
||||||
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
|
import { pagingParams, searchParams } from '@/lib/schema';
|
||||||
|
import { createPixel, getUserLinks } from '@/queries';
|
||||||
|
|
||||||
|
export async function GET(request: Request) {
|
||||||
|
const schema = z.object({
|
||||||
|
...pagingParams,
|
||||||
|
...searchParams,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { auth, query, error } = await parseRequest(request, schema);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return error();
|
||||||
|
}
|
||||||
|
|
||||||
|
const filters = await getQueryFilters(query);
|
||||||
|
|
||||||
|
const inks = await getUserLinks(auth.user.id, filters);
|
||||||
|
|
||||||
|
return json(inks);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function POST(request: Request) {
|
||||||
|
const schema = z.object({
|
||||||
|
name: z.string().max(100),
|
||||||
|
slug: z.string().max(100),
|
||||||
|
teamId: z.string().nullable().optional(),
|
||||||
|
id: z.string().uuid().nullable().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const { auth, body, error } = await parseRequest(request, schema);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return error();
|
||||||
|
}
|
||||||
|
|
||||||
|
const { id, name, slug, teamId } = body;
|
||||||
|
|
||||||
|
if ((teamId && !(await canCreateTeamWebsite(auth, teamId))) || !(await canCreateWebsite(auth))) {
|
||||||
|
return unauthorized();
|
||||||
|
}
|
||||||
|
|
||||||
|
const data: any = {
|
||||||
|
id: id ?? uuid(),
|
||||||
|
name,
|
||||||
|
slug,
|
||||||
|
teamId,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!teamId) {
|
||||||
|
data.userId = auth.user.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await createPixel(data);
|
||||||
|
|
||||||
|
return json(result);
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { json, unauthorized } from '@/lib/response';
|
import { json, unauthorized } from '@/lib/response';
|
||||||
import { getRealtimeData } from '@/queries';
|
import { getRealtimeData } from '@/queries';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { startOfMinute, subMinutes } from 'date-fns';
|
import { startOfMinute, subMinutes } from 'date-fns';
|
||||||
import { REALTIME_RANGE } from '@/lib/constants';
|
import { REALTIME_RANGE } from '@/lib/constants';
|
||||||
import { parseRequest, getQueryFilters } from '@/lib/request';
|
import { parseRequest, getQueryFilters } from '@/lib/request';
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { deleteReport, getReport, updateReport } from '@/queries';
|
import { deleteReport, getReport, updateReport } from '@/queries';
|
||||||
import { canDeleteReport, canUpdateReport, canViewReport } from '@/lib/auth';
|
import { canDeleteReport, canUpdateReport, canViewReport } from '@/validations';
|
||||||
import { unauthorized, json, notFound, ok } from '@/lib/response';
|
import { unauthorized, json, notFound, ok } from '@/lib/response';
|
||||||
import { reportSchema } from '@/lib/schema';
|
import { reportSchema } from '@/lib/schema';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { getQueryFilters, parseRequest, setWebsiteDate } from '@/lib/request';
|
import { getQueryFilters, parseRequest, setWebsiteDate } from '@/lib/request';
|
||||||
import { json, unauthorized } from '@/lib/response';
|
import { json, unauthorized } from '@/lib/response';
|
||||||
import { reportResultSchema } from '@/lib/schema';
|
import { reportResultSchema } from '@/lib/schema';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { getQueryFilters, parseRequest, setWebsiteDate } from '@/lib/request';
|
import { getQueryFilters, parseRequest, setWebsiteDate } from '@/lib/request';
|
||||||
import { BreakdownParameters, getBreakdown } from '@/queries';
|
import { BreakdownParameters, getBreakdown } from '@/queries';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { parseRequest, getQueryFilters, setWebsiteDate } from '@/lib/request';
|
import { parseRequest, getQueryFilters, setWebsiteDate } from '@/lib/request';
|
||||||
import { FunnelParameters, getFunnel } from '@/queries';
|
import { FunnelParameters, getFunnel } from '@/queries';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { getQueryFilters, parseRequest, setWebsiteDate } from '@/lib/request';
|
import { getQueryFilters, parseRequest, setWebsiteDate } from '@/lib/request';
|
||||||
import { getGoal, GoalParameters } from '@/queries/sql/reports/getGoal';
|
import { getGoal, GoalParameters } from '@/queries/sql/reports/getGoal';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { getJourney } from '@/queries';
|
import { getJourney } from '@/queries';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { parseRequest, getQueryFilters, setWebsiteDate } from '@/lib/request';
|
import { parseRequest, getQueryFilters, setWebsiteDate } from '@/lib/request';
|
||||||
import { getRetention, RetentionParameters } from '@/queries';
|
import { getRetention, RetentionParameters } from '@/queries';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { parseRequest, getQueryFilters, setWebsiteDate } from '@/lib/request';
|
import { parseRequest, getQueryFilters, setWebsiteDate } from '@/lib/request';
|
||||||
import { reportResultSchema } from '@/lib/schema';
|
import { reportResultSchema } from '@/lib/schema';
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { z } from 'zod';
|
||||||
import { uuid } from '@/lib/crypto';
|
import { uuid } from '@/lib/crypto';
|
||||||
import { pagingParams, reportSchema } from '@/lib/schema';
|
import { pagingParams, reportSchema } from '@/lib/schema';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { canViewWebsite, canUpdateWebsite } from '@/lib/auth';
|
import { canViewWebsite, canUpdateWebsite } from '@/validations';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { getReports, createReport } from '@/queries';
|
import { getReports, createReport } from '@/queries';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { getQueryFilters, parseRequest, setWebsiteDate } from '@/lib/request';
|
import { getQueryFilters, parseRequest, setWebsiteDate } from '@/lib/request';
|
||||||
import { getUTM, UTMParameters } from '@/queries';
|
import { getUTM, UTMParameters } from '@/queries';
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewTeam } from '@/lib/auth';
|
import { canViewTeam } from '@/validations';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { pagingParams, searchParams } from '@/lib/schema';
|
import { pagingParams, searchParams } from '@/lib/schema';
|
||||||
import { getTeamLinks } from '@/queries';
|
import { getTeamLinks } from '@/queries';
|
||||||
|
|
@ -23,7 +23,7 @@ export async function GET(request: Request, { params }: { params: Promise<{ team
|
||||||
|
|
||||||
const filters = await getQueryFilters(query);
|
const filters = await getQueryFilters(query);
|
||||||
|
|
||||||
const websites = await getTeamLinks(teamId, filters);
|
const links = await getTeamLinks(teamId, filters);
|
||||||
|
|
||||||
return json(websites);
|
return json(links);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewTeam } from '@/lib/auth';
|
import { canViewTeam } from '@/validations';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { pagingParams, searchParams } from '@/lib/schema';
|
import { pagingParams, searchParams } from '@/lib/schema';
|
||||||
import { getTeamPixels } from '@/queries';
|
import { getTeamPixels } from '@/queries';
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { unauthorized, json, notFound, ok } from '@/lib/response';
|
import { unauthorized, json, notFound, ok } from '@/lib/response';
|
||||||
import { canDeleteTeam, canUpdateTeam, canViewTeam } from '@/lib/auth';
|
import { canDeleteTeam, canUpdateTeam, canViewTeam } from '@/validations';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { deleteTeam, getTeam, updateTeam } from '@/queries';
|
import { deleteTeam, getTeam, updateTeam } from '@/queries';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canDeleteTeamUser, canUpdateTeam } from '@/lib/auth';
|
import { canDeleteTeamUser, canUpdateTeam } from '@/validations';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { badRequest, json, ok, unauthorized } from '@/lib/response';
|
import { badRequest, json, ok, unauthorized } from '@/lib/response';
|
||||||
import { deleteTeamUser, getTeamUser, updateTeamUser } from '@/queries';
|
import { deleteTeamUser, getTeamUser, updateTeamUser } from '@/queries';
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { unauthorized, json, badRequest } from '@/lib/response';
|
import { unauthorized, json, badRequest } from '@/lib/response';
|
||||||
import { canAddUserToTeam, canViewTeam } from '@/lib/auth';
|
import { canAddUserToTeam, canViewTeam } from '@/validations';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { pagingParams, teamRoleParam, searchParams } from '@/lib/schema';
|
import { pagingParams, teamRoleParam, searchParams } from '@/lib/schema';
|
||||||
import { createTeamUser, getTeamUser, getTeamUsers } from '@/queries';
|
import { createTeamUser, getTeamUser, getTeamUsers } from '@/queries';
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewTeam } from '@/lib/auth';
|
import { canViewTeam } from '@/validations';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { pagingParams, searchParams } from '@/lib/schema';
|
import { pagingParams, searchParams } from '@/lib/schema';
|
||||||
import { getTeamWebsites } from '@/queries';
|
import { getTeamWebsites } from '@/queries';
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { unauthorized, json, badRequest, notFound } from '@/lib/response';
|
import { unauthorized, json, badRequest, notFound } from '@/lib/response';
|
||||||
import { canCreateTeam } from '@/lib/auth';
|
import { canCreateTeam } from '@/validations';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { ROLES } from '@/lib/constants';
|
import { ROLES } from '@/lib/constants';
|
||||||
import { createTeamUser, findTeam, getTeamUser } from '@/queries';
|
import { createTeamUser, findTeam, getTeamUser } from '@/queries';
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { getRandomChars } from '@/lib/crypto';
|
import { getRandomChars } from '@/lib/crypto';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canCreateTeam } from '@/lib/auth';
|
import { canCreateTeam } from '@/validations';
|
||||||
import { uuid } from '@/lib/crypto';
|
import { uuid } from '@/lib/crypto';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { createTeam } from '@/queries';
|
import { createTeam } from '@/queries';
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { canUpdateUser, canViewUser, canDeleteUser } from '@/lib/auth';
|
import { canUpdateUser, canViewUser, canDeleteUser } from '@/validations';
|
||||||
import { getUser, getUserByUsername, updateUser, deleteUser } from '@/queries';
|
import { getUser, getUserByUsername, updateUser, deleteUser } from '@/queries';
|
||||||
import { json, unauthorized, badRequest, ok } from '@/lib/response';
|
import { json, unauthorized, badRequest, ok } from '@/lib/response';
|
||||||
import { hashPassword } from '@/lib/auth';
|
import { hashPassword } from '@/lib/auth';
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { hashPassword, canCreateUser } from '@/lib/auth';
|
import { hashPassword } from '@/lib/auth';
|
||||||
|
import { canCreateUser } from '@/validations';
|
||||||
import { ROLES } from '@/lib/constants';
|
import { ROLES } from '@/lib/constants';
|
||||||
import { uuid } from '@/lib/crypto';
|
import { uuid } from '@/lib/crypto';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { json, unauthorized } from '@/lib/response';
|
import { json, unauthorized } from '@/lib/response';
|
||||||
import { getActiveVisitors } from '@/queries';
|
import { getActiveVisitors } from '@/queries';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
|
|
@ -19,7 +19,7 @@ export async function GET(
|
||||||
return unauthorized();
|
return unauthorized();
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await getActiveVisitors(websiteId);
|
const visitors = await getActiveVisitors(websiteId);
|
||||||
|
|
||||||
return json(result);
|
return json(visitors);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { getWebsiteDateRange } from '@/queries';
|
import { getWebsiteDateRange } from '@/queries';
|
||||||
import { json, unauthorized } from '@/lib/response';
|
import { json, unauthorized } from '@/lib/response';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
|
|
@ -19,7 +19,7 @@ export async function GET(
|
||||||
return unauthorized();
|
return unauthorized();
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await getWebsiteDateRange(websiteId);
|
const dateRange = await getWebsiteDateRange(websiteId);
|
||||||
|
|
||||||
return json(result);
|
return json(dateRange);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { getEventData } from '@/queries/sql/events/getEventData';
|
import { getEventData } from '@/queries/sql/events/getEventData';
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { getEventDataEvents } from '@/queries/sql/events/getEventDataEvents';
|
import { getEventDataEvents } from '@/queries/sql/events/getEventDataEvents';
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { getEventDataFields } from '@/queries';
|
import { getEventDataFields } from '@/queries';
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { getEventDataProperties } from '@/queries';
|
import { getEventDataProperties } from '@/queries';
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { getEventDataStats } from '@/queries';
|
import { getEventDataStats } from '@/queries';
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { getEventDataValues } from '@/queries';
|
import { getEventDataValues } from '@/queries';
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { dateRangeParams, pagingParams, filterParams, searchParams } from '@/lib/schema';
|
import { dateRangeParams, pagingParams, filterParams, searchParams } from '@/lib/schema';
|
||||||
import { getWebsiteEvents } from '@/queries';
|
import { getWebsiteEvents } from '@/queries';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { parseRequest, getQueryFilters } from '@/lib/request';
|
import { parseRequest, getQueryFilters } from '@/lib/request';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { filterParams, timezoneParam, unitParam } from '@/lib/schema';
|
import { filterParams, timezoneParam, unitParam } from '@/lib/schema';
|
||||||
import { getEventStats } from '@/queries';
|
import { getEventStats } from '@/queries';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import JSZip from 'jszip';
|
||||||
import Papa from 'papaparse';
|
import Papa from 'papaparse';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { pagingParams, dateRangeParams } from '@/lib/schema';
|
import { pagingParams, dateRangeParams } from '@/lib/schema';
|
||||||
import { getEventMetrics, getPageviewMetrics, getSessionMetrics } from '@/queries';
|
import { getEventMetrics, getPageviewMetrics, getSessionMetrics } from '@/queries';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { EVENT_COLUMNS, SESSION_COLUMNS } from '@/lib/constants';
|
import { EVENT_COLUMNS, SESSION_COLUMNS } from '@/lib/constants';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { badRequest, json, unauthorized } from '@/lib/response';
|
import { badRequest, json, unauthorized } from '@/lib/response';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { EVENT_COLUMNS, SESSION_COLUMNS } from '@/lib/constants';
|
import { EVENT_COLUMNS, SESSION_COLUMNS } from '@/lib/constants';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { badRequest, json, unauthorized } from '@/lib/response';
|
import { badRequest, json, unauthorized } from '@/lib/response';
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { dateRangeParams, filterParams } from '@/lib/schema';
|
import { dateRangeParams, filterParams } from '@/lib/schema';
|
||||||
import { getCompareDate } from '@/lib/date';
|
import { getCompareDate } from '@/lib/date';
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { getReports } from '@/queries';
|
import { getReports } from '@/queries';
|
||||||
import { filterParams, pagingParams } from '@/lib/schema';
|
import { filterParams, pagingParams } from '@/lib/schema';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canUpdateWebsite } from '@/lib/auth';
|
import { canUpdateWebsite } from '@/validations';
|
||||||
import { resetWebsite } from '@/queries';
|
import { resetWebsite } from '@/queries';
|
||||||
import { unauthorized, ok } from '@/lib/response';
|
import { unauthorized, ok } from '@/lib/response';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { canUpdateWebsite, canDeleteWebsite, canViewWebsite } from '@/lib/auth';
|
import { canUpdateWebsite, canDeleteWebsite, canViewWebsite } from '@/validations';
|
||||||
import { SHARE_ID_REGEX } from '@/lib/constants';
|
import { SHARE_ID_REGEX } from '@/lib/constants';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { ok, json, unauthorized, serverError } from '@/lib/response';
|
import { ok, json, unauthorized, serverError } from '@/lib/response';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canDeleteWebsite, canUpdateWebsite, canViewWebsite } from '@/lib/auth';
|
import { canDeleteWebsite, canUpdateWebsite, canViewWebsite } from '@/validations';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { json, notFound, ok, unauthorized } from '@/lib/response';
|
import { json, notFound, ok, unauthorized } from '@/lib/response';
|
||||||
import { segmentTypeParam } from '@/lib/schema';
|
import { segmentTypeParam } from '@/lib/schema';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canUpdateWebsite, canViewWebsite } from '@/lib/auth';
|
import { canUpdateWebsite, canViewWebsite } from '@/validations';
|
||||||
import { uuid } from '@/lib/crypto';
|
import { uuid } from '@/lib/crypto';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { json, unauthorized } from '@/lib/response';
|
import { json, unauthorized } from '@/lib/response';
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { getSessionDataProperties } from '@/queries';
|
import { getSessionDataProperties } from '@/queries';
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { json, unauthorized } from '@/lib/response';
|
import { json, unauthorized } from '@/lib/response';
|
||||||
import { getSessionDataValues } from '@/queries';
|
import { getSessionDataValues } from '@/queries';
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { parseRequest, getQueryFilters } from '@/lib/request';
|
import { parseRequest, getQueryFilters } from '@/lib/request';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { getSessionActivity } from '@/queries';
|
import { getSessionActivity } from '@/queries';
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { getSessionData } from '@/queries';
|
import { getSessionData } from '@/queries';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { getWebsiteSession } from '@/queries';
|
import { getWebsiteSession } from '@/queries';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { dateRangeParams, filterParams, pagingParams, searchParams } from '@/lib/schema';
|
import { dateRangeParams, filterParams, pagingParams, searchParams } from '@/lib/schema';
|
||||||
import { getWebsiteSessions } from '@/queries';
|
import { getWebsiteSessions } from '@/queries';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { parseRequest, getQueryFilters } from '@/lib/request';
|
import { parseRequest, getQueryFilters } from '@/lib/request';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { filterParams } from '@/lib/schema';
|
import { filterParams } from '@/lib/schema';
|
||||||
import { getWebsiteSessionStats } from '@/queries';
|
import { getWebsiteSessionStats } from '@/queries';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { pagingParams, timezoneParam } from '@/lib/schema';
|
import { pagingParams, timezoneParam } from '@/lib/schema';
|
||||||
import { getWebsiteSessionsWeekly } from '@/queries';
|
import { getWebsiteSessionsWeekly } from '@/queries';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { parseRequest, getQueryFilters } from '@/lib/request';
|
import { parseRequest, getQueryFilters } from '@/lib/request';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { dateRangeParams, filterParams } from '@/lib/schema';
|
import { dateRangeParams, filterParams } from '@/lib/schema';
|
||||||
import { getWebsiteStats } from '@/queries';
|
import { getWebsiteStats } from '@/queries';
|
||||||
import { getCompareDate } from '@/lib/date';
|
import { getCompareDate } from '@/lib/date';
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { canTransferWebsiteToTeam, canTransferWebsiteToUser } from '@/lib/auth';
|
import { canTransferWebsiteToTeam, canTransferWebsiteToUser } from '@/validations';
|
||||||
import { updateWebsite } from '@/queries';
|
import { updateWebsite } from '@/queries';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { badRequest, unauthorized, json } from '@/lib/response';
|
import { badRequest, unauthorized, json } from '@/lib/response';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { canViewWebsite } from '@/lib/auth';
|
import { canViewWebsite } from '@/validations';
|
||||||
import { EVENT_COLUMNS, FILTER_COLUMNS, FILTER_GROUPS, SESSION_COLUMNS } from '@/lib/constants';
|
import { EVENT_COLUMNS, FILTER_COLUMNS, FILTER_GROUPS, SESSION_COLUMNS } from '@/lib/constants';
|
||||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { badRequest, json, unauthorized } from '@/lib/response';
|
import { badRequest, json, unauthorized } from '@/lib/response';
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { canCreateTeamWebsite, canCreateWebsite } from '@/lib/auth';
|
import { canCreateTeamWebsite, canCreateWebsite } from '@/validations';
|
||||||
import { json, unauthorized } from '@/lib/response';
|
import { json, unauthorized } from '@/lib/response';
|
||||||
import { uuid } from '@/lib/crypto';
|
import { uuid } from '@/lib/crypto';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue