Skip to content

Commit 27685e4

Browse files
authored
๐Ÿ› fix: ๋ฉ”์‹œ์ง€ ์ „์†ก ์ค‘๋ณต ๋ฐฉ์ง€๋ฅผ ์œ„ํ•œ ์ƒํƒœ ๊ด€๋ฆฌ ์ถ”๊ฐ€
๐Ÿ› fix: ๋ฉ”์‹œ์ง€ ์ „์†ก ์ค‘๋ณต ๋ฐฉ์ง€๋ฅผ ์œ„ํ•œ ์ƒํƒœ ๊ด€๋ฆฌ ์ถ”๊ฐ€
2 parents 9caf791 + 318f9c4 commit 27685e4

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

โ€Žsrc/pages/CreateRecipient/CreateRecipient.jsxโ€Ž

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default function CreateRecipient() {
1818
const [selectedImage, setSelectedImage] = useState(-1);
1919
const [imageLoading, setImageLoading] = useState([]);
2020
const [uploadedImageUrl, setUploadedImageUrl] = useState(null);
21+
const [isCreating, setIsCreating] = useState(false);
2122
const navigate = useNavigate();
2223

2324
useEffect(() => {
@@ -64,6 +65,15 @@ export default function CreateRecipient() {
6465
}
6566

6667
async function handleButtonClick() {
68+
if (isCreating) return;
69+
70+
if (value.trim() === '' || value.trim().length > 10) {
71+
alert('์ด๋ฆ„์€ ๊ณต๋ฐฑ์ด ์•„๋‹ˆ์–ด์•ผ ํ•˜๋ฉฐ, ์ตœ๋Œ€ 10์ž๊นŒ์ง€ ์ž…๋ ฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.');
72+
return;
73+
}
74+
75+
setIsCreating(true);
76+
6777
try {
6878
const id = await postRecipient({
6979
team: '15-7',
@@ -74,6 +84,8 @@ export default function CreateRecipient() {
7484
navigate(`/post/${id}`);
7585
} catch (error) {
7686
console.error('ํŽ˜์ด์ง€ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜:', error.response.data);
87+
} finally {
88+
setIsCreating(false);
7789
}
7890
}
7991

@@ -172,7 +184,7 @@ export default function CreateRecipient() {
172184
<Button
173185
type="button"
174186
onClick={handleButtonClick}
175-
disabled={!value.trim()}
187+
disabled={!value.trim() || isCreating}
176188
>
177189
์ƒ์„ฑํ•˜๊ธฐ
178190
</Button>

โ€Žsrc/pages/MessageForm/MessageForm.jsxโ€Ž

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default function MessageForm() {
2020
const [message, setMessage] = useState('');
2121
const [font, setFont] = useState('Noto Sans');
2222
const [isRestored, setIsRestored] = useState(false);
23+
const [isCreating, setIsCreating] = useState(false);
2324

2425
const stripHtml = (html) => html.replace(/<[^>]+>/g, '').trim();
2526
const isValid = sender.trim() !== '' && stripHtml(message) !== '';
@@ -92,6 +93,8 @@ export default function MessageForm() {
9293
}, [sender, profileImage, relationship, message, font]);
9394

9495
async function handleSubmit() {
96+
if (isCreating) return;
97+
9598
if (
9699
sender.trim() === '' ||
97100
sender.trim().length > 10 ||
@@ -101,6 +104,8 @@ export default function MessageForm() {
101104
return;
102105
}
103106

107+
setIsCreating(true);
108+
104109
try {
105110
await postMessage({
106111
team: import.meta.env.VITE_TEAM_ID,
@@ -117,6 +122,8 @@ export default function MessageForm() {
117122
navigate(`/post/${id}`);
118123
} catch (error) {
119124
console.error('๋ฉ”์„ธ์ง€ ์ „์†ก ์‹คํŒจ', error);
125+
} finally {
126+
setIsCreating(false);
120127
}
121128
}
122129

@@ -155,7 +162,11 @@ export default function MessageForm() {
155162
<FontSelect value={font} onChange={setFont} />
156163
</div>
157164
</div>
158-
<Button type="button" onClick={handleSubmit} disabled={!isValid}>
165+
<Button
166+
type="button"
167+
onClick={handleSubmit}
168+
disabled={!isValid || isCreating}
169+
>
159170
์ƒ์„ฑํ•˜๊ธฐ
160171
</Button>
161172
</div>

0 commit comments

Comments
ย (0)