Skip to content

Commit

Permalink
feat: improve UX for marathon registration
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnsonMao committed Dec 13, 2024
1 parent 7eac8a0 commit d7718cd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
15 changes: 13 additions & 2 deletions components/Marathon/Banner/index.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useRouter } from 'next/navigation';
import styled from '@emotion/styled';
import Button from '@/shared/components/Button';
import groupBannerImg from '@/public/assets/group-banner.png';
import Image from '@/shared/components/Image';
import InfoCompletionGuard from '@/shared/components/InfoCompletionGuard';
import { useAuthDispatch } from '@/contexts/Auth';
import { useAuth, useAuthDispatch } from '@/contexts/Auth';

const StyledBanner = styled.div`
position: relative;
Expand Down Expand Up @@ -47,8 +48,18 @@ const StyledBannerContent = styled.div`
`;

const Banner = () => {
const router = useRouter();
const { isLoggedIn, isTemporary } = useAuth();
const { openLoginModal } = useAuthDispatch();

const handleClick = () => {
if (isLoggedIn || isTemporary) {
router.push('/learning-marathon/signup');
} else {
openLoginModal('/learning-marathon/signup');
}
};

return (
<StyledBanner>
<picture>
Expand All @@ -64,7 +75,7 @@ const Banner = () => {
<h1>島島盃 - 學習馬拉松 2025 春季賽</h1>
<p>註冊並加入我們,立即報名!</p>
<InfoCompletionGuard>
<Button onClick={() => openLoginModal({ redirectUrl: '/learning-marathon/signup' })}>立即報名</Button>
<Button onClick={handleClick}>立即報名</Button>
</InfoCompletionGuard>
</StyledBannerContent>
</StyledBanner>
Expand Down
3 changes: 0 additions & 3 deletions components/Marathon/SignUp/UserProfileForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ export default function UserProfileForm({
};

useEffect(() => {
if (!user._id && (user.userType !== 'no_data')) {
router.push('/');
}
if (user._id) {
Object.entries(user).forEach(([key, value]) => {
if (key === 'contactList') {
Expand Down
5 changes: 3 additions & 2 deletions pages/learning-marathon/signup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import SaveBar from '@/components/Marathon/SignUp/SaveBar';
import UserProfileForm from '@/components/Marathon/SignUp/UserProfileForm';
import MarathonForm from '@/components/Marathon/SignUp/MarathonForm';
import ConfirmForm from '@/components/Marathon/SignUp/ConfirmForm';
import { ProtectedComponent } from '@/contexts/Auth';

const HomePageWrapper = styled.div`
--section-height: calc(100vh - 80px);
Expand Down Expand Up @@ -99,7 +100,7 @@ const LearningMarathonSignUp = () => {
});
}, [currentStep]);
return (
<>
<ProtectedComponent redirectOnCancel="/learning-marathon" onlyCheckToken>
<SEOConfig data={SEOData} />
<SaveBar currentStep={currentStep} />
<FormWrapper sx={{
Expand All @@ -121,7 +122,7 @@ const LearningMarathonSignUp = () => {
</ContentWrapper>
</LocalizationProvider>
</FormWrapper>
</>
</ProtectedComponent>
);
};

Expand Down

0 comments on commit d7718cd

Please sign in to comment.