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
8 changes: 6 additions & 2 deletions apps/web/src/app/university/SearchResultsContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import CloudSpinnerPage from "@/components/ui/CloudSpinnerPage";
import FloatingUpBtn from "@/components/ui/FloatingUpBtn";
import UniversityCards from "@/components/university/UniversityCards";
import { COUNTRY_CODE_MAP } from "@/constants/university";
import { type CountryCode, type LanguageTestType, RegionEnumExtend } from "@/types/university";
import RegionFilter from "./RegionFilter";
import SearchBar from "./SearchBar";
Expand All @@ -32,9 +33,12 @@ const SearchResultsContent = () => {
const countries = searchParams.getAll("countryCode");

// URL에서 전달된 국가 목록을 기본으로 사용
const filteredCountries = countries as CountryCode[];
const filteredCountries = countries.filter((country): country is CountryCode =>
Object.hasOwn(COUNTRY_CODE_MAP, country),
);
const hasFilterParams = Boolean(lang) || filteredCountries.length > 0;

if (!lang || !countries) {
if (!hasFilterParams) {
return {
isTextSearch: true,
searchText: text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ const SearchPageContent = ({ homeUniversitySlug }: SearchPageContentProps) => {
// 필터 검색
const onSubmit: SubmitHandler<SearchFormData> = (data) => {
const queryParams = new URLSearchParams();
const availableCountryCodeSet = new Set(availableCountries.map(([code]) => code as CountryCode));

if (data.languageTestType) {
queryParams.append("languageTestType", data.languageTestType);
}

[data.country1, data.country2, data.country3].forEach((code) => {
if (code) {
if (code && availableCountryCodeSet.has(code)) {
queryParams.append("countryCode", code);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import CloudSpinnerPage from "@/components/ui/CloudSpinnerPage";
import FloatingUpBtn from "@/components/ui/FloatingUpBtn";
import UniversityCards from "@/components/university/UniversityCards";
import { COUNTRY_CODE_MAP } from "@/constants/university";
import { type CountryCode, type HomeUniversityName, type LanguageTestType, RegionEnumExtend } from "@/types/university";
import RegionFilter from "../../RegionFilter";
import SearchBar from "../../SearchBar";
Expand All @@ -36,9 +37,12 @@ const SearchResultsContentInner = ({ homeUniversityName }: SearchResultsContentI
const countries = searchParams.getAll("countryCode");

// URL에서 전달된 국가 목록을 기본으로 사용
const filteredCountries = countries as CountryCode[];
const filteredCountries = countries.filter((country): country is CountryCode =>
Object.hasOwn(COUNTRY_CODE_MAP, country),
);
const hasFilterParams = Boolean(lang) || filteredCountries.length > 0;

if (!lang || !countries) {
if (!hasFilterParams) {
return {
isTextSearch: true,
searchText: text,
Expand Down
7 changes: 6 additions & 1 deletion apps/web/src/app/university/search/PageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const SchoolSearchForm = ({ homeUniversitySlug }: SchoolSearchFormProps) => {

const onSubmit: SubmitHandler<SearchFormData> = (data) => {
const queryParams = new URLSearchParams();
const availableCountryCodeSet = new Set(availableCountries.map(([code]) => code as CountryCode));

if (data.searchText) {
queryParams.append("searchText", data.searchText);
Expand All @@ -57,11 +58,15 @@ const SchoolSearchForm = ({ homeUniversitySlug }: SchoolSearchFormProps) => {
}

[data.country1, data.country2, data.country3].forEach((code) => {
if (code) {
if (code && availableCountryCodeSet.has(code)) {
queryParams.append("countryCode", code);
}
});

if (data.regions && data.regions.length > 0) {
data.regions.forEach((region) => queryParams.append("region", region));
}

const queryString = queryParams.toString();
router.push(`/university/${homeUniversitySlug}?${queryString}`);
};
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/constants/university.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type TestScoreInfo,
} from "@/types/university";

export const REGIONS_SEARCH = ["유럽권", "미주권", "아시아권"] as const;
export const REGIONS_SEARCH = ["유럽권", "미주권", "아시아권", "중국권"] as const;

export const REGIONS_KO = ["유럽권", "미주권", "아시아권", "중국권"];

Expand Down