dashboard: remove unnecessary org/project exists check
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
||||||
import { getExists } from '@/server/pageExists';
|
|
||||||
import { notFound } from 'next/navigation';
|
import { notFound } from 'next/navigation';
|
||||||
|
|
||||||
import { getDashboardById, getReportsByDashboardId } from '@openpanel/db';
|
import { getDashboardById, getReportsByDashboardId } from '@openpanel/db';
|
||||||
@@ -20,7 +19,6 @@ export default async function Page({
|
|||||||
const [dashboard, reports] = await Promise.all([
|
const [dashboard, reports] = await Promise.all([
|
||||||
getDashboardById(dashboardId, projectId),
|
getDashboardById(dashboardId, projectId),
|
||||||
getReportsByDashboardId(dashboardId),
|
getReportsByDashboardId(dashboardId),
|
||||||
getExists(organizationId),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!dashboard) {
|
if (!dashboard) {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
||||||
import { getExists } from '@/server/pageExists';
|
|
||||||
|
|
||||||
import { getDashboardsByProjectId } from '@openpanel/db';
|
import { getDashboardsByProjectId } from '@openpanel/db';
|
||||||
|
|
||||||
@@ -16,10 +15,7 @@ interface PageProps {
|
|||||||
export default async function Page({
|
export default async function Page({
|
||||||
params: { projectId, organizationId },
|
params: { projectId, organizationId },
|
||||||
}: PageProps) {
|
}: PageProps) {
|
||||||
const [dashboards] = await Promise.all([
|
const dashboards = await getDashboardsByProjectId(projectId);
|
||||||
getDashboardsByProjectId(projectId),
|
|
||||||
await getExists(organizationId, projectId),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageLayout title="Dashboards" organizationSlug={organizationId}>
|
<PageLayout title="Dashboards" organizationSlug={organizationId}>
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
eventQueryFiltersParser,
|
eventQueryFiltersParser,
|
||||||
eventQueryNamesFilter,
|
eventQueryNamesFilter,
|
||||||
} from '@/hooks/useEventQueryFilters';
|
} from '@/hooks/useEventQueryFilters';
|
||||||
import { getExists } from '@/server/pageExists';
|
|
||||||
import { parseAsInteger } from 'nuqs';
|
import { parseAsInteger } from 'nuqs';
|
||||||
|
|
||||||
import { getEventList, getEventsCount } from '@openpanel/db';
|
import { getEventList, getEventsCount } from '@openpanel/db';
|
||||||
@@ -54,7 +53,6 @@ export default async function Page({
|
|||||||
events: eventsFilter,
|
events: eventsFilter,
|
||||||
filters,
|
filters,
|
||||||
}),
|
}),
|
||||||
getExists(organizationId, projectId),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import OverviewTopEvents from '@/components/overview/overview-top-events';
|
|||||||
import OverviewTopGeo from '@/components/overview/overview-top-geo';
|
import OverviewTopGeo from '@/components/overview/overview-top-geo';
|
||||||
import OverviewTopPages from '@/components/overview/overview-top-pages';
|
import OverviewTopPages from '@/components/overview/overview-top-pages';
|
||||||
import OverviewTopSources from '@/components/overview/overview-top-sources';
|
import OverviewTopSources from '@/components/overview/overview-top-sources';
|
||||||
import { getExists } from '@/server/pageExists';
|
|
||||||
|
|
||||||
import { db } from '@openpanel/db';
|
import { db } from '@openpanel/db';
|
||||||
|
|
||||||
@@ -27,14 +26,11 @@ interface PageProps {
|
|||||||
export default async function Page({
|
export default async function Page({
|
||||||
params: { organizationId, projectId },
|
params: { organizationId, projectId },
|
||||||
}: PageProps) {
|
}: PageProps) {
|
||||||
const [share] = await Promise.all([
|
const share = await db.shareOverview.findUnique({
|
||||||
db.shareOverview.findUnique({
|
|
||||||
where: {
|
where: {
|
||||||
project_id: projectId,
|
project_id: projectId,
|
||||||
},
|
},
|
||||||
}),
|
});
|
||||||
getExists(organizationId, projectId),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageLayout title="Overview" organizationSlug={organizationId}>
|
<PageLayout title="Overview" organizationSlug={organizationId}>
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import {
|
|||||||
eventQueryFiltersParser,
|
eventQueryFiltersParser,
|
||||||
eventQueryNamesFilter,
|
eventQueryNamesFilter,
|
||||||
} from '@/hooks/useEventQueryFilters';
|
} from '@/hooks/useEventQueryFilters';
|
||||||
import { getExists } from '@/server/pageExists';
|
|
||||||
import { getProfileName } from '@/utils/getters';
|
import { getProfileName } from '@/utils/getters';
|
||||||
import { notFound } from 'next/navigation';
|
import { notFound } from 'next/navigation';
|
||||||
import { parseAsInteger, parseAsString } from 'nuqs';
|
import { parseAsInteger, parseAsString } from 'nuqs';
|
||||||
@@ -63,7 +62,6 @@ export default async function Page({
|
|||||||
getEventList(eventListOptions),
|
getEventList(eventListOptions),
|
||||||
getEventsCount(eventListOptions),
|
getEventsCount(eventListOptions),
|
||||||
getConversionEventNames(projectId),
|
getConversionEventNames(projectId),
|
||||||
getExists(organizationId, projectId),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const chartSelectedEvents: IChartEvent[] = [
|
const chartSelectedEvents: IChartEvent[] = [
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
|||||||
import { OverviewFiltersButtons } from '@/components/overview/filters/overview-filters-buttons';
|
import { OverviewFiltersButtons } from '@/components/overview/filters/overview-filters-buttons';
|
||||||
import { OverviewFiltersDrawer } from '@/components/overview/filters/overview-filters-drawer';
|
import { OverviewFiltersDrawer } from '@/components/overview/filters/overview-filters-drawer';
|
||||||
import { eventQueryFiltersParser } from '@/hooks/useEventQueryFilters';
|
import { eventQueryFiltersParser } from '@/hooks/useEventQueryFilters';
|
||||||
import { getExists } from '@/server/pageExists';
|
|
||||||
import { parseAsInteger } from 'nuqs';
|
import { parseAsInteger } from 'nuqs';
|
||||||
|
|
||||||
import { StickyBelowHeader } from '../layout-sticky-below-header';
|
import { StickyBelowHeader } from '../layout-sticky-below-header';
|
||||||
@@ -25,12 +24,10 @@ const nuqsOptions = {
|
|||||||
shallow: false,
|
shallow: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function Page({
|
export default function Page({
|
||||||
params: { organizationId, projectId },
|
params: { organizationId, projectId },
|
||||||
searchParams: { cursor, f },
|
searchParams: { cursor, f },
|
||||||
}: PageProps) {
|
}: PageProps) {
|
||||||
await getExists(organizationId, projectId);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageLayout title="Profiles" organizationSlug={organizationId}>
|
<PageLayout title="Profiles" organizationSlug={organizationId}>
|
||||||
<StickyBelowHeader className="p-4 flex justify-between">
|
<StickyBelowHeader className="p-4 flex justify-between">
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
||||||
import { getExists } from '@/server/pageExists';
|
|
||||||
import { Pencil } from 'lucide-react';
|
import { Pencil } from 'lucide-react';
|
||||||
import { notFound } from 'next/navigation';
|
import { notFound } from 'next/navigation';
|
||||||
|
|
||||||
import { getOrganizationBySlug, getReportById } from '@openpanel/db';
|
import { getReportById } from '@openpanel/db';
|
||||||
|
|
||||||
import ReportEditor from '../report-editor';
|
import ReportEditor from '../report-editor';
|
||||||
|
|
||||||
@@ -16,12 +15,9 @@ interface PageProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function Page({
|
export default async function Page({
|
||||||
params: { reportId, organizationId, projectId },
|
params: { reportId, organizationId },
|
||||||
}: PageProps) {
|
}: PageProps) {
|
||||||
const [report] = await Promise.all([
|
const report = await getReportById(reportId);
|
||||||
getReportById(reportId),
|
|
||||||
getExists(organizationId, projectId),
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (!report) {
|
if (!report) {
|
||||||
return notFound();
|
return notFound();
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
||||||
import { getExists } from '@/server/pageExists';
|
|
||||||
import { Pencil } from 'lucide-react';
|
import { Pencil } from 'lucide-react';
|
||||||
import { notFound } from 'next/navigation';
|
|
||||||
|
|
||||||
import { getOrganizationBySlug } from '@openpanel/db';
|
|
||||||
|
|
||||||
import ReportEditor from './report-editor';
|
import ReportEditor from './report-editor';
|
||||||
|
|
||||||
@@ -14,11 +10,7 @@ interface PageProps {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function Page({
|
export default function Page({ params: { organizationId } }: PageProps) {
|
||||||
params: { organizationId, projectId },
|
|
||||||
}: PageProps) {
|
|
||||||
await getExists(organizationId, projectId);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageLayout
|
<PageLayout
|
||||||
organizationSlug={organizationId}
|
organizationSlug={organizationId}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
||||||
import { getExists } from '@/server/pageExists';
|
|
||||||
|
|
||||||
import { getClientsByOrganizationId } from '@openpanel/db';
|
import { getClientsByOrganizationId } from '@openpanel/db';
|
||||||
|
|
||||||
@@ -12,7 +11,6 @@ interface PageProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function Page({ params: { organizationId } }: PageProps) {
|
export default async function Page({ params: { organizationId } }: PageProps) {
|
||||||
await getExists(organizationId);
|
|
||||||
const clients = await getClientsByOrganizationId(organizationId);
|
const clients = await getClientsByOrganizationId(organizationId);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
||||||
import { getExists } from '@/server/pageExists';
|
|
||||||
import { auth } from '@clerk/nextjs';
|
import { auth } from '@clerk/nextjs';
|
||||||
|
|
||||||
import { getUserById } from '@openpanel/db';
|
import { getUserById } from '@openpanel/db';
|
||||||
@@ -14,7 +13,6 @@ interface PageProps {
|
|||||||
}
|
}
|
||||||
export default async function Page({ params: { organizationId } }: PageProps) {
|
export default async function Page({ params: { organizationId } }: PageProps) {
|
||||||
const { userId } = auth();
|
const { userId } = auth();
|
||||||
await getExists(organizationId);
|
|
||||||
const profile = await getUserById(userId!);
|
const profile = await getUserById(userId!);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
||||||
import { getExists } from '@/server/pageExists';
|
|
||||||
|
|
||||||
import { getProjectsByOrganizationSlug } from '@openpanel/db';
|
import { getProjectsByOrganizationSlug } from '@openpanel/db';
|
||||||
|
|
||||||
@@ -12,7 +11,6 @@ interface PageProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function Page({ params: { organizationId } }: PageProps) {
|
export default async function Page({ params: { organizationId } }: PageProps) {
|
||||||
await getExists(organizationId);
|
|
||||||
const projects = await getProjectsByOrganizationSlug(organizationId);
|
const projects = await getProjectsByOrganizationSlug(organizationId);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
import PageLayout from '@/app/(app)/[organizationId]/[projectId]/page-layout';
|
||||||
import { getExists } from '@/server/pageExists';
|
|
||||||
|
|
||||||
import { getReferences } from '@openpanel/db';
|
import { getReferences } from '@openpanel/db';
|
||||||
|
|
||||||
@@ -15,7 +14,6 @@ interface PageProps {
|
|||||||
export default async function Page({
|
export default async function Page({
|
||||||
params: { organizationId, projectId },
|
params: { organizationId, projectId },
|
||||||
}: PageProps) {
|
}: PageProps) {
|
||||||
await getExists(organizationId, projectId);
|
|
||||||
const references = await getReferences({
|
const references = await getReferences({
|
||||||
where: {
|
where: {
|
||||||
project_id: projectId,
|
project_id: projectId,
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
import { notFound } from 'next/navigation';
|
|
||||||
|
|
||||||
import { getOrganizationBySlug, getProjectById } from '@openpanel/db';
|
|
||||||
|
|
||||||
export async function getExists(organizationSlug: string, projectId?: string) {
|
|
||||||
const promises: Promise<any>[] = [getOrganizationBySlug(organizationSlug)];
|
|
||||||
|
|
||||||
if (projectId) {
|
|
||||||
promises.push(getProjectById(projectId));
|
|
||||||
}
|
|
||||||
|
|
||||||
const results = await Promise.all(promises);
|
|
||||||
|
|
||||||
if (results.some((res) => !res)) {
|
|
||||||
return notFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
organization: results[0] as Awaited<
|
|
||||||
ReturnType<typeof getOrganizationBySlug>
|
|
||||||
>,
|
|
||||||
project: results[1] as Awaited<ReturnType<typeof getProjectById>>,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user