Skip to content

Commit

Permalink
refactor: separate diff pages to diff file
Browse files Browse the repository at this point in the history
  • Loading branch information
jinho-choi123 committed Mar 22, 2024
1 parent 5eb1ccd commit 25fa5a1
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 46 deletions.
56 changes: 10 additions & 46 deletions src/components/Auth/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useAppDispatch, useAppSelector } from "@/types";
import { type RootState } from "@/redux/store";
import { Board } from "@/components/Board";
import { loginThunk } from "@/redux/auth/loginThunk";
import style from "./Auth.module.scss";
import { LoginPage } from "@/components/Auth/LoginPage";

export const AuthPage = () => {
const [deviceId, setDeviceId] = useState("");
Expand Down Expand Up @@ -33,50 +33,14 @@ export const AuthPage = () => {
setPin("");
};

if (isLoggedIn) {
return <Board />;
}

return (
<div className={style.modalWrapper}>
<div className={style.modalContainer}>
<h1 className={style.modalTitle}> Zabo Board Login</h1>
<br />
<p className={style.modalContent}>
Zabo Board 서비스를 이용하기 위해서는 등록된 device Id와 PIN을
입력하세요.
<br />
Zabo Board 서비스를 등록하기 위해서는 zabo.sparcs.org 채널톡으로
문의해주세요.
</p>
<div className={style.form}>
<label className={style.input}>
device Id
<input
className={style.input}
name="deviceId"
onChange={onDeviceIdChange}
/>
</label>
<label className={style.input}>
PIN
<input
className={style.input}
type="password"
name="PIN"
onChange={onPinChange}
/>
</label>
</div>
<button
type="submit"
className={style.submit}
onClick={onSubmitHandler}
>
Submit
</button>
<div className={style.errorBox}>{errorMessage}</div>
</div>
</div>
return isLoggedIn ? (
<Board />
) : (
<LoginPage
errorMessage={errorMessage}
onDeviceIdChange={onDeviceIdChange}
onPinChange={onPinChange}
onSubmitHandler={onSubmitHandler}
/>
);
};
53 changes: 53 additions & 0 deletions src/components/Auth/LoginPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import type { ChangeEvent } from "react";
import style from "./Auth.module.scss";

type LoginPageProps = {
onDeviceIdChange: (e: ChangeEvent<HTMLInputElement>) => void;
onPinChange: (e: ChangeEvent<HTMLInputElement>) => void;
onSubmitHandler: () => void;
errorMessage: string;
};

export const LoginPage = ({
onDeviceIdChange,
onPinChange,
onSubmitHandler,
errorMessage,
}: LoginPageProps) => (
<div className={style.modalWrapper}>
<div className={style.modalContainer}>
<h1 className={style.modalTitle}> Zabo Board Login</h1>
<br />
<p className={style.modalContent}>
Zabo Board 서비스를 이용하기 위해서는 등록된 device Id와 PIN을
입력하세요.
<br />
Zabo Board 서비스를 등록하기 위해서는 zabo.sparcs.org 채널톡으로
문의해주세요.
</p>
<div className={style.form}>
<label className={style.input}>
device Id
<input
className={style.input}
name="deviceId"
onChange={onDeviceIdChange}
/>
</label>
<label className={style.input}>
PIN
<input
className={style.input}
type="password"
name="PIN"
onChange={onPinChange}
/>
</label>
</div>
<button type="submit" className={style.submit} onClick={onSubmitHandler}>
Submit
</button>
<div className={style.errorBox}>{errorMessage}</div>
</div>
</div>
);

0 comments on commit 25fa5a1

Please sign in to comment.