Skip to content

Commit 995ecce

Browse files
committed
refactor: 함수 호출이 모두 entities/slogan 내부이기 때문에 파일로 분리하지 않겠습니다
1 parent 62f085d commit 995ecce

4 files changed

Lines changed: 4 additions & 8 deletions

File tree

src/entities/slogan/lib/normalizeText.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/entities/slogan/lib/useSloganForm.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { sloganSchema, SloganFormValues } from "../model/schema";
66
import { handleSloganFormSubmit } from "./handleSloganFormSubmit";
77
import { useDebounce } from "./useDebounce";
88
import { useGetSchool } from "../api/useGetSchool";
9-
import { normalizeText } from "./normalizeText";
109
import { SchoolInfoResponse } from "@/widgets/slogan/model/school";
1110
import { UseSloganFormReturn } from "./types";
1211

@@ -23,7 +22,7 @@ export const useSloganForm = (): UseSloganFormReturn => {
2322
const isValid = sloganSchema.safeParse(state.formValues).success;
2423

2524
const normalizedSchoolName = useMemo(
26-
() => normalizeText(state.formValues.school),
25+
() => state.formValues.school.replace(/\s+/g, ""),
2726
[state.formValues.school],
2827
);
2928
const debouncedSchoolName = useDebounce<string>(normalizedSchoolName, SCHOOL_SEARCH_DELAY);

src/entities/slogan/ui/HighlightText/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from "react";
2-
import { normalizeText } from "@/entities/slogan/lib/normalizeText";
32

43
interface HighlightTextProps {
54
text: string;
@@ -16,13 +15,13 @@ const HighlightText = ({
1615
return <span>{text}</span>;
1716
}
1817

19-
const normalizedSearchTerm = normalizeText(searchTerm);
18+
const normalizedSearchTerm = searchTerm.replace(/\s+/g, "");
2019

2120
if (!normalizedSearchTerm) {
2221
return <span>{text}</span>;
2322
}
2423

25-
const matchIndex = normalizeText(text).indexOf(normalizedSearchTerm);
24+
const matchIndex = text.replace(/\s+/g, "").indexOf(normalizedSearchTerm);
2625

2726
if (matchIndex === -1) {
2827
return <span>{text}</span>;

src/entities/slogan/ui/SchoolSearchInput/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Input } from "@/shared/ui";
33
import { cn } from "@/shared/utils/cn";
44
import Search from "@/shared/asset/svg/Search";
55
import HighlightText from "../HighlightText";
6-
import { normalizeText } from "@/entities/slogan/lib/normalizeText";
76

87
type School = {
98
SD_SCHUL_CODE: string;
@@ -25,7 +24,7 @@ const SchoolSearchInput = ({
2524
isSchoolFetched,
2625
onSchoolSelect,
2726
}: SchoolSearchInputProps) => {
28-
const normalizedValue = useMemo(() => normalizeText(value), [value]);
27+
const normalizedValue = useMemo(() => value.replace(/\s+/g, ""), [value]);
2928

3029
return (
3130
<div className="relative">

0 commit comments

Comments
 (0)