# Content - Introduce the `workspaceUrls` property. It contains two sub-properties: `customUrl, subdomainUrl`. These endpoints are used to access the workspace. Even if the `workspaceUrls` is invalid for multiple reasons, the `subdomainUrl` remains valid. - Introduce `ResolveField` workspaceEndpoints to avoid unnecessary URL computation on the frontend part. - Add a `forceSubdomainUrl` to avoid custom URL using a query parameter
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { isMultiWorkspaceEnabledState } from '@/client-config/states/isMultiWorkspaceEnabledState';
|
|
import { useReadDefaultDomainFromConfiguration } from '@/domain-manager/hooks/useReadDefaultDomainFromConfiguration';
|
|
import { domainConfigurationState } from '@/domain-manager/states/domainConfigurationState';
|
|
import { useRecoilValue } from 'recoil';
|
|
import { isDefined } from 'twenty-shared';
|
|
|
|
export const useIsCurrentLocationOnAWorkspace = () => {
|
|
const { defaultDomain } = useReadDefaultDomainFromConfiguration();
|
|
|
|
const isMultiWorkspaceEnabled = useRecoilValue(isMultiWorkspaceEnabledState);
|
|
const domainConfiguration = useRecoilValue(domainConfigurationState);
|
|
|
|
if (
|
|
isMultiWorkspaceEnabled &&
|
|
(!isDefined(domainConfiguration.frontDomain) ||
|
|
!isDefined(domainConfiguration.defaultSubdomain))
|
|
) {
|
|
throw new Error('frontDomain and defaultSubdomain are required');
|
|
}
|
|
|
|
const isOnAWorkspace =
|
|
isMultiWorkspaceEnabled && window.location.hostname !== defaultDomain;
|
|
|
|
return {
|
|
isOnAWorkspace,
|
|
};
|
|
};
|