mirror of
https://github.com/documenso/documenso.git
synced 2025-11-20 03:32:14 +10:00
fix: wip
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
import { Outlet } from 'react-router';
|
||||
import { redirect } from 'react-router';
|
||||
import { Outlet, redirect } from 'react-router';
|
||||
|
||||
import { LimitsProvider } from '@documenso/ee/server-only/limits/provider/client';
|
||||
import { SessionProvider } from '@documenso/lib/client-only/providers/session';
|
||||
|
||||
import { Header } from '~/components/(dashboard)/layout/header';
|
||||
import { VerifyEmailBanner } from '~/components/(dashboard)/layout/verify-email-banner';
|
||||
@ -13,33 +11,30 @@ export const loader = ({ context }: Route.LoaderArgs) => {
|
||||
const { session } = context;
|
||||
|
||||
if (!session) {
|
||||
return redirect('/signin');
|
||||
throw redirect('/signin');
|
||||
}
|
||||
|
||||
return {
|
||||
user: session.user,
|
||||
session: session.session,
|
||||
teams: session.teams,
|
||||
};
|
||||
};
|
||||
|
||||
export default function Layout({ loaderData }: Route.ComponentProps) {
|
||||
const { user, session, teams } = loaderData;
|
||||
const { user, teams } = loaderData;
|
||||
|
||||
return (
|
||||
<SessionProvider session={session} user={user}>
|
||||
<LimitsProvider>
|
||||
{!user.emailVerified && <VerifyEmailBanner email={user.email} />}
|
||||
<LimitsProvider>
|
||||
{!user.emailVerified && <VerifyEmailBanner email={user.email} />}
|
||||
|
||||
{/* // Todo: Banner */}
|
||||
{/* <Banner /> */}
|
||||
{/* // Todo: Banner */}
|
||||
{/* <Banner /> */}
|
||||
|
||||
<Header user={user} teams={teams} />
|
||||
<Header user={user} teams={teams} />
|
||||
|
||||
<main className="mt-8 pb-8 md:mt-12 md:pb-12">
|
||||
<Outlet />
|
||||
</main>
|
||||
</LimitsProvider>
|
||||
</SessionProvider>
|
||||
<main className="mt-8 pb-8 md:mt-12 md:pb-12">
|
||||
<Outlet />
|
||||
</main>
|
||||
</LimitsProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { redirect } from 'react-router';
|
||||
|
||||
export function loader() {
|
||||
return redirect('/admin/stats');
|
||||
throw redirect('/admin/stats');
|
||||
}
|
||||
|
||||
export default function AdminPage() {
|
||||
|
||||
@ -13,7 +13,7 @@ export function loader({ context }: Route.LoaderArgs) {
|
||||
const { user } = getRequiredSessionContext(context);
|
||||
|
||||
if (!user || !isAdmin(user)) {
|
||||
return redirect('/documents');
|
||||
throw redirect('/documents');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ export async function loader({ params }: Route.LoaderArgs) {
|
||||
// Todo: Is it possible for this to return data to the frontend w/out auth layout due to race condition?
|
||||
|
||||
if (isNaN(id)) {
|
||||
return redirect('/admin/documents');
|
||||
throw redirect('/admin/documents');
|
||||
}
|
||||
|
||||
const document = await getEntireDocument({ id });
|
||||
|
||||
@ -1,19 +1,16 @@
|
||||
import { Plural, Trans } from '@lingui/macro';
|
||||
import { useLingui } from '@lingui/react';
|
||||
import { DocumentStatus } from '@prisma/client';
|
||||
import { TeamMemberRole } from '@prisma/client';
|
||||
import { DocumentStatus, TeamMemberRole } from '@prisma/client';
|
||||
import { ChevronLeft, Clock9, Users2 } from 'lucide-react';
|
||||
import { Link, redirect } from 'react-router';
|
||||
import { getRequiredSessionContext } from 'server/utils/get-required-session-context';
|
||||
import { match } from 'ts-pattern';
|
||||
|
||||
import { useSession } from '@documenso/lib/client-only/providers/session';
|
||||
import { DOCUMENSO_ENCRYPTION_KEY } from '@documenso/lib/constants/crypto';
|
||||
import { getDocumentById } from '@documenso/lib/server-only/document/get-document-by-id';
|
||||
import { getFieldsForDocument } from '@documenso/lib/server-only/field/get-fields-for-document';
|
||||
import { getRecipientsForDocument } from '@documenso/lib/server-only/recipient/get-recipients-for-document';
|
||||
import { DocumentVisibility } from '@documenso/lib/types/document-visibility';
|
||||
import { symmetricDecrypt } from '@documenso/lib/universal/crypto';
|
||||
import { formatDocumentsPath } from '@documenso/lib/utils/teams';
|
||||
import { Badge } from '@documenso/ui/primitives/badge';
|
||||
import { Button } from '@documenso/ui/primitives/button';
|
||||
@ -28,11 +25,11 @@ import {
|
||||
DocumentStatus as DocumentStatusComponent,
|
||||
FRIENDLY_STATUS_MAP,
|
||||
} from '~/components/formatter/document-status';
|
||||
import { DocumentPageViewButton } from '~/components/pages/document/document-page-view-button';
|
||||
import { DocumentPageViewDropdown } from '~/components/pages/document/document-page-view-dropdown';
|
||||
import { DocumentPageViewInformation } from '~/components/pages/document/document-page-view-information';
|
||||
import { DocumentPageViewRecentActivity } from '~/components/pages/document/document-page-view-recent-activity';
|
||||
import { DocumentPageViewRecipients } from '~/components/pages/document/document-page-view-recipients';
|
||||
import { DocumentPageViewButton } from '~/components/general/document/document-page-view-button';
|
||||
import { DocumentPageViewDropdown } from '~/components/general/document/document-page-view-dropdown';
|
||||
import { DocumentPageViewInformation } from '~/components/general/document/document-page-view-information';
|
||||
import { DocumentPageViewRecentActivity } from '~/components/general/document/document-page-view-recent-activity';
|
||||
import { DocumentPageViewRecipients } from '~/components/general/document/document-page-view-recipients';
|
||||
|
||||
import type { Route } from './+types/$id._index';
|
||||
|
||||
@ -46,7 +43,7 @@ export async function loader({ params, context }: Route.LoaderArgs) {
|
||||
const documentRootPath = formatDocumentsPath(team?.url);
|
||||
|
||||
if (!documentId || Number.isNaN(documentId)) {
|
||||
return redirect(documentRootPath);
|
||||
throw redirect(documentRootPath);
|
||||
}
|
||||
|
||||
const document = await getDocumentById({
|
||||
@ -56,7 +53,7 @@ export async function loader({ params, context }: Route.LoaderArgs) {
|
||||
}).catch(() => null);
|
||||
|
||||
if (document?.teamId && !team?.url) {
|
||||
return redirect(documentRootPath);
|
||||
throw redirect(documentRootPath);
|
||||
}
|
||||
|
||||
const documentVisibility = document?.visibility;
|
||||
@ -76,31 +73,32 @@ export async function loader({ params, context }: Route.LoaderArgs) {
|
||||
}
|
||||
|
||||
if (!document || !document.documentData || (team && !canAccessDocument)) {
|
||||
return redirect(documentRootPath);
|
||||
throw redirect(documentRootPath);
|
||||
}
|
||||
|
||||
if (team && !canAccessDocument) {
|
||||
return redirect(documentRootPath);
|
||||
throw redirect(documentRootPath);
|
||||
}
|
||||
|
||||
const { documentMeta } = document;
|
||||
|
||||
if (documentMeta?.password) {
|
||||
const key = DOCUMENSO_ENCRYPTION_KEY;
|
||||
// Todo: We don't handle encrypted files right.
|
||||
// if (documentMeta?.password) {
|
||||
// const key = DOCUMENSO_ENCRYPTION_KEY;
|
||||
|
||||
if (!key) {
|
||||
throw new Error('Missing DOCUMENSO_ENCRYPTION_KEY');
|
||||
}
|
||||
// if (!key) {
|
||||
// throw new Error('Missing DOCUMENSO_ENCRYPTION_KEY');
|
||||
// }
|
||||
|
||||
const securePassword = Buffer.from(
|
||||
symmetricDecrypt({
|
||||
key,
|
||||
data: documentMeta.password,
|
||||
}),
|
||||
).toString('utf-8');
|
||||
// const securePassword = Buffer.from(
|
||||
// symmetricDecrypt({
|
||||
// key,
|
||||
// data: documentMeta.password,
|
||||
// }),
|
||||
// ).toString('utf-8');
|
||||
|
||||
documentMeta.password = securePassword;
|
||||
}
|
||||
// documentMeta.password = securePassword;
|
||||
// }
|
||||
|
||||
// Todo: Get full document instead???
|
||||
const [recipients, fields] = await Promise.all([
|
||||
|
||||
@ -1,21 +1,19 @@
|
||||
import { Plural, Trans } from '@lingui/macro';
|
||||
import { TeamMemberRole } from '@prisma/client';
|
||||
import { DocumentStatus as InternalDocumentStatus } from '@prisma/client';
|
||||
import { DocumentStatus as InternalDocumentStatus, TeamMemberRole } from '@prisma/client';
|
||||
import { ChevronLeft, Users2 } from 'lucide-react';
|
||||
import { Link, redirect } from 'react-router';
|
||||
import { getRequiredSessionContext } from 'server/utils/get-required-session-context';
|
||||
import { match } from 'ts-pattern';
|
||||
|
||||
import { isUserEnterprise } from '@documenso/ee/server-only/util/is-document-enterprise';
|
||||
import { DOCUMENSO_ENCRYPTION_KEY } from '@documenso/lib/constants/crypto';
|
||||
import { getDocumentWithDetailsById } from '@documenso/lib/server-only/document/get-document-with-details-by-id';
|
||||
import { DocumentVisibility } from '@documenso/lib/types/document-visibility';
|
||||
import { symmetricDecrypt } from '@documenso/lib/universal/crypto';
|
||||
import { formatDocumentsPath } from '@documenso/lib/utils/teams';
|
||||
|
||||
import { StackAvatarsWithTooltip } from '~/components/(dashboard)/avatar/stack-avatars-with-tooltip';
|
||||
import { DocumentStatus } from '~/components/formatter/document-status';
|
||||
import { DocumentEditForm } from '~/components/pages/document/document-edit-form';
|
||||
import { DocumentEditForm } from '~/components/general/document/document-edit-form';
|
||||
import { superLoaderJson, useSuperLoaderData } from '~/utils/super-json-loader';
|
||||
|
||||
import type { Route } from './+types/$id.edit';
|
||||
|
||||
@ -29,7 +27,7 @@ export async function loader({ params, context }: Route.LoaderArgs) {
|
||||
const documentRootPath = formatDocumentsPath(team?.url);
|
||||
|
||||
if (!documentId || Number.isNaN(documentId)) {
|
||||
return redirect(documentRootPath);
|
||||
throw redirect(documentRootPath);
|
||||
}
|
||||
|
||||
const document = await getDocumentWithDetailsById({
|
||||
@ -39,7 +37,7 @@ export async function loader({ params, context }: Route.LoaderArgs) {
|
||||
}).catch(() => null);
|
||||
|
||||
if (document?.teamId && !team?.url) {
|
||||
return redirect(documentRootPath);
|
||||
throw redirect(documentRootPath);
|
||||
}
|
||||
|
||||
const documentVisibility = document?.visibility;
|
||||
@ -59,50 +57,49 @@ export async function loader({ params, context }: Route.LoaderArgs) {
|
||||
}
|
||||
|
||||
if (!document) {
|
||||
return redirect(documentRootPath);
|
||||
throw redirect(documentRootPath);
|
||||
}
|
||||
|
||||
if (team && !canAccessDocument) {
|
||||
return redirect(documentRootPath);
|
||||
throw redirect(documentRootPath);
|
||||
}
|
||||
|
||||
if (document.status === InternalDocumentStatus.COMPLETED) {
|
||||
return redirect(`${documentRootPath}/${documentId}`);
|
||||
throw redirect(`${documentRootPath}/${documentId}`);
|
||||
}
|
||||
|
||||
const { documentMeta, recipients } = document;
|
||||
// Todo: We don't handle encrypted files right.
|
||||
// if (documentMeta?.password) {
|
||||
// const key = DOCUMENSO_ENCRYPTION_KEY;
|
||||
|
||||
if (documentMeta?.password) {
|
||||
const key = DOCUMENSO_ENCRYPTION_KEY;
|
||||
// if (!key) {
|
||||
// throw new Error('Missing DOCUMENSO_ENCRYPTION_KEY');
|
||||
// }
|
||||
|
||||
if (!key) {
|
||||
throw new Error('Missing DOCUMENSO_ENCRYPTION_KEY');
|
||||
}
|
||||
// const securePassword = Buffer.from(
|
||||
// symmetricDecrypt({
|
||||
// key,
|
||||
// data: documentMeta.password,
|
||||
// }),
|
||||
// ).toString('utf-8');
|
||||
|
||||
const securePassword = Buffer.from(
|
||||
symmetricDecrypt({
|
||||
key,
|
||||
data: documentMeta.password,
|
||||
}),
|
||||
).toString('utf-8');
|
||||
|
||||
documentMeta.password = securePassword;
|
||||
}
|
||||
// documentMeta.password = securePassword;
|
||||
// }
|
||||
|
||||
const isDocumentEnterprise = await isUserEnterprise({
|
||||
userId: user.id,
|
||||
teamId: team?.id,
|
||||
});
|
||||
|
||||
return {
|
||||
return superLoaderJson({
|
||||
document,
|
||||
documentRootPath,
|
||||
isDocumentEnterprise,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export default function DocumentEditPage({ loaderData }: Route.ComponentProps) {
|
||||
const { document, documentRootPath, isDocumentEnterprise } = loaderData;
|
||||
export default function DocumentEditPage() {
|
||||
const { document, documentRootPath, isDocumentEnterprise } = useSuperLoaderData<typeof loader>();
|
||||
|
||||
const { recipients } = document;
|
||||
|
||||
|
||||
@ -7,19 +7,17 @@ import { DateTime } from 'luxon';
|
||||
import { Link, redirect } from 'react-router';
|
||||
import { getRequiredSessionContext } from 'server/utils/get-required-session-context';
|
||||
|
||||
import { getRequiredSession } from '@documenso/auth/server/lib/utils/get-session';
|
||||
import { getDocumentById } from '@documenso/lib/server-only/document/get-document-by-id';
|
||||
import { getRecipientsForDocument } from '@documenso/lib/server-only/recipient/get-recipients-for-document';
|
||||
import { formatDocumentsPath } from '@documenso/lib/utils/teams';
|
||||
import { prisma } from '@documenso/prisma';
|
||||
import { Card } from '@documenso/ui/primitives/card';
|
||||
|
||||
import {
|
||||
DocumentStatus as DocumentStatusComponent,
|
||||
FRIENDLY_STATUS_MAP,
|
||||
} from '~/components/formatter/document-status';
|
||||
import { DocumentAuditLogDownloadButton } from '~/components/pages/document/document-audit-log-download-button';
|
||||
import { DocumentCertificateDownloadButton } from '~/components/pages/document/document-certificate-download-button';
|
||||
import { DocumentAuditLogDownloadButton } from '~/components/general/document/document-audit-log-download-button';
|
||||
import { DocumentCertificateDownloadButton } from '~/components/general/document/document-certificate-download-button';
|
||||
import { DocumentLogsTable } from '~/components/tables/document-logs-table';
|
||||
|
||||
import type { Route } from './+types/$id.logs';
|
||||
@ -34,7 +32,7 @@ export async function loader({ params, context }: Route.LoaderArgs) {
|
||||
const documentRootPath = formatDocumentsPath(team?.url);
|
||||
|
||||
if (!documentId || Number.isNaN(documentId)) {
|
||||
return redirect(documentRootPath);
|
||||
throw redirect(documentRootPath);
|
||||
}
|
||||
|
||||
// Todo: Get detailed?
|
||||
@ -52,7 +50,7 @@ export async function loader({ params, context }: Route.LoaderArgs) {
|
||||
]);
|
||||
|
||||
if (!document || !document.documentData) {
|
||||
return redirect(documentRootPath);
|
||||
throw redirect(documentRootPath);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { redirect } from 'react-router';
|
||||
|
||||
export function loader() {
|
||||
return redirect('/settings/profile');
|
||||
throw redirect('/settings/profile');
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ export const loader = ({ context }: Route.LoaderArgs) => {
|
||||
const { currentTeam } = getRequiredSessionContext(context);
|
||||
|
||||
if (!currentTeam) {
|
||||
return redirect('/documents');
|
||||
throw redirect('/documents');
|
||||
}
|
||||
|
||||
const trpcHeaders = {
|
||||
|
||||
@ -15,8 +15,8 @@ import { TeamDeleteDialog } from '~/components/dialogs/team-delete-dialog';
|
||||
import { TeamEmailAddDialog } from '~/components/dialogs/team-email-add-dialog';
|
||||
import { TeamTransferDialog } from '~/components/dialogs/team-transfer-dialog';
|
||||
import { AvatarImageForm } from '~/components/forms/avatar-image';
|
||||
import { TeamEmailDropdown } from '~/components/pages/teams/team-email-dropdown';
|
||||
import { TeamTransferStatus } from '~/components/pages/teams/team-transfer-status';
|
||||
import { TeamEmailDropdown } from '~/components/general/teams/team-email-dropdown';
|
||||
import { TeamTransferStatus } from '~/components/general/teams/team-transfer-status';
|
||||
import { useCurrentTeam } from '~/providers/team';
|
||||
|
||||
export default function TeamsSettingsPage() {
|
||||
|
||||
@ -4,8 +4,8 @@ import { getRequiredTeamSessionContext } from 'server/utils/get-required-session
|
||||
|
||||
import { canExecuteTeamAction } from '@documenso/lib/utils/teams';
|
||||
|
||||
import { TeamSettingsDesktopNav } from '~/components/pages/teams/team-settings-desktop-nav';
|
||||
import { TeamSettingsMobileNav } from '~/components/pages/teams/team-settings-mobile-nav';
|
||||
import { TeamSettingsDesktopNav } from '~/components/general/teams/team-settings-desktop-nav';
|
||||
import { TeamSettingsMobileNav } from '~/components/general/teams/team-settings-mobile-nav';
|
||||
|
||||
import type { Route } from '../+types/_layout';
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ import { Card, CardContent } from '@documenso/ui/primitives/card';
|
||||
|
||||
import { SettingsHeader } from '~/components/(dashboard)/settings/layout/header';
|
||||
import { TeamBillingInvoicesDataTable } from '~/components/(teams)/tables/team-billing-invoices-data-table';
|
||||
import { TeamBillingPortalButton } from '~/components/pages/teams/team-billing-portal-button';
|
||||
import { TeamBillingPortalButton } from '~/components/general/teams/team-billing-portal-button';
|
||||
|
||||
import type { Route } from './+types/billing';
|
||||
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
import { Trans } from '@lingui/macro';
|
||||
import { DocumentSigningOrder, SigningStatus, type Team } from '@prisma/client';
|
||||
import { DocumentSigningOrder, SigningStatus } from '@prisma/client';
|
||||
import { ChevronLeft, LucideEdit } from 'lucide-react';
|
||||
import { Link, redirect } from 'react-router';
|
||||
import { getRequiredSessionContext } from 'server/utils/get-required-session-context';
|
||||
|
||||
import { useSession } from '@documenso/lib/client-only/providers/session';
|
||||
import { getTemplateById } from '@documenso/lib/server-only/template/get-template-by-id';
|
||||
import { formatDocumentsPath, formatTemplatesPath } from '@documenso/lib/utils/teams';
|
||||
import { Button } from '@documenso/ui/primitives/button';
|
||||
@ -15,13 +14,13 @@ import { TemplateDirectLinkDialogWrapper } from '~/components/dialogs/template-d
|
||||
import { TemplateUseDialog } from '~/components/dialogs/template-use-dialog';
|
||||
import { DocumentReadOnlyFields } from '~/components/document/document-read-only-fields';
|
||||
import { TemplateType } from '~/components/formatter/template-type';
|
||||
import { TemplateDirectLinkBadge } from '~/components/pages/template/template-direct-link-badge';
|
||||
import { TemplatePageViewDocumentsTable } from '~/components/pages/template/template-page-view-documents-table';
|
||||
import { TemplatePageViewInformation } from '~/components/pages/template/template-page-view-information';
|
||||
import { TemplatePageViewRecentActivity } from '~/components/pages/template/template-page-view-recent-activity';
|
||||
import { TemplatePageViewRecipients } from '~/components/pages/template/template-page-view-recipients';
|
||||
import { TemplateDirectLinkBadge } from '~/components/general/template/template-direct-link-badge';
|
||||
import { TemplatePageViewDocumentsTable } from '~/components/general/template/template-page-view-documents-table';
|
||||
import { TemplatePageViewInformation } from '~/components/general/template/template-page-view-information';
|
||||
import { TemplatePageViewRecentActivity } from '~/components/general/template/template-page-view-recent-activity';
|
||||
import { TemplatePageViewRecipients } from '~/components/general/template/template-page-view-recipients';
|
||||
import { TemplatesTableActionDropdown } from '~/components/tables/templates-table-action-dropdown';
|
||||
import { useOptionalCurrentTeam } from '~/providers/team';
|
||||
import { superLoaderJson, useSuperLoaderData } from '~/utils/super-json-loader';
|
||||
|
||||
import type { Route } from './+types/$id._index';
|
||||
|
||||
@ -35,7 +34,7 @@ export async function loader({ params, context }: Route.LoaderArgs) {
|
||||
const documentRootPath = formatDocumentsPath(team?.url);
|
||||
|
||||
if (!templateId || Number.isNaN(templateId)) {
|
||||
return redirect(templateRootPath);
|
||||
throw redirect(templateRootPath);
|
||||
}
|
||||
|
||||
const template = await getTemplateById({
|
||||
@ -45,20 +44,21 @@ export async function loader({ params, context }: Route.LoaderArgs) {
|
||||
}).catch(() => null);
|
||||
|
||||
if (!template || !template.templateDocumentData || (template?.teamId && !team?.url)) {
|
||||
return redirect(templateRootPath);
|
||||
throw redirect(templateRootPath);
|
||||
}
|
||||
|
||||
return {
|
||||
return superLoaderJson({
|
||||
user,
|
||||
team,
|
||||
template,
|
||||
templateRootPath,
|
||||
documentRootPath,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export default function TemplatePage({ loaderData }: Route.ComponentProps) {
|
||||
const { user, team, template, templateRootPath, documentRootPath } = loaderData;
|
||||
export default function TemplatePage() {
|
||||
const { user, team, template, templateRootPath, documentRootPath } =
|
||||
useSuperLoaderData<typeof loader>();
|
||||
|
||||
const { templateDocumentData, fields, recipients, templateMeta } = template;
|
||||
|
||||
|
||||
@ -8,8 +8,9 @@ import { getTemplateById } from '@documenso/lib/server-only/template/get-templat
|
||||
import { formatTemplatesPath } from '@documenso/lib/utils/teams';
|
||||
|
||||
import { TemplateType } from '~/components/formatter/template-type';
|
||||
import { TemplateDirectLinkBadge } from '~/components/pages/template/template-direct-link-badge';
|
||||
import { TemplateEditForm } from '~/components/pages/template/template-edit-form';
|
||||
import { TemplateDirectLinkBadge } from '~/components/general/template/template-direct-link-badge';
|
||||
import { TemplateEditForm } from '~/components/general/template/template-edit-form';
|
||||
import { superLoaderJson, useSuperLoaderData } from '~/utils/super-json-loader';
|
||||
|
||||
import { TemplateDirectLinkDialogWrapper } from '../../../components/dialogs/template-direct-link-dialog-wrapper';
|
||||
import type { Route } from './+types/$id.edit';
|
||||
@ -23,7 +24,7 @@ export async function loader({ context, params }: Route.LoaderArgs) {
|
||||
const templateRootPath = formatTemplatesPath(team?.url);
|
||||
|
||||
if (!templateId || Number.isNaN(templateId)) {
|
||||
return redirect(templateRootPath);
|
||||
throw redirect(templateRootPath);
|
||||
}
|
||||
|
||||
const template = await getTemplateById({
|
||||
@ -33,7 +34,7 @@ export async function loader({ context, params }: Route.LoaderArgs) {
|
||||
}).catch(() => null);
|
||||
|
||||
if (!template || !template.templateDocumentData) {
|
||||
return redirect(templateRootPath);
|
||||
throw redirect(templateRootPath);
|
||||
}
|
||||
|
||||
const isTemplateEnterprise = await isUserEnterprise({
|
||||
@ -41,15 +42,15 @@ export async function loader({ context, params }: Route.LoaderArgs) {
|
||||
teamId: team?.id,
|
||||
});
|
||||
|
||||
return {
|
||||
return superLoaderJson({
|
||||
template,
|
||||
isTemplateEnterprise,
|
||||
templateRootPath,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export default function TemplateEditPage({ loaderData }: Route.ComponentProps) {
|
||||
const { template, isTemplateEnterprise, templateRootPath } = loaderData;
|
||||
export default function TemplateEditPage() {
|
||||
const { template, isTemplateEnterprise, templateRootPath } = useSuperLoaderData<typeof loader>();
|
||||
|
||||
return (
|
||||
<div className="mx-auto -mt-4 max-w-screen-xl px-4 md:px-8">
|
||||
|
||||
Reference in New Issue
Block a user