mirror of
https://github.com/documenso/documenso.git
synced 2025-11-23 13:11:32 +10:00
fix: wip
This commit is contained in:
@ -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