Skip to content

Commit

Permalink
feat(auth): add close to home capability to auth wrapper modal
Browse files Browse the repository at this point in the history
  • Loading branch information
agustinusnathaniel committed Apr 1, 2023
1 parent 72bc80b commit e8f406e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/lib/components/auth/AuthWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import * as React from 'react';

import { PUBLIC_ROUTES } from '~/lib/constants/routes/public';
import { RESTRICTED_ROUTES } from '~/lib/constants/routes/restricted';
import { EVENT_TYPE_AUTH } from '~/lib/constants/tracking';
import { useAuth } from '~/lib/stores/auth';
import { trackEvent } from '~/lib/utils/trackEvent';

import Login from './Login';
import Register from './Register';
Expand Down Expand Up @@ -45,14 +47,22 @@ const AuthWrapper = ({ children }: AuthWrapperProps) => {
const handleSwitchToRegister = () => setIsRegistered(false);
const handleSwitchToLogin = () => setIsRegistered(true);

const handleCloseAuthModal = () => {
router.push({ pathname: '/home' });
trackEvent({
eventName: 'close_auth-back_to_home',
eventData: { type: EVENT_TYPE_AUTH },
});
};

if (!isUnauthorized) {
return children as React.ReactElement;
}

return (
<Modal
isOpen={isOpen}
onClose={() => 0}
onClose={handleCloseAuthModal}
motionPreset="slideInBottom"
isCentered
size="md"
Expand Down
3 changes: 3 additions & 0 deletions src/lib/components/auth/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Grid,
Heading,
ModalBody,
ModalCloseButton,
ModalContent,
ModalFooter,
ModalHeader,
Expand Down Expand Up @@ -54,6 +55,8 @@ const Login = ({ handleSwitchToRegister }: LoginProps) => {
<Heading bgGradient="linear(to-br, teal.200, blue.600)" bgClip="text">
Login
</Heading>

<ModalCloseButton />
</ModalHeader>

<ModalBody>
Expand Down
3 changes: 1 addition & 2 deletions src/lib/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ const Home = () => {
</Heading>

<Text color="gray">
Welcome to sozonome&apos;s take on scrum poker web app. Just click
start below.
spoker: real-time multiplayer scrum poker app.
</Text>
</Flex>

Expand Down

0 comments on commit e8f406e

Please sign in to comment.