-
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.
- Loading branch information
Showing
2 changed files
with
42 additions
and
14 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
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'; | ||
|
@@ -8,6 +10,22 @@ interface AlertsProps { | |
} | ||
|
||
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]'; | ||
return ( | ||
<div className="flex flex-col rounded-[0.8rem] bg-gray-bg-04 p-[3rem]"> | ||
{variant === 'logout' && ( | ||
|
@@ -37,19 +55,28 @@ const ModalContentsAlerts = ({ variant, handleClose }: AlertsProps) => { | |
영구적으로 삭제됩니다. 삭제하시겠습니까? | ||
</p> | ||
<p className="subhead-med-18 mb-[1rem] flex justify-center text-gray-05">이메일을 입력하여 확인해주세요.</p> | ||
<input | ||
type="text" | ||
placeholder="[email protected]" | ||
className="subhead-med-18 w-full rounded-[5px] bg-gray-bg-02 p-[1rem] text-gray-03 outline-none" | ||
/> | ||
<div className="mt-[3rem] flex gap-[1rem]"> | ||
<ButtonAlert variant="danger" onClick={handleClose}> | ||
계정 영구 삭제 | ||
</ButtonAlert> | ||
<ButtonAlert variant="primary" onClick={handleClose}> | ||
취소하기 | ||
</ButtonAlert> | ||
</div> | ||
<form action="" onSubmit={handleSubmit}> | ||
<input | ||
ref={inputRef} | ||
type="text" | ||
placeholder="[email protected]" | ||
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`} | ||
/> | ||
{error && ( | ||
<div className="absolute mt-[1rem] flex gap-[5px]"> | ||
<p className="body-reg-16 text-error-01">계속하려면 “[email protected]”을(를) 입력하세요.</p> | ||
</div> | ||
)} | ||
<div className="mt-[5.8rem] flex gap-[1rem]"> | ||
<ButtonAlert variant="danger" onClick={handleClose} type="submit"> | ||
계정 영구 삭제 | ||
</ButtonAlert> | ||
<ButtonAlert variant="primary" onClick={handleClose}> | ||
취소하기 | ||
</ButtonAlert> | ||
</div> | ||
</form> | ||
</div> | ||
)} | ||
{variant === 'delete-account-complete' && ( | ||
|