Skip to content
Open
Show file tree
Hide file tree
Changes from all 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.length);
setValue(e.target.value);
}, []);
return [value, handler, setValue];
Expand Down
5 changes: 5 additions & 0 deletions src/pages/home/components/profile/editor/ProfileEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export default function ProfileEditor({ setIsEditing }) {
queryClient.refetchQueries(["user"]);
setIsEditing();
},
onError: (code) => {
if (code.response.status === 400) {
alert("잘못된 양식을 제출했어요!");
}
},
});

const handleSubmit = (e) => {
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
5 changes: 5 additions & 0 deletions src/pages/item/components/modification/ItemAdd/ItemAdd.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const ItemAddOnAuth = () => {
await queryClient.refetchQueries([`${item.category}`, "list"]);
navigate("/item", { state: { item: res.id, category: item.category } });
},
onError: (code) => {
if (code.response.status === 400) {
alert("잘못된 양식을 제출했어요!");
}
},
});

const itemImgFile = useRef(null);
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
5 changes: 5 additions & 0 deletions src/pages/item/components/modification/ItemEdit/ItemEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ const ItemEditOnAuth = () => {
queryClient.invalidateQueries([`${item.category}`, "list"]);
navigate("/item", { state: { item: item.id, category: item.category } });
},
onError: (code) => {
if (code.response.status === 400) {
alert("잘못된 양식을 제출했어요!");
}
},
});

const itemImgFile = useRef(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ 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.target.value = e.target.value.trim();
};

return (
<S.Form onSubmit={handleSubmit}>
Expand All @@ -64,6 +67,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 +79,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