Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ interface FilterState {
interface CustomerFilterModalProps {
open: boolean;
onClose: () => void;
filters: any; // 🔥 부모에서 관리하는 필터
setFilters: (filters: any) => void; // 🔥 부모 setter
onApply: (filters: any) => void; // 🔥 적용 시 호출
filters: any;
setFilters: (filters: any) => void;
onApply: (filters: any) => void;
}

const CustomerFilterModal = ({ open, onClose, filters, setFilters, onApply }: CustomerFilterModalProps) => {
Expand All @@ -67,7 +67,7 @@ const CustomerFilterModal = ({ open, onClose, filters, setFilters, onApply }: Cu
const [labels, setLabels] = useState<Label[]>([]);
const [selectedLabels, setSelectedLabels] = useState<Label[]>([]);

// 라벨 목록 불러오기

const fetchLabels = async () => {
try {
const response = await apiClient.get("/labels");
Expand All @@ -92,15 +92,6 @@ const CustomerFilterModal = ({ open, onClose, filters, setFilters, onApply }: Cu
);
setSelectedLabels(selectedLabelsData);
}
} else {
setRegion({
sido: [],
sigungu: [],
dong: [],
selectedSido: null,
selectedSigungu: null,
selectedDong: null,
});
}
}, [open, filters]);

Expand Down Expand Up @@ -221,6 +212,15 @@ const CustomerFilterModal = ({ open, onClose, filters, setFilters, onApply }: Cu
return Number(price.replace(/[^0-9]/g, ''));
};

let regionCode: string | undefined;
if (region.selectedDong) {
regionCode = String(region.selectedDong);
} else if (region.selectedSigungu) {
regionCode = String(region.selectedSigungu).slice(0, 5);
} else if (region.selectedSido) {
regionCode = String(region.selectedSido).slice(0, 2);
}

const filterData = {
...filtersTemp,
minPrice: parsePrice(filtersTemp.minPrice as string),
Expand All @@ -229,7 +229,7 @@ const CustomerFilterModal = ({ open, onClose, filters, setFilters, onApply }: Cu
maxDeposit: parsePrice(filtersTemp.maxDeposit as string),
minRent: parsePrice(filtersTemp.minRent as string),
maxRent: parsePrice(filtersTemp.maxRent as string),
regionCode: region.selectedDong || region.selectedSigungu || region.selectedSido || undefined,
regionCode,
labelUids: selectedLabels.length > 0 ? selectedLabels.map(label => label.uid) : undefined,
};

Expand All @@ -254,6 +254,33 @@ const CustomerFilterModal = ({ open, onClose, filters, setFilters, onApply }: Cu
onClose();
};

// 필터 초기화 함수
const handleReset = () => {
setFiltersTemp({
tenant: false,
landlord: false,
buyer: false,
seller: false,
noRole: false,
minPrice: "",
maxPrice: "",
minDeposit: "",
maxDeposit: "",
minRent: "",
maxRent: "",
labelUids: [],
});
setSelectedLabels([]);
setRegion({
sido: [],
sigungu: [],
dong: [],
selectedSido: null,
selectedSigungu: null,
selectedDong: null,
});
};

return (
<Modal open={open} onClose={onClose}>
<Box
Expand Down Expand Up @@ -410,7 +437,7 @@ const CustomerFilterModal = ({ open, onClose, filters, setFilters, onApply }: Cu

{/* 버튼 영역 */}
<Box sx={{ mt: 4, display: "flex", justifyContent: "flex-end", gap: 2 }}>
<Button onClick={onClose} variant="outlined">취소</Button>
<Button onClick={handleReset} variant="outlined">초기화</Button>
<Button onClick={handleApply} variant="contained" sx={{ backgroundColor: "#164F9E" }}>
적용하기
</Button>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/CustomerListPage/CustomerListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ const CustomerListPage = () => {
sx={{
width: 250,
"& .MuiOutlinedInput-root": {
borderRadius: "14px",
borderRadius: "14px",
boxShadow: "0 2px 6px rgba(0, 0, 0, 0.05)",
"&:hover .MuiOutlinedInput-notchedOutline": {
borderColor: "rgba(0, 0, 0, 0.25)",
Expand All @@ -272,6 +272,7 @@ const CustomerListPage = () => {
onClick={() => setFilterModalOpen(true)}
sx={{
borderRadius: "14px",
padding: "5px",
border: "1px solid rgba(0, 0, 0, 0.23)",
"&:hover": {
backgroundColor: "#F5F5F5",
Expand Down
27 changes: 20 additions & 7 deletions src/pages/PrivatePropertyListPage/PrivatePropertyListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { MenuItem, SelectChangeEvent } from "@mui/material";
import PropertyAddButtonList from "./PropertyAddButtonList";
import { Box } from "@mui/material";
import { useNavigate } from "react-router-dom";
import FilterListIcon from "@mui/icons-material/FilterList";

export interface PropertyItem {
uid: number;
Expand Down Expand Up @@ -373,13 +374,25 @@ function PrivatePropertyListPage() {
</StyledSelect>
</TypeButtonGroup>
<FilterButtonWrapper>
<FilterButton
variant="outlined"
onClick={() => setFilterModalOpen(true)}
>
상세 필터
</FilterButton>
</FilterButtonWrapper>
<FilterButton
variant="outlined"
onClick={() => setFilterModalOpen(true)}
sx={{
// 기존 스타일 유지
border: "1px solid #164F9E",
color: "#164F9E",
minWidth: "40px",
padding: "5px",
borderRadius: "14px",
"&:hover": {
backgroundColor: "#F5F5F5",
border: "1px solid #164F9E",
},
}}
>
<FilterListIcon />
</FilterButton>
</FilterButtonWrapper>
</LeftButtonGroup>
<RightButtonGroup>
<PropertyAddButtonList fetchPropertyData={fetchPropertyData} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ const PropertyTable = ({
{formatArea(property.netArea)}
</TableCell>
<TableCell align="center">
{property.details ?? "-"}
{property.details
? property.details.length > 20
? property.details.slice(0, 20) + "..."
: property.details
: "-"}
</TableCell>
</TableRow>
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,15 @@ const PublicPropertyFilterModal = ({
};

const handleApply = () => {
// Create filter object with region code
const regionCode = region.selectedDong || region.selectedSigungu || region.selectedSido || undefined;
let regionCode: string | undefined;
if (region.selectedDong) {
regionCode = String(region.selectedDong);
} else if (region.selectedSigungu) {
regionCode = String(region.selectedSigungu).slice(0, 5);
} else if (region.selectedSido) {
regionCode = String(region.selectedSido).slice(0, 2);
}

const updatedFilters = {
...localFilters,
regionCode,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/PublicPropertyListPage/PublicPropertyListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ function PublicPropertyListPage() {
<PageHeader title="공개 매물 목록" userName={user?.name || "-"} />
<Box sx={{ padding: "20px", paddingTop: "20px", backgroundColor: "#f5f5f5", minHeight: '100vh' }}>
{/* 상단 필터 바 컨테이너 */}
<Paper sx={{ p: 3, mb: 3, borderRadius: "8px", boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }}>
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2 }}>
<Paper sx={{ p: 3, mb: "28px", borderRadius: "8px", boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }}>
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Typography variant="h6" fontWeight="bold">
공개 매물 검색 결과 : {totalElements} 건
</Typography>
Expand Down