diff --git a/frontend/src/app/ABTestWrapper.js b/frontend/src/app/ABTestWrapper.js index 9c7d45ab66..6d1177b928 100644 --- a/frontend/src/app/ABTestWrapper.js +++ b/frontend/src/app/ABTestWrapper.js @@ -1,30 +1,20 @@ import React from 'react' import { any, string } from 'prop-types' import { useUserVar } from '../utilities/userState' -import { IS_USER_SUPER_ADMIN } from '../graphql/queries' -import { useQuery } from '@apollo/client' - -const isInsiderUser = ({ isUserSuperAdmin, insideUser }) => { - return insideUser || isUserSuperAdmin -} export function ABTestVariant({ children }) { return <>{children} } export function ABTestWrapper({ children, insiderVariantName = 'B' }) { - const { data } = useQuery(IS_USER_SUPER_ADMIN) - const { currentUser } = useUserVar() + const { + currentUser: { insideUser }, + } = useUserVar() let childIndex = 0 // only one variant if (!children.length) { - if ( - isInsiderUser({ - isUserSuperAdmin: data?.isUserSuperAdmin || false, - insideUser: currentUser?.insideUser || false, - }) - ) { + if (insideUser) { if (children.props.name === insiderVariantName) return <>{children} else return <> } else { @@ -33,12 +23,7 @@ export function ABTestWrapper({ children, insiderVariantName = 'B' }) { } } // A + B variants - if ( - isInsiderUser({ - isUserSuperAdmin: data?.isUserSuperAdmin || false, - insideUser: currentUser?.insideUser || false, - }) - ) { + if (insideUser) { childIndex = children.findIndex((variant) => variant.props.name === insiderVariantName) } else { childIndex = children.findIndex((variant) => variant.props.name !== insiderVariantName)