Skip to content

Commit ba29dc4

Browse files
Merge pull request #270 from ItRecode/FE-252
[FE-252] feat: ํƒˆํ‡ดํ•˜๊ธฐ ๋‹‰๋„ค์ž„ ์ผ์น˜ ๊ตฌํ˜„
2 parents 00b5239 + 692fde5 commit ba29dc4

5 files changed

Lines changed: 149 additions & 5 deletions

File tree

โ€Žsrc/components/Alert.tsxโ€Ž

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ export default function Alert({
3030
<Modal visible={visible} onClose={onClose}>
3131
<div className="flex h-auto w-[270px] flex-col justify-center">
3232
<div className="flex flex-col items-center justify-center border-b border-grey-2 py-6 text-center">
33-
<div className="text-base font-semibold leading-6">{mainMessage}</div>
33+
<div className="text-[18px] font-semibold leading-[24px]">
34+
{mainMessage}
35+
</div>
3436
{subMessage && (
35-
<div className="pt-4 text-xs font-medium text-grey-8">
37+
<div className="pt-4 text-[12px] font-medium leading-[18px] text-grey-8">
3638
{subMessage}
3739
</div>
3840
)}

โ€Žsrc/pages/Setting/Setting.tsxโ€Ž

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ export default function Setting() {
9292
<SettingSection routeText="๋กœ๊ทธ์•„์›ƒ" />
9393
</section>
9494
<section id="withdraw-item-section">
95-
<SettingSection routeText="ํšŒ์›ํƒˆํ‡ด" routeUrl="/setting/withdraw" />
95+
<SettingSection
96+
routeText="ํšŒ์›ํƒˆํ‡ด"
97+
routeUrl="/setting/withdraw"
98+
state={{ nickname: user.data }}
99+
/>
96100
</section>
97101
</div>
98102
)}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import React, { useRef, useState } from 'react'
2+
import { useLocation, useNavigate } from 'react-router-dom'
3+
import { NICKNAME_MAX_LENGTH } from '@assets/constant/constant'
4+
import { ReactComponent as CloseIcon } from '@assets/icon_closed.svg'
5+
import { ReactComponent as Back } from '@assets/back.svg'
6+
import useDebounce from '@hooks/useDebounce'
7+
import Button from '@components/Button'
8+
import Alert from '@components/Alert'
9+
10+
export default function CheckedNicknameBeforeWithDraw() {
11+
const navigate = useNavigate()
12+
const { state } = useLocation()
13+
const inputRef = useRef<HTMLInputElement>(null)
14+
const [isCheckedNickname, setIsCheckedNickname] = useState(false)
15+
const [nickname, setNickname] = useState('')
16+
const [message, setMessage] = useState('')
17+
const [inputBorderStyle, setInputBorderStyle] = useState('')
18+
const [isFocusInput, setIsFocusInput] = useState(false)
19+
const [alertOpen, setAlertOpen] = useState(false)
20+
21+
useDebounce(
22+
async () => {
23+
setMessage('')
24+
setInputBorderStyle('')
25+
setIsCheckedNickname(false)
26+
if (nickname.length > 0) {
27+
if (state.nickname === nickname) {
28+
setIsCheckedNickname(true)
29+
setInputBorderStyle('border border-solid border-grey-10')
30+
} else {
31+
setMessage('๋‹‰๋„ค์ž„์ด ์ผ์น˜ํ•˜์ง€ ์•Š์•„์š”.')
32+
setInputBorderStyle('border border-solid border-sub-1')
33+
setIsCheckedNickname(false)
34+
}
35+
}
36+
},
37+
300,
38+
[nickname]
39+
)
40+
41+
return (
42+
<>
43+
<section id="route-backIcon-button" className="ml-[18px] mt-4">
44+
<Back
45+
className="cursor-pointer"
46+
onClick={() => navigate('/setting', { replace: true })}
47+
/>
48+
</section>
49+
<section
50+
id="checked-nickname-before-withdraw-info"
51+
className="mt-11 px-6"
52+
>
53+
<h1 className="text-[20px] font-medium leading-[30px]">
54+
๊ณ„์† ํƒˆํ‡ด๋ฅผ ์ง„ํ–‰ํ•˜์‹œ๋ ค๋ฉด
55+
<br />
56+
๋‹‰๋„ค์ž„์„ ์ž…๋ ฅํ•ด ํ™•์ธํ•ด์ฃผ์„ธ์š”
57+
</h1>
58+
<div className="mt-10 h-[70px]">
59+
<p className="font-medium">๋‹‰๋„ค์ž„</p>
60+
<div className="relative mt-[9px] flex w-full items-center">
61+
<input
62+
ref={inputRef}
63+
id="modify-nickname-input"
64+
value={nickname}
65+
placeholder={isFocusInput || !state ? '' : state.nickname}
66+
className={`w-full rounded-[8px] bg-grey-2 py-[17px] pl-[12px] text-[14px] font-medium placeholder:text-grey-5 focus:outline-none
67+
${inputBorderStyle}`}
68+
autoComplete="off"
69+
onChange={(e) => setNickname(e.target.value)}
70+
onFocus={() => setIsFocusInput(true)}
71+
onBlur={() => setIsFocusInput(false)}
72+
maxLength={NICKNAME_MAX_LENGTH}
73+
/>
74+
<CloseIcon
75+
className="absolute right-[10px] cursor-pointer"
76+
onClick={() => {
77+
setNickname('')
78+
inputRef.current?.focus()
79+
}}
80+
/>
81+
</div>
82+
{nickname.length > 0 && (
83+
<p
84+
className={`pt-3 text-sm ${
85+
isCheckedNickname ? 'text-grey-10' : 'text-sub-1'
86+
}`}
87+
>
88+
{isCheckedNickname ? '๋‹‰๋„ค์ž„์ด ์ผ์น˜ํ•ด์š”.' : message}
89+
</p>
90+
)}
91+
</div>
92+
<div className="mt-[104px] w-full">
93+
<Button
94+
property="danger"
95+
type="submit"
96+
active={isCheckedNickname}
97+
disabled={!isCheckedNickname}
98+
onClick={() => setAlertOpen(true)}
99+
>
100+
ํƒˆํ‡ดํ•˜๊ธฐ
101+
</Button>
102+
</div>
103+
</section>
104+
<Alert
105+
visible={alertOpen}
106+
mainMessage={
107+
<>
108+
{nickname}๋‹˜, <br /> ํƒˆํ‡ดํ•˜์‹ ๋‹ค๋‹ˆ ๋„ˆ๋ฌด ์•„์‰ฌ์›Œ์š”
109+
</>
110+
}
111+
subMessage={
112+
<>
113+
ํƒˆํ‡ด ํ›„ <span className="text-sub-1">1์ฃผ์ผ ๊ฐ„</span>
114+
<br /> ์žฌ๊ฐ€์ž…์ด ๋ถˆ๊ฐ€๋Šฅํ•ด์š”.
115+
</>
116+
}
117+
confirmMessage="์˜ˆ"
118+
cancelMessage="์•„๋‹ˆ์˜ค"
119+
onConfirm={() => setAlertOpen(false)}
120+
onClose={() => setAlertOpen(false)}
121+
onCancel={() => setAlertOpen(false)}
122+
/>
123+
</>
124+
)
125+
}

โ€Žsrc/pages/Setting/Withdraw/Withdraw.tsxโ€Ž

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import React from 'react'
22
import Button from '@components/Button'
33
import BackButton from '@components/BackButton'
4+
import { useLocation, useNavigate } from 'react-router-dom'
45

56
const Withdraw = () => {
7+
const navigate = useNavigate()
8+
const { state } = useLocation()
9+
610
return (
711
<>
812
<section id="route-backIcon-button" className="ml-[18px] mt-4">
@@ -37,7 +41,12 @@ const Withdraw = () => {
3741
</ul>
3842
</section>
3943
<section id="withdraw-navigate-button" className="mt-[180px] px-6">
40-
<Button property="danger">ํƒˆํ‡ดํ•˜๊ธฐ</Button>
44+
<Button
45+
property="danger"
46+
onClick={() => navigate('/setting/withdraw/check', { state })}
47+
>
48+
ํƒˆํ‡ดํ•˜๊ธฐ
49+
</Button>
4150
</section>
4251
</>
4352
)

โ€Žsrc/routes/router.tsxโ€Ž

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import ManageComment from '@pages/Setting/ManageComment/ManageComment'
2222
import TeamIntroduction from '@pages/Setting/TeamIntroduction/TeamIntroduction'
2323
import FeedbackMail from '@pages/Setting/FeedbackMail/FeedbackMail'
2424
import Withdraw from '@pages/Setting/Withdraw/Withdraw'
25+
import CheckedNicknameBeforeWithDraw from '@pages/Setting/Withdraw/CheckedNicknameBeforeWithDraw'
2526

2627
const router = createBrowserRouter([
2728
{
@@ -103,7 +104,10 @@ const router = createBrowserRouter([
103104
},
104105
{
105106
path: 'withdraw',
106-
element: <Withdraw />,
107+
children: [
108+
{ index: true, element: <Withdraw /> },
109+
{ path: 'check', element: <CheckedNicknameBeforeWithDraw /> },
110+
],
107111
},
108112
],
109113
},

0 commit comments

Comments
ย (0)