Skip to content

Commit b0b400a

Browse files
authored
Fix: 체크박스 선택 시 알림창 오류 수정 (#39)
* fix: 체크박스 선택 시 알림창 오류 수정
1 parent 0093d26 commit b0b400a

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

src/components/calendar/calendarFilterBar.vue

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div class="button-group top">
77
<!-- ✅ 내 조건 체크박스 -->
88
<label class="checkbox-label">
9-
<input type="checkbox" @change="startSelfCheck" />
9+
<input type="checkbox" ref="selfCheckRef" @change="startSelfCheck" />
1010
지원 가능한 청약만 보기
1111
</label>
1212
<button class="reset-btn" @click="resetAll()">필터 초기화</button>
@@ -74,6 +74,7 @@ import { calendarColorMap } from '@/assets/calendarColorMap.js';
7474
const router = useRouter();
7575
const emit = defineEmits(['update:filters']);
7676
77+
const selfCheckRef = ref(null);
7778
const currentTab = ref('공고유형');
7879
const tabOptions = ['공고유형', '공급지역'];
7980
@@ -126,10 +127,10 @@ const getTypeStyle = (code) => {
126127
};
127128
128129
const resetAll = () => {
129-
selectedChoice.value = {
130-
type: [],
131-
region: [],
132-
};
130+
selectedChoice.value = { type: [], region: [] };
131+
if (selfCheckRef.value) {
132+
selfCheckRef.value.checked = false; // 체크 해제
133+
}
133134
};
134135
135136
const toggleOption = (filterKey, option) => {
@@ -174,25 +175,29 @@ async function startSelfCheck(event) {
174175
const shouldLogin = window.confirm(
175176
'로그인이 필요한 서비스입니다. 로그인 하시겠습니까?'
176177
);
178+
event.target.checked = false;
177179
if (shouldLogin) {
178180
router.push('/login');
179181
}
180182
return;
181183
}
182184
183-
// 2. 로그인된 경우
185+
// 2. 로그인 된 경우 → 세대 정보 먼저 최신화
186+
await myPageStore.getHouseholdInfo();
187+
188+
if (householdInfoError.value) {
189+
const shouldSelfCheck = window.confirm(
190+
'지원 조건 확인을 위해 자가진단이 필요합니다. 자가진단 페이지로 이동할까요?'
191+
);
192+
if (shouldSelfCheck) router.push({ name: 'SelfCheck' });
193+
return;
194+
}
195+
196+
// 4. 체크박스 체크 시 지원가능 리스트 필터 적용
184197
if (isChecked) {
185-
await myPageStore.getSupportableList(); // 리스트 호출
186-
187-
if (householdInfoError.value) {
188-
const shouldSelfCheck = window.confirm(
189-
'지원 조건 확인을 위해 자가진단이 필요합니다. 자가진단 페이지로 이동할까요?'
190-
);
191-
if (shouldSelfCheck) router.push({ name: 'SelfCheck' });
192-
return;
193-
}
198+
await myPageStore.getSupportableList();
194199
195-
// calendarColorMap 기반 label → code 매핑 객체 생성
200+
// calendarColorMap 기반 label → code 매핑 객체
196201
const labelToCodeMap = Object.entries(calendarColorMap).reduce(
197202
(acc, [code, { label }]) => {
198203
acc[label] = code;
@@ -204,20 +209,23 @@ async function startSelfCheck(event) {
204209
// supportableList에서 code 목록 추출
205210
const supportedCodes = supportableList.value
206211
.map((item) => {
207-
// "공공분양""분양주택"으로 매핑
212+
// "공공분양""분양주택" 매핑
208213
const normalizedName =
209214
item.name === '공공분양' ? '분양주택' : item.name;
210215
return labelToCodeMap[normalizedName];
211216
})
212-
.filter(Boolean); // undefined 제거
217+
.filter(Boolean);
213218
214-
// 선택한 코드 저장
219+
// 필터에 반영
215220
selectedChoice.value.type = supportedCodes;
216221
} else {
222+
// 체크 해제 시 필터 해제
217223
selectedChoice.value.type = [];
218224
}
219225
} catch (error) {
220226
console.error('자가진단 필터 처리 중 오류 발생:', error);
227+
228+
event.target.checked = false;
221229
}
222230
}
223231
</script>

0 commit comments

Comments
 (0)