-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ Style ] 설정 뷰 내의 경고 모달 뷰 구현 #227
Changes from 5 commits
40db651
0bffbdb
39c7df0
5b85c9e
1096aa2
fe4dc24
14c919c
4fcbc8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { FormEvent, useRef, useState } from 'react'; | ||
|
||
import IconWarning from '@/shared/assets/svgs/ic_delete_alert.svg?react'; | ||
|
||
import ButtonAlert from '@/pages/HomePage/components/ModalContents/Setting/components/ButtonAlert'; | ||
|
||
interface AlertsProps { | ||
variant?: 'logout' | 'delete-account' | 'delete-account-complete'; | ||
handleClose?: () => void; | ||
} | ||
|
||
const ModalContentsAlerts = ({ variant, handleClose }: AlertsProps) => { | ||
const inputRef = useRef<HTMLInputElement | null>(null); | ||
const [error, setError] = useState(false); | ||
const handleSubmit = (e: FormEvent) => { | ||
e.preventDefault(); | ||
|
||
if (String(inputRef.current?.value) !== '[email protected]') { | ||
setError(true); | ||
} | ||
}; | ||
|
||
const handleInputChange = () => { | ||
if (inputRef.current) { | ||
setError(false); | ||
} | ||
}; | ||
const errorStyle = 'border-error-01 border-[1px]'; | ||
|
||
const renderLogoutModal = () => ( | ||
<> | ||
<p className="subhead-bold-22 flex justify-center text-white">[email protected] 계정이</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p1: 이 부분의 이메일도 prop으로 받을수 있게 변경 부탁드립니다! |
||
<p className="subhead-bold-22 mb-[1rem] flex justify-center text-white"> | ||
본 기기를 포함한 모든 기기에서 로그아웃됩니다. | ||
</p> | ||
<p className="subhead-med-18 mb-[3rem] flex justify-center text-gray-05">로그아웃 하시겠습니까?</p> | ||
<div className="flex gap-[1rem]"> | ||
<ButtonAlert variant="danger" onClick={handleClose}> | ||
로그아웃 | ||
</ButtonAlert> | ||
<ButtonAlert variant="primary" onClick={handleClose}> | ||
취소하기 | ||
</ButtonAlert> | ||
</div> | ||
</> | ||
); | ||
|
||
const renderDeleteAccountModal = () => ( | ||
<div className="w-[62rem]"> | ||
<div className="mb-[3rem] flex justify-center"> | ||
<IconWarning width="5.4rem" /> | ||
</div> | ||
<p className="subhead-bold-22 flex justify-center text-white">[email protected] 계정이</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p1: 이 부분의 이메일도 prop으로 받을수 있게 변경 부탁드립니다! |
||
<p className="subhead-bold-22 mb-[3rem] flex justify-center text-white"> | ||
영구적으로 삭제됩니다. 삭제하시겠습니까? | ||
</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p1: api 연결 시 해당 부분에는 실제 이메일을 넣어야되기 때문에 prop으로 받을 수 있게 변경 부탁드려요! <p className="subhead-bold-22 flex justify-center text-white">{`${userEmail} 계정이`}</p>
<p className="subhead-bold-22 mb-[3rem] flex justify-center text-white">
영구적으로 삭제됩니다. 삭제하시겠습니까?
</p> |
||
<p className="subhead-med-18 mb-[1rem] flex justify-center text-gray-05">이메일을 입력하여 확인해주세요.</p> | ||
<form action="" onSubmit={handleSubmit}> | ||
<input | ||
ref={inputRef} | ||
type="text" | ||
placeholder="[email protected]" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p1: 이 부분의 이메일도 prop으로 받을수 있게 변경 부탁드립니다! |
||
onChange={handleInputChange} | ||
className={`${error ? errorStyle : ''} subhead-med-18 placeholder-text-gray-03 w-full rounded-[5px] bg-gray-bg-02 p-[1rem] text-white outline-none`} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p5: 에러 부분 스타일을 분리해 두신 이유가 있을까요? 테일윈드를 사용하는 만큼 스타일로 인해 가독성이 크게 저하되지 않는다면 클래스 내에 직관적으로 나타내도 좋을 것 같아요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
저도 이 의견에 동의합니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 반영했습니다~ |
||
/> | ||
{error && ( | ||
<div className="mt-[1rem]"> | ||
<p className="body-reg-16 mb-[3rem] text-error-01">계속하려면 “[email protected]”을(를) 입력하세요.</p> | ||
</div> | ||
)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p1: 이 부분의 이메일도 prop으로 받을수 있게 변경 부탁드립니다~~ |
||
<div className="mt-[3rem] flex gap-[1rem]"> | ||
<ButtonAlert variant="danger" onClick={handleClose} type="submit"> | ||
계정 영구 삭제 | ||
</ButtonAlert> | ||
<ButtonAlert variant="primary" onClick={handleClose}> | ||
취소하기 | ||
</ButtonAlert> | ||
</div> | ||
</form> | ||
</div> | ||
); | ||
|
||
const renderDeleteAccountCompleteModal = () => ( | ||
<div className="w-[47.2rem]"> | ||
<p className="subhead-bold-22 flex justify-center text-white">[email protected] 계정이</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p1: 이 부분도 이메일 prop으로 받을수있게 부탁드려요~ |
||
<p className="subhead-bold-22 mb-[3rem] flex justify-center text-white"> 삭제되었습니다.</p> | ||
<ButtonAlert variant="primary" onClick={handleClose}> | ||
확인 | ||
</ButtonAlert> | ||
</div> | ||
); | ||
|
||
return ( | ||
<div className="flex flex-col rounded-[0.8rem] bg-gray-bg-04 p-[3rem]"> | ||
{variant === 'logout' && renderLogoutModal()} | ||
{variant === 'delete-account' && renderDeleteAccountModal()} | ||
{variant === 'delete-account-complete' && renderDeleteAccountCompleteModal()} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ModalContentsAlerts; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ButtonHTMLAttributes, ReactNode } from 'react'; | ||
|
||
interface ButtonAlertProps extends ButtonHTMLAttributes<HTMLButtonElement> { | ||
variant?: 'primary' | 'danger'; | ||
children: ReactNode; | ||
} | ||
|
||
const ButtonAlert = ({ children, variant = 'primary', ...props }: ButtonAlertProps) => { | ||
const primaryStyle = 'bg-gray-bg-06 hover:bg-gray-bg-04 active:bg-gray-bg-05'; | ||
const dangerStyle = 'bg-error-01 hover:bg-error-03 active:bg-error-03 active:text-gray-04'; | ||
const buttonStyle = variant === 'primary' ? primaryStyle : dangerStyle; | ||
return ( | ||
<button | ||
{...props} | ||
className={`subhead-semibold-18 w-full rounded-[5px] px-[4.8rem] py-[1rem] text-center text-white ${buttonStyle}`} | ||
> | ||
{children} | ||
</button> | ||
); | ||
}; | ||
|
||
export default ButtonAlert; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p1: 이 부분도
prop
으로 변경해 주세요!