mirror of
https://github.com/hanzoai/sign.git
synced 2026-10-21 01:21:51 +00:00
The product is branded Hanzo eSign (esign.hanzo.ai, repo hanzoai/esign). Rename all workspace packages @hanzo/sign-* → @hanzo/esign-* (1052 files) and align docker/Dockerfile turbo --scope/--filter to the actual remix package name @hanzo/esign (was a pre-existing mismatch with -remix that broke the build). Protected deps (@hanzo/insights, @hanzo/logo) untouched.
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import { prisma } from '@hanzo/esign-prisma';
|
|
|
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
|
import { buildTeamWhereQuery, extractDerivedTeamSettings } from '../../utils/teams';
|
|
|
|
export type GetTeamSettingsOptions = {
|
|
userId?: number;
|
|
teamId: number;
|
|
};
|
|
|
|
/**
|
|
* You must provide userId if you want to validate whether the user can access the team settings.
|
|
*/
|
|
export const getTeamSettings = async ({ userId, teamId }: GetTeamSettingsOptions) => {
|
|
const team = await prisma.team.findFirst({
|
|
where: userId !== undefined ? buildTeamWhereQuery({ teamId, userId }) : { id: teamId },
|
|
include: {
|
|
organisation: {
|
|
include: {
|
|
organisationGlobalSettings: true,
|
|
},
|
|
},
|
|
teamGlobalSettings: true,
|
|
},
|
|
});
|
|
|
|
if (!team) {
|
|
throw new AppError(AppErrorCode.NOT_FOUND, {
|
|
message: 'Team not found',
|
|
});
|
|
}
|
|
|
|
const organisationSettings = team.organisation.organisationGlobalSettings;
|
|
const teamSettings = team.teamGlobalSettings;
|
|
|
|
// Override branding settings if inherit is enabled.
|
|
if (teamSettings.brandingEnabled === null) {
|
|
teamSettings.brandingEnabled = organisationSettings.brandingEnabled;
|
|
teamSettings.brandingLogo = organisationSettings.brandingLogo;
|
|
teamSettings.brandingUrl = organisationSettings.brandingUrl;
|
|
teamSettings.brandingCompanyDetails = organisationSettings.brandingCompanyDetails;
|
|
}
|
|
|
|
return extractDerivedTeamSettings(organisationSettings, teamSettings);
|
|
};
|