Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/pages/main/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ import { useNavigate } from "react-router";

import { Box, Button, Flex, HStack, Text, VStack } from "@chakra-ui/react";

import { useAuth } from "@/entities";
import { AssignmentHelpSection, ExecutionOnlySection } from "@/features";
import { CheckIcon, CopyIcon, ROUTE_PATHS, SparklesIcon } from "@/shared";

export default function MainPage() {
const [isSolutionSectionReady, setIsSolutionSectionReady] = useState(false);
const navigate = useNavigate();
const { isAuthenticated, isLoading } = useAuth();

const handleStartClick = () => {
navigate(isAuthenticated ? ROUTE_PATHS.MYPAGE : ROUTE_PATHS.LOGIN);
};
Comment on lines +15 to +17
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

버튼에 isDisabled 속성을 사용하면 비활성화 상태일 때 클릭 이벤트가 자동으로 차단됩니다. 따라서 핸들러 내부에서 isStartButtonDisabled를 중복으로 체크할 필요가 없으므로 로직을 단순화할 수 있습니다.

  const handleStartClick = () => {
    navigate(startButtonTargetPath);
  };

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로직 단순화 진행하겠습니다.


return (
<Flex flexDir="column" align="center" bg="white">
Expand Down Expand Up @@ -97,13 +103,18 @@ export default function MainPage() {
bg="button.bg"
borderRadius={20}
color="button.foreground"
disabled={isLoading}
fontSize="xl"
fontWeight="bold"
p={6}
w={{ base: "full", lg: "auto" }}
w="full"
_active={{ bg: "seed.active" }}
_disabled={{
cursor: "not-allowed",
opacity: 0.5,
}}
_hover={{ bg: "seed.hover" }}
onClick={() => navigate(ROUTE_PATHS.LOGIN)}
onClick={handleStartClick}
>
시작하기
</Button>
Expand Down
Loading