Files
twenty/packages/twenty-front/src/modules/users/components/UserProvider.tsx
T
Antoine Moreaux a85c4f263a fix(settings routing): handle trailing slashes in base paths (#10055)
Adjusted URL construction to properly handle trailing slashes in base
paths, ensuring consistent matching logic. Added logic for setting the
hotkey scope when navigating to the domain settings path.
2025-02-06 16:07:19 +00:00

32 lines
1.1 KiB
TypeScript

import React from 'react';
import { useRecoilValue } from 'recoil';
import { isCurrentUserLoadedState } from '@/auth/states/isCurrentUserLoadingState';
import { dateTimeFormatState } from '@/localization/states/dateTimeFormatState';
import { AppPath } from '@/types/AppPath';
import { UserContext } from '@/users/contexts/UserContext';
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
import { UserOrMetadataLoader } from '~/loading/components/UserOrMetadataLoader';
export const UserProvider = ({ children }: React.PropsWithChildren) => {
const isCurrentUserLoaded = useRecoilValue(isCurrentUserLoadedState);
const { isMatchingLocation } = useIsMatchingLocation();
const dateTimeFormat = useRecoilValue(dateTimeFormatState);
return !isCurrentUserLoaded &&
!isMatchingLocation(AppPath.CreateWorkspace) ? (
<UserOrMetadataLoader />
) : (
<UserContext.Provider
value={{
dateFormat: dateTimeFormat.dateFormat,
timeFormat: dateTimeFormat.timeFormat,
timeZone: dateTimeFormat.timeZone,
}}
>
{children}
</UserContext.Provider>
);
};