Skip to content

Commit

Permalink
Merge pull request #279 from SOPT-all/fix/#277/ALL-QA(heesun)
Browse files Browse the repository at this point in the history
[Fix] ์ „์ฒด QA (์ƒ์„ธํŽ˜์ด์ง€, ์ƒ์„ธ๋‚ด์—ญํŽ˜์ด์ง€, ๋งˆ์ดํŽ˜์ด์ง€)
  • Loading branch information
heesunee authored Jan 24, 2025
2 parents 42d211a + 38189aa commit 368c748
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 19 deletions.
3 changes: 2 additions & 1 deletion src/components/ClassCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const ClassCard = ({
lessonEndDateTime,
isReservation = true,
children,
onClick,
}: ClassCardProps) => {
// ํด๋ž˜์Šค ์ƒํƒœ ๊ณ„์‚ฐ
const { status, remainingDays } = getClassStatus(lessonStartDateTime, lessonEndDateTime);
Expand Down Expand Up @@ -68,7 +69,7 @@ const ClassCard = ({
};

return (
<div className={styles.cardContainerStyle}>
<div className={styles.cardContainerStyle} onClick={onClick}>
<Flex justify="spaceBetween" align="center">
<Flex align="center" gap="0.3rem" marginBottom="1.2rem">
<Flex marginRight="0.5rem">{statusIcon()}</Flex>
Expand Down
31 changes: 30 additions & 1 deletion src/pages/home/components/BottomSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,36 @@ const BottomSection = ({ isInstructor }: { isInstructor: boolean }) => {

return (
<Flex>
<ul className={styles.ulStyle}>{LIST_DATA.map(renderListItem)}</ul>
<ul className={styles.ulStyle}>
{LIST_DATA.map((item) => {
const isDisabled =
(item.isInstructorRequired && !isInstructor) || (item.label === '๊ฐ•์‚ฌ ๋“ฑ๋ก' && isInstructor);
const ArrowIcon = isDisabled ? IcArrowRightSmallGray0432 : IcArrowRightSmallGray0732;

const handleClick = () => {
if (isDisabled) return;
if (item.label === '๋กœ๊ทธ์•„์›ƒ') {
handleLogout();
} else if (item.path) {
navigate(item.path);
}
};

return (
<React.Fragment key={item.id}>
<li className={`${styles.listStyle} ${isDisabled ? styles.disabledStyle : ''}`} onClick={handleClick}>
<p>{item.label}</p>
<ArrowIcon width={32} height={32} />
</li>
{item.hasDivider && (
<div className={styles.dividerStyle}>
<Divider color="gray1" thickness={1} />
</div>
)}
</React.Fragment>
);
})}
</ul>
</Flex>
);
};
Expand Down
12 changes: 10 additions & 2 deletions src/pages/home/components/TopSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ const TopSection = ({ userData, onClose, isInstructor }: TopSectionProps) => {
);
};

const handleMyClassesClick = () => {
if (isInstructor && userData.lessonCount === 0) {
return;
}
if (isInstructor) {
handleNavigate(ROUTES_CONFIG.instructorClassList.path);
}
};

return (
<section className={styles.sectionStyle}>
<Flex direction="column" align="center">
Expand Down Expand Up @@ -92,7 +101,6 @@ const TopSection = ({ userData, onClose, isInstructor }: TopSectionProps) => {

<Divider direction="vertical" color="gray2" length={32} thickness={1} />

{/* ๊ด€์‹ฌ๋ชฉ๋ก ์šฐ์„  disabled ์ฒ˜๋ฆฌ */}
<Flex direction="column" align="center" gap="0.5rem" className={styles.disabledStyle}>
<Head tag="h4" color={getTextColor(userData.favoriteCount)}>
{userData.favoriteCount}
Expand All @@ -108,7 +116,7 @@ const TopSection = ({ userData, onClose, isInstructor }: TopSectionProps) => {
gap="0.5rem"
direction="column"
align="center"
onClick={() => isInstructor && handleNavigate(ROUTES_CONFIG.instructorClassList.path)}
onClick={handleMyClassesClick}
className={isInstructor ? '' : styles.disabledStyle}>
<Head tag="h4" color={getTextColor(userData.lessonCount ?? 0)}>
{userData.lessonCount ?? 0}
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/types/classCardTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export interface ClassCardProps {
lessonStartDateTime: string | undefined;
lessonEndDateTime: string | undefined;
isReservation?: boolean;
onClick?: () => void;
children?: React.ReactNode;
}
13 changes: 4 additions & 9 deletions src/pages/instructor/classList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { useNavigate } from 'react-router-dom';
import { layoutStyle, containerStyle } from '@/pages/instructor/classList/index.css';
import { handleClassCardClick, handleBoxButtonClick, handleCancelClick } from '@/pages/mypage/utils/clickUtils';
import BoxButton from '@/components/BoxButton';
import ClassCard from '@/components/ClassCard';
import Flex from '@/components/Flex';
import Header from '@/components/Header';
import Text from '@/components/Text';
import { notify } from '@/components/Toast';
import { useGetMyLessons } from '@/apis/classList/queries';
import { ROUTES_CONFIG } from '@/routes/routesConfig';
import { Lesson } from '@/types/lessonTypes';

const ClassList = () => {
Expand All @@ -24,11 +23,6 @@ const ClassList = () => {
return <div></div>;
}

const handleDetailClick = (lessonId: number) => {
const path = ROUTES_CONFIG.instructorClassDetail.path(lessonId.toString());
navigate(path);
};

return (
<div className={layoutStyle}>
<Header.Root isColor={true}>
Expand All @@ -42,6 +36,7 @@ const ClassList = () => {
<Flex direction="column" gap="1.2rem" marginTop="1.6rem">
{lessonData?.lessons.map((lesson: Lesson) => (
<ClassCard
onClick={() => handleClassCardClick(navigate, lesson.id)}
isReservation={false}
key={lesson.id}
lessonName={lesson.name}
Expand All @@ -51,10 +46,10 @@ const ClassList = () => {
lessonLocation={lesson.location}
lessonStartDateTime={lesson.startDateTime}
lessonEndDateTime={lesson.endDateTime}>
<BoxButton variant="temp" onClick={() => notify()}>
<BoxButton onClick={handleCancelClick} variant="temp">
์ˆ˜์ •ํ•˜๊ธฐ
</BoxButton>
<BoxButton variant="outline" onClick={() => handleDetailClick(lesson.id)}>
<BoxButton variant="outline" onClick={(e) => handleBoxButtonClick(e, navigate, lesson.id, false)}>
์ƒ์„ธ๋ณด๊ธฐ
</BoxButton>
</ClassCard>
Expand Down
16 changes: 10 additions & 6 deletions src/pages/mypage/mypageReservation/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { useNavigate } from 'react-router-dom';
import { layoutStyle, containerStyle } from '@/pages/mypage/mypageReservation/index.css';
import { handleClassCardClick, handleBoxButtonClick, handleCancelClick } from '@/pages/mypage/utils/clickUtils';
import BoxButton from '@/components/BoxButton';
import ClassCard from '@/components/ClassCard';
import Flex from '@/components/Flex';
import Header from '@/components/Header';
import Text from '@/components/Text';
import { notify } from '@/components/Toast';
import { useGetReservations } from '@/apis/myPageReservation/queries';
import { ROUTES_CONFIG } from '@/routes/routesConfig';
import { Reservation } from '@/types/reservationTypes';

const MyPageReservation = () => {
const navigate = useNavigate();

const { data: reservationData } = useGetReservations();


const handleDetailClick = (reservationId: number | undefined) => {
if (reservationId !== undefined) {
const path = ROUTES_CONFIG.mypageReservationDetail.path(reservationId.toString());
Expand All @@ -27,6 +26,7 @@ const MyPageReservation = () => {
const handleNavigateHome = () => {
navigate('/');
};

return (
<div className={layoutStyle}>
<Header.Root isColor={true}>
Expand All @@ -53,12 +53,16 @@ const MyPageReservation = () => {
lessonLocation={reservation.location}
lessonStartDateTime={reservation.startDateTime}
lessonEndDateTime={reservation.endDateTime}
isReservation={true}>
<BoxButton onClick={notify} variant="temp">
isReservation={true}
onClick={() => handleClassCardClick(navigate, reservation.reservationId)}
>
<BoxButton onClick={handleCancelClick} variant="temp">
์ทจ์†Œํ•˜๊ธฐ
</BoxButton>

<BoxButton variant="outline" onClick={() => handleDetailClick(reservation.reservationId)}>
<BoxButton
variant="outline"
onClick={(e) => handleBoxButtonClick(e, navigate, reservation.reservationId, true)}>
์ƒ์„ธ๋ณด๊ธฐ
</BoxButton>
</ClassCard>
Expand Down
42 changes: 42 additions & 0 deletions src/pages/mypage/utils/clickUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { useNavigate } from 'react-router-dom';
import { notify } from '@/components/Toast';
import { ROUTES_CONFIG } from '@/routes/routesConfig';

export const handleClassCardClick = (navigate: ReturnType<typeof useNavigate>, reservationId: number | undefined) => {
if (reservationId !== undefined) {
const path = ROUTES_CONFIG.class.path(reservationId.toString());
navigate(path);
} else {
navigate(ROUTES_CONFIG.error.path);
}
};

export const handleDetailClick = (
navigate: ReturnType<typeof useNavigate>,
id: number | undefined,
isReservation: boolean
) => {
if (id !== undefined) {
const path = isReservation
? ROUTES_CONFIG.mypageReservationDetail.path(id.toString())
: ROUTES_CONFIG.instructorClassDetail.path(id.toString());
navigate(path);
} else {
navigate(ROUTES_CONFIG.error.path);
}
};

export const handleCancelClick = (e: React.MouseEvent) => {
e.stopPropagation();
notify();
};

export const handleBoxButtonClick = (
e: React.MouseEvent,
navigate: ReturnType<typeof useNavigate>,
reservationId: number | undefined,
isReservation: boolean
) => {
e.stopPropagation();
handleDetailClick(navigate, reservationId, isReservation);
};

0 comments on commit 368c748

Please sign in to comment.