Files
frontend/apps/wr/app/map/searchModal.tsx
T
swcho 0ebe5e8ab8 - refactor: 안 쓰는 import 정리
- feat: 지도에서 Search 버튼 숨김, searchModal.tsx props 수정
2025-06-13 12:50:43 +09:00

81 lines
3.0 KiB
TypeScript

"use client"
import { useWrStore } from "@/app/store";
import { btnClass } from "@/app/store/common/code";
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { MapSearchBar, type ReturnType } from "./mapSearchBar";
import { Button } from "@common/components/ui";
import { SearchFormLeft, type EnvPartSelectDataType } from "@common/business_components/ui/search_form_left";
import { SearchFormRight } from "@common/business_components/ui/search_form_right";
import type { SelectDataType } from "@common/business_components/ui/search_input_select";
const API_URL = `${process.env.NEXT_PUBLIC_SEWERAGE_API_URL}`;
const YEARS = Array.from({ length: 100 }, (_, i) => `${2025 - i}`);
interface SearchModalProps {
open: boolean;
onOpenChange: (open: boolean) => void;
onFeatureSelect: (row: any) => void;
}
// 날짜 조합 함수
const getDateString = (
year: string,
month: string,
day: string,
defaultDate: string,
) => {
if (!year && !month && !day) return defaultDate;
const y = year || defaultDate.slice(0, 4);
const m = month || defaultDate.slice(4, 6);
const d = day || defaultDate.slice(6, 8);
return `${y}${m}${d}`;
};
const SearchModal: React.FC<SearchModalProps> = ({
open,
onOpenChange,
onFeatureSelect,
}) => {
// 로딩바
const [isLoading, setIsLoading] = useState(false);
// 상세 정보 조회를 위한 상태 추가
const [popupFeature, setPopupFeature] = useState<any>(null);
const { code, pbnstSttn, pbnstSttnSearch } = useWrStore((state) => state);
const [isChHead, setIsChHead] = useState(false);
const ref = useRef<ReturnType>({} as ReturnType);
return (
<div className="absolute left-1/2 -translate-x-1/2 w-full max-w-7xl bg-white flex items-center justify-center p-4 rounded-md shadow-lg">
<MapSearchBar
selectSidoData={code.cityCd}
selectSigunData={code.sggCd}
selectRegionData={code.rvbsnCd}
selectUnitWaterShedData={code.lgbsnCd}
selectMiddleRegionData={code.mdmbsnCd}
selectEnvPartData={code.lclgvrnmntCd}
queryClick={function (returnType: ReturnType): void {
// '{partValue: 'A', sidoValue: '0', sigunValue: '0', regionValue: '0', unitWaterShedValue: '0', …}'
let con;
if (returnType.sigunValue != "0") {
con = returnType.sigunValue;
} else {
con = returnType.sidoValue;
}
// pbnstSttnSearch(1, "20", con);
}}
initClick={function (): void { }}
btnClass={btnClass}
ref={ref} excelClick={function (returnType: ReturnType): void {
throw new Error("Function not implemented.");
}}
isAdmin={false}
/>
</div>
);
};
export default React.memo(SearchModal);