Skip to content

Commit da47d8a

Browse files
committed
♻️ [refactor] 2차 카테고리 추가 시 1차 카테고리 기본 설정
1 parent 7595a4e commit da47d8a

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/components/task-management/CategoryAdd.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,14 @@ onMounted(async () => {
157157
}
158158
}
159159
} else if (categoryStep === '2') {
160-
categoryOptions.value = await getMainCategory()
160+
const mainCategories: Category[] = await getMainCategory()
161+
categoryOptions.value = mainCategories
162+
if (!id) {
163+
const mainCategoryId = ref(Number(route.query.mainCategoryId))
164+
categoryForm.value.mainCategoryId = mainCategoryId.value
165+
mainCategory.value =
166+
categoryOptions.value.find(el => el.mainCategoryId === mainCategoryId.value)?.name || ''
167+
}
161168
if (id) {
162169
const { data: initialValue } = await axiosInstance.get(`/api/sub-categories/${id}`)
163170
if (initialValue) {

src/components/task-management/CategoryLineSub.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</div>
4040
<div
4141
class="category-management-line gap-1 justify-center cursor-pointer bg-white hover:bg-background-2"
42-
@click="MovetoAddSubCategory">
42+
@click="MovetoAddSubCategory(main.mainCategoryId)">
4343
<CommonIcons :name="plusIcon" />
4444
<p class="text-xs text-disabled font-bold">새 2차 카테고리 추가</p>
4545
</div>
@@ -80,7 +80,7 @@ const deleteCategory = async (id: number) => {
8080
closeModal()
8181
}
8282
83-
const MovetoAddSubCategory = () => {
84-
router.push('/category-second')
83+
const MovetoAddSubCategory = (id: number) => {
84+
router.push(`/category-second?mainCategoryId=${id}`)
8585
}
8686
</script>

src/utils/axios.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ const setInterceptors = (instance: AxiosInstance) => {
4444
response => response,
4545
async error => {
4646
const { setError } = useErrorStore()
47-
console.log(error)
4847
if (axios.isCancel(error)) {
4948
setError('요청이 취소되었습니다:', error.message)
5049
} else if (error.response) {

0 commit comments

Comments
 (0)