mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 15:53:02 +10:00
Merge branch 'main' into feat/typeInDeletion
This commit is contained in:
@ -25,7 +25,11 @@ type TemplateWithRecipient = Template & {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type TemplatesDataTableProps = {
|
type TemplatesDataTableProps = {
|
||||||
templates: TemplateWithRecipient[];
|
templates: Array<
|
||||||
|
TemplateWithRecipient & {
|
||||||
|
team: { id: number; url: string } | null;
|
||||||
|
}
|
||||||
|
>;
|
||||||
perPage: number;
|
perPage: number;
|
||||||
page: number;
|
page: number;
|
||||||
totalPages: number;
|
totalPages: number;
|
||||||
|
|||||||
@ -1,23 +1,35 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
|
|
||||||
import { useSession } from 'next-auth/react';
|
import { useSession } from 'next-auth/react';
|
||||||
|
|
||||||
import { Template } from '@documenso/prisma/client';
|
import { formatTemplatesPath } from '@documenso/lib/utils/teams';
|
||||||
|
import type { Template } from '@documenso/prisma/client';
|
||||||
|
|
||||||
|
import { useOptionalCurrentTeam } from '~/providers/team';
|
||||||
|
|
||||||
export type DataTableTitleProps = {
|
export type DataTableTitleProps = {
|
||||||
row: Template;
|
row: Template & {
|
||||||
|
team: { id: number; url: string } | null;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DataTableTitle = ({ row }: DataTableTitleProps) => {
|
export const DataTableTitle = ({ row }: DataTableTitleProps) => {
|
||||||
const { data: session } = useSession();
|
const { data: session } = useSession();
|
||||||
|
const team = useOptionalCurrentTeam();
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isCurrentTeamTemplate = team?.url && row.team?.url === team?.url;
|
||||||
|
|
||||||
|
const templatesPath = formatTemplatesPath(isCurrentTeamTemplate ? team?.url : undefined);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
href={`/templates/${row.id}`}
|
href={`${templatesPath}/${row.id}`}
|
||||||
className="block max-w-[10rem] cursor-pointer truncate font-medium hover:underline md:max-w-[20rem]"
|
className="block max-w-[10rem] cursor-pointer truncate font-medium hover:underline md:max-w-[20rem]"
|
||||||
>
|
>
|
||||||
{row.title}
|
{row.title}
|
||||||
|
|||||||
@ -37,6 +37,12 @@ export const findTemplates = async ({
|
|||||||
where: whereFilter,
|
where: whereFilter,
|
||||||
include: {
|
include: {
|
||||||
templateDocumentData: true,
|
templateDocumentData: true,
|
||||||
|
team: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
url: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
Field: true,
|
Field: true,
|
||||||
Recipient: true,
|
Recipient: true,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user