Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/hooks/useInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useCallback, useState } from "react";
const useInput = (initialValue) => {
const [value, setValue] = useState(initialValue);
const handler = useCallback((e) => {
if (e.target.value[0] && e.target.value[0] === " ")
e.target.value = e.target.value.slice(1, e.target.value.lengght);
setValue(e.target.value);
}, []);
return [value, handler, setValue];
Expand Down
5 changes: 5 additions & 0 deletions src/pages/home/components/profile/editor/ProfileText.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ function ProfileText({ userData, setUserData }, ref) {
<S.ProfileText
value={userData.nickname}
onChange={(e) => {
e.preventDefault();
const inputException = /((?![ㄱ-ㅎ|ㅏ-ㅣ|가-힣]|[a-zA-Z]).)|\n|$/g;
if (e.target.value.length > 8)
e.target.value = e.target.value.slice(0, 8);
e.target.value = e.target.value.replace(inputException, "");
setUserData({ ...userData, nickname: e.target.value });
}}
rows={1}
Expand Down
10 changes: 8 additions & 2 deletions src/pages/item/components/modification/ItemAdd/ItemAddDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@ const ItemAddDetail = ({ category, submitCallback, onCancel, isMutating }) => {
setIsError(false);
submitCallback({
category,
nickname,
brand,
nickname: nickname.trim(),
brand: brand.trim(),
price,
purchaseDate,
type,
goalUsageCount,
});
};
const handleInputBlur = (e) => {
e.preventDefault();
e.target.value = e.target.value.trim();
};

return (
<S.Form onSubmit={handleSubmit}>
Expand All @@ -61,6 +65,7 @@ const ItemAddDetail = ({ category, submitCallback, onCancel, isMutating }) => {
type="text"
value={nickname}
onChange={onNickname}
onBlur={handleInputBlur}
minLength={2}
maxLength={8}
/>
Expand All @@ -71,6 +76,7 @@ const ItemAddDetail = ({ category, submitCallback, onCancel, isMutating }) => {
type="text"
value={brand}
onChange={onBrand}
onBlur={handleInputBlur}
minLength={1}
maxLength={10}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@ const ItemEditDetail = ({ itemDetail, editCallback, onCancel, isMutating }) => {
}
setIsError(false);
editCallback({
nickname,
nickname: nickname.trim(),
type,
brand,
brand: brand.trim(),
price,
purchaseDate,
goalUsageCount,
});
};
const handleInputBlur = (e) => {
e.preventDefault();
e.target.value = e.target.value.trim();
};

return (
<S.Form onSubmit={handleSubmit}>
Expand All @@ -64,6 +68,7 @@ const ItemEditDetail = ({ itemDetail, editCallback, onCancel, isMutating }) => {
type="text"
value={nickname}
onChange={onNickname}
onBlur={handleInputBlur}
minLength={2}
maxLength={8}
placeholder={itemDetail.nickname}
Expand All @@ -75,6 +80,7 @@ const ItemEditDetail = ({ itemDetail, editCallback, onCancel, isMutating }) => {
type="text"
value={brand}
onChange={onBrand}
onBlur={handleInputBlur}
minLength={1}
maxLength={10}
placeholder={itemDetail.brand}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/signup/components/SignUpUser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ function SignUpUser(
};

const handleNicknameInput = (e) => {
const inputException = /((?![ㄱ-ㅎ|ㅏ-ㅣ|가-힣]|[a-zA-Z]).)|\n|$/g;
lengthSliceInKorean(e);
e.target.value = e.target.value.replace(inputException, "");
setUserInput({ ...userInput, nickname: e.target.value });
if (warningText) setWarningText(null);
};
Expand Down