Skip to content

Commit 9183ae8

Browse files
authored
Merge pull request #89 from TaskFlow-CLAP/CLAP-256
CLAP-256 작업 거부 API 연결
2 parents 74faaee + 8804f6c commit 9183ae8

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

src/components/ModalView.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ watch(textValue, newValue => {
9292
})
9393
9494
const closeModal = () => {
95+
textValue.value = ''
9596
emit('close')
9697
}
9798

src/components/requested/RequestedListCard.vue

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,34 @@
1414
class="button-medium-primary">
1515
승인
1616
</button>
17-
<button class="button-medium-default">거부</button>
17+
<button
18+
@click="toggleModal('reject')"
19+
class="button-medium-default">
20+
거부
21+
</button>
1822
</div>
1923
</div>
24+
25+
<ModalView
26+
:is-open="isModalVisible.reject"
27+
@update:model-value="value => (rejectReason = value)"
28+
type="inputType"
29+
@close="closeModal"
30+
@click="rejectRequest">
31+
<template #header>거부 사유를 입력해주세요</template>
32+
</ModalView>
33+
<ModalView
34+
:is-open="isModalVisible.success"
35+
type="successType"
36+
@close="closeModal">
37+
<template #header>거부가 완료되었습니다</template>
38+
</ModalView>
39+
<ModalView
40+
:is-open="isModalVisible.fail"
41+
type="failType"
42+
@close="closeModal">
43+
<template #header>{{ modalError }}</template>
44+
</ModalView>
2045
</template>
2146

2247
<script setup lang="ts">
@@ -25,6 +50,10 @@ import ListCardTab from '../lists/ListCardTab.vue'
2550
import type { RequestedListData } from '@/types/manager'
2651
import { useRouter } from 'vue-router'
2752
import { formatDate } from '@/utils/date'
53+
import ModalView from '../ModalView.vue'
54+
import { ref } from 'vue'
55+
import { axiosInstance } from '@/utils/axios'
56+
import { useQueryClient } from '@tanstack/vue-query'
2857
2958
const { info } = defineProps<{ info: RequestedListData }>()
3059
const requestedTabList: ListCardProps[] = [
@@ -36,4 +65,37 @@ const requestedTabList: ListCardProps[] = [
3665
]
3766
3867
const router = useRouter()
68+
const queryClient = useQueryClient()
69+
70+
const isModalVisible = ref({
71+
reject: false,
72+
fail: false,
73+
success: false
74+
})
75+
const modalError = ref('')
76+
const rejectReason = ref('')
77+
const toggleModal = (key: keyof typeof isModalVisible.value) => {
78+
isModalVisible.value = Object.fromEntries(
79+
Object.keys(isModalVisible.value).map(k => [k, k === key])
80+
) as typeof isModalVisible.value
81+
}
82+
const closeModal = () => {
83+
const prevSuccess = isModalVisible.value.success
84+
isModalVisible.value = { reject: false, fail: false, success: false }
85+
if (prevSuccess) queryClient.invalidateQueries({ queryKey: ['requested'] })
86+
}
87+
const rejectRequest = async () => {
88+
if (rejectReason.value.length === 0) {
89+
toggleModal('fail')
90+
modalError.value = '거부 사유를 입력해주세요'
91+
return
92+
}
93+
try {
94+
await axiosInstance.patch(`/api/tasks/${info.taskId}/terminate`, rejectReason)
95+
toggleModal('success')
96+
} catch {
97+
toggleModal('fail')
98+
modalError.value = '작업 거부에 실패했습니다'
99+
}
100+
}
39101
</script>

0 commit comments

Comments
 (0)