Refactor client config (#529)
* Refactor client config * Fix server tests * Fix lint
This commit is contained in:
@ -12,6 +12,7 @@ import { Logo } from '@/auth/components/ui/Logo';
|
||||
import { Title } from '@/auth/components/ui/Title';
|
||||
import { authFlowUserEmailState } from '@/auth/states/authFlowUserEmailState';
|
||||
import { isMockModeState } from '@/auth/states/isMockModeState';
|
||||
import { authProvidersState } from '@/client-config/states/authProvidersState';
|
||||
import { captureHotkeyTypeInFocusState } from '@/hotkeys/states/captureHotkeyTypeInFocusState';
|
||||
import { MainButton } from '@/ui/components/buttons/MainButton';
|
||||
import { TextInput } from '@/ui/components/inputs/TextInput';
|
||||
@ -36,6 +37,8 @@ export function Index() {
|
||||
const navigate = useNavigate();
|
||||
const theme = useTheme();
|
||||
const [, setMockMode] = useRecoilState(isMockModeState);
|
||||
const [authProviders] = useRecoilState(authProvidersState);
|
||||
const [demoMode] = useRecoilState(authProvidersState);
|
||||
|
||||
const [authFlowUserEmail, setAuthFlowUserEmail] = useRecoilState(
|
||||
authFlowUserEmailState,
|
||||
@ -71,7 +74,14 @@ export function Index() {
|
||||
useEffect(() => {
|
||||
setMockMode(true);
|
||||
setCaptureHotkeyTypeInFocus(true);
|
||||
}, [navigate, setMockMode, setCaptureHotkeyTypeInFocus]);
|
||||
setAuthFlowUserEmail(demoMode ? 'tim@apple.dev' : '');
|
||||
}, [
|
||||
navigate,
|
||||
setMockMode,
|
||||
setCaptureHotkeyTypeInFocus,
|
||||
setAuthFlowUserEmail,
|
||||
demoMode,
|
||||
]);
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -80,12 +90,14 @@ export function Index() {
|
||||
</AnimatedEaseIn>
|
||||
<Title animate>Welcome to Twenty</Title>
|
||||
<StyledContentContainer>
|
||||
<MainButton
|
||||
icon={<IconBrandGoogle size={theme.icon.size.sm} stroke={4} />}
|
||||
title="Continue with Google"
|
||||
onClick={onGoogleLoginClick}
|
||||
fullWidth
|
||||
/>
|
||||
{authProviders.google && (
|
||||
<MainButton
|
||||
icon={<IconBrandGoogle size={theme.icon.size.sm} stroke={4} />}
|
||||
title="Continue with Google"
|
||||
onClick={onGoogleLoginClick}
|
||||
fullWidth
|
||||
/>
|
||||
)}
|
||||
{visible && (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, height: 0 }}
|
||||
|
||||
@ -11,6 +11,7 @@ import { Title } from '@/auth/components/ui/Title';
|
||||
import { useAuth } from '@/auth/hooks/useAuth';
|
||||
import { authFlowUserEmailState } from '@/auth/states/authFlowUserEmailState';
|
||||
import { isMockModeState } from '@/auth/states/isMockModeState';
|
||||
import { isDemoModeState } from '@/client-config/states/isDemoModeState';
|
||||
import { MainButton } from '@/ui/components/buttons/MainButton';
|
||||
import { TextInput } from '@/ui/components/inputs/TextInput';
|
||||
import { SubSectionTitle } from '@/ui/components/section-titles/SubSectionTitle';
|
||||
@ -48,15 +49,15 @@ const StyledErrorContainer = styled.div`
|
||||
|
||||
export function PasswordLogin() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const prefillPassword =
|
||||
process.env.NODE_ENV === 'development' ? 'Applecar2025' : '';
|
||||
const [isDemoMode] = useRecoilState(isDemoModeState);
|
||||
|
||||
const [authFlowUserEmail, setAuthFlowUserEmail] = useRecoilState(
|
||||
authFlowUserEmailState,
|
||||
);
|
||||
const [, setMockMode] = useRecoilState(isMockModeState);
|
||||
const [internalPassword, setInternalPassword] = useState(prefillPassword);
|
||||
const [internalPassword, setInternalPassword] = useState(
|
||||
isDemoMode ? 'Applecar2025' : '',
|
||||
);
|
||||
const [formError, setFormError] = useState('');
|
||||
|
||||
const { login } = useAuth();
|
||||
|
||||
Reference in New Issue
Block a user