Introduce ComponentState (#4386)
* Proof of concept ComponentState * Migrate to createState and createFamilyState * Refactor * Fix * Fix tests * Fix lint * Fix tests * Re-enable coverage
This commit is contained in:
@ -15,17 +15,17 @@ import { isNonNullable } from '~/utils/isNonNullable';
|
||||
export const ClientConfigProvider: React.FC<React.PropsWithChildren> = ({
|
||||
children,
|
||||
}) => {
|
||||
const setAuthProviders = useSetRecoilState(authProvidersState);
|
||||
const setIsDebugMode = useSetRecoilState(isDebugModeState);
|
||||
const setAuthProviders = useSetRecoilState(authProvidersState());
|
||||
const setIsDebugMode = useSetRecoilState(isDebugModeState());
|
||||
|
||||
const setIsSignInPrefilled = useSetRecoilState(isSignInPrefilledState);
|
||||
const setIsSignUpDisabled = useSetRecoilState(isSignUpDisabledState);
|
||||
const setIsSignInPrefilled = useSetRecoilState(isSignInPrefilledState());
|
||||
const setIsSignUpDisabled = useSetRecoilState(isSignUpDisabledState());
|
||||
|
||||
const setBilling = useSetRecoilState(billingState);
|
||||
const setTelemetry = useSetRecoilState(telemetryState);
|
||||
const setSupportChat = useSetRecoilState(supportChatState);
|
||||
const setBilling = useSetRecoilState(billingState());
|
||||
const setTelemetry = useSetRecoilState(telemetryState());
|
||||
const setSupportChat = useSetRecoilState(supportChatState());
|
||||
|
||||
const setSentryConfig = useSetRecoilState(sentryConfigState);
|
||||
const setSentryConfig = useSetRecoilState(sentryConfigState());
|
||||
|
||||
const { data, loading } = useGetClientConfigQuery();
|
||||
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
import { createState } from '@/ui/utilities/state/utils/createState';
|
||||
import { AuthProviders } from '~/generated/graphql';
|
||||
|
||||
export const authProvidersState = atom<AuthProviders>({
|
||||
export const authProvidersState = createState<AuthProviders>({
|
||||
key: 'authProvidersState',
|
||||
default: { google: false, magicLink: false, password: true },
|
||||
defaultValue: { google: false, magicLink: false, password: true },
|
||||
});
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
import { createState } from '@/ui/utilities/state/utils/createState';
|
||||
import { Billing } from '~/generated/graphql';
|
||||
|
||||
export const billingState = atom<Billing | null>({
|
||||
export const billingState = createState<Billing | null>({
|
||||
key: 'billingState',
|
||||
default: null,
|
||||
defaultValue: null,
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { atom } from 'recoil';
|
||||
import { createState } from '@/ui/utilities/state/utils/createState';
|
||||
|
||||
export const isDebugModeState = atom<boolean>({
|
||||
export const isDebugModeState = createState<boolean>({
|
||||
key: 'isDebugModeState',
|
||||
default: false,
|
||||
defaultValue: false,
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { atom } from 'recoil';
|
||||
import { createState } from '@/ui/utilities/state/utils/createState';
|
||||
|
||||
export const isSignInPrefilledState = atom<boolean>({
|
||||
export const isSignInPrefilledState = createState<boolean>({
|
||||
key: 'isSignInPrefilledState',
|
||||
default: false,
|
||||
defaultValue: false,
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { atom } from 'recoil';
|
||||
import { createState } from '@/ui/utilities/state/utils/createState';
|
||||
|
||||
export const isSignUpDisabledState = atom<boolean>({
|
||||
export const isSignUpDisabledState = createState<boolean>({
|
||||
key: 'isSignUpDisabledState',
|
||||
default: false,
|
||||
defaultValue: false,
|
||||
});
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
import { createState } from '@/ui/utilities/state/utils/createState';
|
||||
import { Sentry } from '~/generated/graphql';
|
||||
|
||||
export const sentryConfigState = atom<Sentry | null>({
|
||||
export const sentryConfigState = createState<Sentry | null>({
|
||||
key: 'sentryConfigState',
|
||||
default: null,
|
||||
defaultValue: null,
|
||||
});
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
import { createState } from '@/ui/utilities/state/utils/createState';
|
||||
import { Support } from '~/generated/graphql';
|
||||
|
||||
export const supportChatState = atom<Support>({
|
||||
export const supportChatState = createState<Support>({
|
||||
key: 'supportChatState',
|
||||
default: {
|
||||
defaultValue: {
|
||||
supportDriver: 'none',
|
||||
supportFrontChatId: null,
|
||||
},
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
import { createState } from '@/ui/utilities/state/utils/createState';
|
||||
import { Telemetry } from '~/generated/graphql';
|
||||
|
||||
export const telemetryState = atom<Telemetry>({
|
||||
export const telemetryState = createState<Telemetry>({
|
||||
key: 'telemetryState',
|
||||
default: { enabled: true, anonymizationEnabled: true },
|
||||
defaultValue: { enabled: true, anonymizationEnabled: true },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user