review(front): refacto url-manager (#8861)
Replace https://github.com/twentyhq/twenty/pull/8855
This commit is contained in:
@ -0,0 +1,29 @@
|
||||
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
||||
import { lastAuthenticatedWorkspaceDomainState } from '@/domain-manager/states/lastAuthenticatedWorkspaceDomainState';
|
||||
import { domainConfigurationState } from '@/domain-manager/states/domainConfigurationState';
|
||||
|
||||
export const useLastAuthenticatedWorkspaceDomain = () => {
|
||||
const domainConfiguration = useRecoilValue(domainConfigurationState);
|
||||
const setLastAuthenticatedWorkspaceDomain = useSetRecoilState(
|
||||
lastAuthenticatedWorkspaceDomainState,
|
||||
);
|
||||
const setLastAuthenticateWorkspaceDomainWithCookieAttributes = (
|
||||
params: { workspaceId: string; subdomain: string } | null,
|
||||
) => {
|
||||
setLastAuthenticatedWorkspaceDomain(
|
||||
params
|
||||
? {
|
||||
...params,
|
||||
cookieAttributes: {
|
||||
domain: `.${domainConfiguration.frontDomain}`,
|
||||
},
|
||||
}
|
||||
: null,
|
||||
);
|
||||
};
|
||||
|
||||
return {
|
||||
setLastAuthenticateWorkspaceDomain:
|
||||
setLastAuthenticateWorkspaceDomainWithCookieAttributes,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user