Skip to content

Commit

Permalink
Merge branch 'GDSC-Hongik:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
GDSChongik authored Sep 4, 2024
2 parents fab438a + 4b2ed15 commit 47004bc
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 37 deletions.
7 changes: 4 additions & 3 deletions src/components/ApiErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Sentry from '@sentry/react';
import { useQueryClient } from '@tanstack/react-query';
import { AxiosError } from 'axios';
import { redirect } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import { toast } from 'react-toastify';
import RoutePath from '@/routes/routePath';
import { ReactNode } from 'react';
Expand All @@ -17,6 +17,7 @@ export default function ApiErrorBoundary({
children: ReactNode;
}) {
const queryClient = useQueryClient();
const navigate = useNavigate();

queryClient.getQueryCache().config = {
onError: (error) => handleError(error as AxiosError)
Expand All @@ -38,8 +39,8 @@ export default function ApiErrorBoundary({
case 401:
case 403:
toast.error(message);
sessionStorage.setItem('isLogin', 'false');
redirect(RoutePath.Home);
localStorage.setItem('isLogin', 'false');
navigate(RoutePath.Home);
break;
default:
toast.error(message);
Expand Down
5 changes: 4 additions & 1 deletion src/components/bottomsheet/JoinRegularMemberBottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,13 @@ const JoinRegularMemberBottomSheet = ({
text={<Text typo="label1">{recruitmentPeriod}</Text>}
/>
<Button
disabled={currentRecruitment ? true : false}
onClick={() => {
joinRegularMember(currentRecruitment.recruitmentId);
}}>
지원하러 가기
{currentRecruitment
? '정회원 가입 조건을 완료해주세요'
: '지원하러 가기'}
</Button>
</BottomSheetContent>
</BottomSheet>
Expand Down
26 changes: 18 additions & 8 deletions src/components/myPage/ApproveBox.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import Box from 'wowds-ui/Box';
import styled from '@emotion/styled';
import { CurrentRecruitmentType } from '@/apis/member/memberType';
import {
CurrentMembershipType,
CurrentRecruitmentType
} from '@/apis/member/memberType';
import {
convertRecruitmentPeriod,
convertRecruitmentName
Expand All @@ -13,14 +16,16 @@ type BoxStatusType = 'default' | 'success' | 'error';

export const ApproveBox = ({
role,
currentRecruitment
currentRecruitment,
currentMembership
}: {
role: UserRoleType;
currentRecruitment: CurrentRecruitmentType;
currentMembership?: CurrentMembershipType;
}) => {
const { handleBottomSheet } = useBottomSheet();

if (!currentRecruitment) {
if (!currentRecruitment && role !== 'REGULAR') {
return (
<Box
variant="warn"
Expand Down Expand Up @@ -48,20 +53,25 @@ export const ApproveBox = ({
ASSOCIATE: {
title: `${convertRecruitmentName(currentRecruitment.name, currentRecruitment.roundTypeValue)}`,
description: `${convertRecruitmentPeriod(currentRecruitment.period)}`,
boxVariant: 'arrow',
boxVariant: currentMembership ? 'text' : 'arrow',
status: 'error'
},
REGULAR: {
title: '모든 가입 절차를 완료했어요.',
boxVariant: 'text',
title: 'WOW CLASS',
description:
'GDSC Hongik의 스터디 서비스인 WOW CLASS를 이용할 수 있어요.',
boxVariant: 'arrow',
status: 'success'
}
};

return (
<BoxWrapper
onClick={() => {
if (role === 'ASSOCIATE') handleBottomSheet();
else {
if (role === 'ASSOCIATE' && !currentMembership) handleBottomSheet();
else if (role === 'REGULAR') {
window.location.href = 'https://study.gdschongik.com/';
} else {
return;
}
}}>
Expand Down
47 changes: 32 additions & 15 deletions src/components/myPage/JoinRegularMember.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { Text, Flex } from '@/components/common/Wrapper';
import RoutePath from '@/routes/routePath';
import { Status } from '@/types/status';
import { User } from '@/types/user';
import { useNavigate } from 'react-router-dom';
import Box from 'wowds-ui/Box';

const JoinRegularMember = ({ paymentStatus }: { paymentStatus: Status }) => {
const JoinRegularMember = ({
paymentStatus,
member
}: {
paymentStatus?: Status;
member: User;
}) => {
const navigate = useNavigate();

const handleClickRoute = () => {
Expand All @@ -23,20 +30,30 @@ const JoinRegularMember = ({ paymentStatus }: { paymentStatus: Status }) => {
<Text typo="h2" color="textBlack">
정회원 가입 조건
</Text>
<Box
text={
paymentStatus === 'UNSATISFIED'
? '이번 학기 회비를 납부해주세요.'
: '이번 학기 회비를 납부했어요.'
}
variant={paymentStatus === 'UNSATISFIED' ? 'arrow' : 'text'}
status={paymentStatus === 'UNSATISFIED' ? 'error' : 'success'}
subText={
paymentStatus === 'UNSATISFIED'
? '카드·계좌이체 등 여러 결제수단을 지원해요.'
: undefined
}
/>
{paymentStatus ? (
<Box
text={
paymentStatus === 'UNSATISFIED'
? '이번 학기 회비를 납부해주세요.'
: '이번 학기 회비를 납부했어요.'
}
variant={paymentStatus === 'UNSATISFIED' ? 'arrow' : 'text'}
status={paymentStatus === 'UNSATISFIED' ? 'error' : 'success'}
subText={
paymentStatus === 'UNSATISFIED'
? '카드·계좌이체 등 여러 결제수단을 지원해요.'
: undefined
}
/>
) : (
member.role === 'REGULAR' && (
<Box
text="이번 학기 회비를 납부했어요."
variant="text"
status="success"
/>
)
)}
</Flex>
);
};
Expand Down
15 changes: 12 additions & 3 deletions src/components/myPage/JoinStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@ import styled from '@emotion/styled';
import MemberStatusInfoBox from '@/components/myPage/MemberStatusInfoBox';
import { ApproveBox } from './ApproveBox';
import { Text, Flex, Space } from '../common/Wrapper';
import { CurrentRecruitmentType } from '@/apis/member/memberType';
import {
CurrentMembershipType,
CurrentRecruitmentType
} from '@/apis/member/memberType';
import MemberStatusStepper from './MemberStatusStepper';
import { User, UserRoleType } from '@/types/user';

const JoinStatus = ({
role,
currentRecruitmentRound,
member
member,
currentMembership
}: {
role: UserRoleType;
currentRecruitmentRound: CurrentRecruitmentType;
member: User;
currentMembership?: CurrentMembershipType;
}) => {
const [openInfo, setOpenInfo] = useState(false);
const helpButtonRef = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -50,7 +55,11 @@ const JoinStatus = ({
<Space height={40} />
<MemberStatusStepper member={member} />
<Space height={20} />
<ApproveBox role={role} currentRecruitment={currentRecruitmentRound} />
<ApproveBox
role={role}
currentRecruitment={currentRecruitmentRound}
currentMembership={currentMembership}
/>
</Flex>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/signup/EmailInputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const EmailInputField = ({ control }: DepartmentSelectProps) => {
render={({ field, fieldState }) => (
<TextFieldWrapper>
<TextField
style={{ minWidth: '100%' }}
style={{ minWidth: '100%', flex: 1, maxWidth: '150px' }}
label="이메일"
error={fieldState.invalid}
ref={field.ref}
Expand Down Expand Up @@ -69,7 +69,7 @@ const EmailInputField = ({ control }: DepartmentSelectProps) => {
{customEmail ? (
<TextFieldWrapper>
<TextField
style={{ minWidth: '100%' }}
style={{ minWidth: '100%', flex: 1, maxWidth: '150px' }}
label="도메인"
error={fieldState.invalid}
ref={field.ref}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/mutation/useLogout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function useLogout() {
const mutation = useMutation({
mutationFn: authApi.LOGOUT,
onSuccess: () => {
sessionStorage.clear();
localStorage.clear();
navigate(RoutePath.Home);
location.reload();
},
Expand Down
8 changes: 6 additions & 2 deletions src/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export const Dashboard = () => {

const { member, currentRecruitmentRound, currentMembership } = data;

console.log(data);

return (
<div style={{ height: '100%' }}>
<Wrapper direction="column" justify="flex-start">
Expand All @@ -40,12 +42,14 @@ export const Dashboard = () => {
<JoinStatus
role={member.role}
currentRecruitmentRound={currentRecruitmentRound}
currentMembership={currentMembership}
member={member}
/>
</Flex>
{currentMembership && (
{(currentMembership || member.role === 'REGULAR') && (
<JoinRegularMember
paymentStatus={currentMembership.regularRequirement.paymentStatus}
member={member}
paymentStatus={currentMembership?.regularRequirement.paymentStatus}
/>
)}
<AssociateRequirementCheck
Expand Down
2 changes: 1 addition & 1 deletion src/pages/redirect/AuthServerRedirectNavigate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const AuthServerRedirectNavigate = () => {
const navigate = useNavigate();

useEffect(() => {
sessionStorage.setItem('isLogin', 'true');
localStorage.setItem('isLogin', 'true');
navigate(RoutePath.Dashboard);
}, [navigate]);

Expand Down
2 changes: 1 addition & 1 deletion src/utils/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const isAuthenticated = () => {
const isLogin = sessionStorage.getItem('isLogin');
const isLogin = localStorage.getItem('isLogin');

return isLogin === 'true';
};

0 comments on commit 47004bc

Please sign in to comment.