mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
fix: pass team id to vanilla trpc client
This commit is contained in:
@ -50,9 +50,16 @@ export const DataTableActionButton = ({ row, team }: DataTableActionButtonProps)
|
|||||||
const onDownloadClick = async () => {
|
const onDownloadClick = async () => {
|
||||||
try {
|
try {
|
||||||
const document = !recipient
|
const document = !recipient
|
||||||
? await trpcClient.document.getDocumentById.query({
|
? await trpcClient.document.getDocumentById.query(
|
||||||
|
{
|
||||||
documentId: row.id,
|
documentId: row.id,
|
||||||
})
|
},
|
||||||
|
{
|
||||||
|
context: {
|
||||||
|
teamId: team?.id?.toString(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
: await trpcClient.document.getDocumentByToken.query({
|
: await trpcClient.document.getDocumentByToken.query({
|
||||||
token: recipient.token,
|
token: recipient.token,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -12,10 +12,32 @@ export const trpc = createTRPCClient<AppRouter>({
|
|||||||
true: httpLink({
|
true: httpLink({
|
||||||
url: `${getBaseUrl()}/api/trpc`,
|
url: `${getBaseUrl()}/api/trpc`,
|
||||||
transformer: SuperJSON,
|
transformer: SuperJSON,
|
||||||
|
headers: (opts) => {
|
||||||
|
if (typeof opts.op.context.teamId === 'string') {
|
||||||
|
return {
|
||||||
|
'x-team-id': opts.op.context.teamId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
false: httpBatchLink({
|
false: httpBatchLink({
|
||||||
url: `${getBaseUrl()}/api/trpc`,
|
url: `${getBaseUrl()}/api/trpc`,
|
||||||
transformer: SuperJSON,
|
transformer: SuperJSON,
|
||||||
|
headers: (opts) => {
|
||||||
|
const operationWithTeamId = opts.opList.find(
|
||||||
|
(op) => op.context.teamId && typeof op.context.teamId === 'string',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (operationWithTeamId && typeof operationWithTeamId.context.teamId === 'string') {
|
||||||
|
return {
|
||||||
|
'x-team-id': operationWithTeamId.context.teamId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user