Skip to content

Commit

Permalink
[fix] HD_ 로 시작하는 이벤트id가 아니더라도 검색에 뜨게 함
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdulgi committed Aug 21, 2024
1 parent e37e0ca commit 50fa70e
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/adminPage/features/comment/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,34 @@ export default function AdminComment() {
}

function onChangeForm(e) {
let newString = e.target.value.replace(/[^0-9]/g, "");
const newString = e.target.value.replace(/[^0-9]/g, "");
const filteredFormString = formString.replace(/[^0-9]/g, "");

if (!newString) {
newString = "";
} else if (newString.length <= 6) {
newString = "HD_" + newString;
} else if (newString.length <= 9) {
newString = "HD_" + newString.slice(0, 6) + "_" + newString.slice(6);
} else return;
if (newString.length > 9) return;

if (newString !== formString) {
if (newString.length >= 9) {
if (newString !== filteredFormString) {
if (newString.length >= 6) {
setSelectedEvent(-1);
setIsSpread(true);
autoCorrect(newString);
} else {
setIsSpread(false);
}
}
setFormString(newString);
if (!newString) {
setFormString("");
} else if (newString.length <= 6) {
setFormString("HD_" + newString);
} else {
setFormString("HD_" + newString.slice(0, 6) + "_" + newString.slice(6));
}
}

function searchEvent(e, eventId) {
e.preventDefault();

const eventIDRegex = /^HD_\d{6}_\d{3}$/;
const searchID = eventId ?? formString;

if (eventIDRegex.test(searchID)) {
navigate(`/comments/${searchID}`);
}
navigate(`/comments/${searchID}`);
}

function onKeyDown(e) {
Expand Down

0 comments on commit 50fa70e

Please sign in to comment.