-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/frontend' into feature/fe/#197-doLogin
- Loading branch information
Showing
37 changed files
with
1,013 additions
and
409 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import React, { useState } from 'react'; | ||
import { Modal } from '@/component/common/modal/Modal'; | ||
|
||
interface IAuthModalProps { | ||
/** ๋ชจ๋ฌ์ด ์ด๋ ค ์๋์ง ์ฌ๋ถ๋ฅผ ๋ํ๋ ๋๋ค. */ | ||
isOpen: boolean; | ||
/** ๋ชจ๋ฌ์ ๋ซ๋ ํจ์์ ๋๋ค. */ | ||
onClose: () => void; | ||
/** ๋ชจ๋ฌ์ ํ์ ์ ๊ฒฐ์ ํ๋ ๊ฐ์ผ๋ก, 'login' ๋๋ 'register'๋ฅผ ๊ฐ์ง๋๋ค. */ | ||
type: 'login' | 'register'; | ||
} | ||
|
||
export const AuthModal = (props: IAuthModalProps) => { | ||
const [loginData, setLoginData] = useState({ | ||
id: '', | ||
pw: '', | ||
}); | ||
|
||
const [registerData, setRegisterData] = useState({ | ||
id: '', | ||
email: '', | ||
name: '', | ||
pw: '', | ||
confirmPw: '', | ||
}); | ||
|
||
const [modalType, setModalType] = useState<'login' | 'register'>(props.type); | ||
|
||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
const { name, value } = e.target; | ||
|
||
if (modalType === 'login') { | ||
setLoginData(prevState => ({ | ||
...prevState, | ||
[name]: value, | ||
})); | ||
} else { | ||
setRegisterData(prevState => ({ | ||
...prevState, | ||
[name]: value, | ||
})); | ||
} | ||
}; | ||
|
||
const handleLoginClick = () => { | ||
console.log('๋ก๊ทธ์ธ ๋ฐ์ดํฐ:', loginData); | ||
}; | ||
|
||
const handleSignUpClick = () => { | ||
if (registerData.pw !== registerData.confirmPw) { | ||
alert('๋น๋ฐ๋ฒํธ๊ฐ ์ผ์นํ์ง ์์ต๋๋ค.'); | ||
return; | ||
} | ||
console.log('ํ์๊ฐ์ ๋ฐ์ดํฐ:', registerData); | ||
}; | ||
|
||
const switchToRegister = () => { | ||
setModalType('register'); | ||
}; | ||
|
||
const switchToLogin = () => { | ||
setModalType('login'); | ||
}; | ||
|
||
return ( | ||
<Modal isOpen={props.isOpen} onClose={props.onClose}> | ||
{modalType === 'login' ? ( | ||
<> | ||
<Modal.Header content="Log In" onClose={props.onClose} /> | ||
<Modal.Input | ||
title="ID" | ||
name="id" | ||
placeholder="ID" | ||
value={loginData.id} | ||
onChange={handleChange} | ||
/> | ||
<Modal.Input | ||
title="PW" | ||
name="pw" | ||
placeholder="PW" | ||
value={loginData.pw} | ||
onChange={handleChange} | ||
/> | ||
<Modal.Footer | ||
text="๋ก๊ทธ์ธ" | ||
onClick={handleLoginClick} | ||
text2="ํ์๊ฐ์ " | ||
onClick2={switchToRegister} | ||
/> | ||
</> | ||
) : ( | ||
<> | ||
<Modal.Header content="Sign Up" onClose={props.onClose} /> | ||
<Modal.Input | ||
title="ID" | ||
name="id" | ||
placeholder="์ฌ์ฉํ ID๋ฅผ ์ ๋ ฅํด์ฃผ์ธ์." | ||
value={registerData.id} | ||
onChange={handleChange} | ||
/> | ||
<Modal.Input | ||
title="Email" | ||
name="email" | ||
placeholder="Email ์ฃผ์๋ฅผ ์ ๋ ฅํด์ฃผ์ธ์." | ||
value={registerData.email} | ||
onChange={handleChange} | ||
/> | ||
<Modal.Input | ||
title="Name" | ||
name="name" | ||
placeholder="์ด๋ฆ์ ์ ๋ ฅํด์ฃผ์ธ์." | ||
value={registerData.name} | ||
onChange={handleChange} | ||
/> | ||
<Modal.Input | ||
title="PW" | ||
name="pw" | ||
placeholder="์ฌ์ฉํ ๋น๋ฐ๋ฒํธ๋ฅผ ์ ๋ ฅํด์ฃผ์ธ์." | ||
value={registerData.pw} | ||
onChange={handleChange} | ||
/> | ||
<Modal.Input | ||
title="" | ||
name="confirmPw" | ||
placeholder="๋น๋ฐ๋ฒํธ๋ฅผ ํ ๋ฒ ๋ ์ ๋ ฅํด์ฃผ์ธ์." | ||
value={registerData.confirmPw} | ||
onChange={handleChange} | ||
/> | ||
<Modal.Footer | ||
text="ํ์๊ฐ์ " | ||
onClick={handleSignUpClick} | ||
text2="๋ก๊ทธ์ธ" | ||
onClick2={switchToLogin} | ||
/> | ||
</> | ||
)} | ||
</Modal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
frontend/src/component/common/dropdown/DropdownContext.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { createContext, ReactNode, useMemo, useState } from 'react'; | ||
|
||
export interface IToggleContext { | ||
isOpen: boolean; | ||
toggle: () => void; | ||
} | ||
|
||
interface IToggleProviderProps { | ||
children: ReactNode; | ||
} | ||
|
||
export const ToggleContext = createContext<IToggleContext>({ | ||
isOpen: false, | ||
toggle: () => {}, | ||
}); | ||
|
||
export const ToggleProvider = (props: IToggleProviderProps) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const toggle = () => setIsOpen(prevIsOpen => !prevIsOpen); | ||
const toggleContextValue = useMemo(() => ({ isOpen, toggle }), [isOpen]); | ||
|
||
return ( | ||
<ToggleContext.Provider value={toggleContextValue}>{props.children}</ToggleContext.Provider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 24 additions & 3 deletions
27
frontend/src/component/common/dropdown/DropdownTrigger.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { ModalHeader } from '@/component/common/modal/ModalHeader'; | ||
import { ModalInput } from '@/component/common/modal/ModalInput'; | ||
import { ModalFooter } from '@/component/common/modal/ModalFooter'; | ||
|
||
interface IModalProps { | ||
/** ๋ชจ๋ฌ์ด ์ด๋ ค ์๋์ง ์ฌ๋ถ๋ฅผ ๋ํ๋ ๋๋ค. */ | ||
isOpen: boolean; | ||
/** ๋ชจ๋ฌ ๋ด์์ ๋ ๋๋งํ ์์ ์์๋ค์ ๋๋ค. */ | ||
children: React.ReactNode; | ||
} | ||
|
||
export const Modal = (props: IModalProps) => { | ||
if (!props.isOpen) return null; | ||
|
||
return ( | ||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-20"> | ||
<div className="relative w-[22rem] max-w-lg rounded-2xl bg-white px-6 shadow-lg"> | ||
{props.children} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
Modal.Header = ModalHeader; | ||
Modal.Footer = ModalFooter; | ||
Modal.Input = ModalInput; |
Oops, something went wrong.