Skip to content

Commit

Permalink
feat(페이지 navigation):
Browse files Browse the repository at this point in the history
- MainPage에서 '시작하기' 버튼 누르면 DrinkPage로 이동 (Navigation)
- Common folder의 Button 컴포넌트에 onClick 속성 추가
  • Loading branch information
Charmull committed Oct 27, 2022
1 parent bccba60 commit e171661
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/common/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ import { ReactNode } from "react";
const Button = ({
children,
isEnable = true,
onClick,
}: {
children: ReactNode;
isEnable?: boolean;
onClick?: React.MouseEventHandler<HTMLButtonElement>;
}) => {
return (
<button
className={`btn btn-primary btn-wide text-xl ${
isEnable ? "btn-active" : "btn-disabled"
}`}
onClick={onClick}
>
{children}
</button>
Expand Down
10 changes: 9 additions & 1 deletion src/main/MainPage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useNavigate } from "react-router-dom";
import Button from "../common/components/Button";
import LoadingBar from "../common/components/LoadingBar";
import NumOfDrinkers from "./components/NumOfDrinkers";
Expand All @@ -8,6 +9,7 @@ import useMainViewModel from "./hooks/useMainViewModel";
const MainPage = () => {
const { numOfDrinkers, totalAmountDrink, data, isFetching } =
useMainViewModel();
const navigate = useNavigate();

return (
<div className="m-10 flex flex-col">
Expand All @@ -24,7 +26,13 @@ const MainPage = () => {
<RegisteredUsers drinkers={data} />
{isFetching && <LoadingBar />}
<div className="flex justify-center py-5">
<Button>시작하기</Button>
<Button
onClick={(_) => {
navigate("/drink");
}}
>
시작하기
</Button>
</div>
</div>
);
Expand Down

0 comments on commit e171661

Please sign in to comment.