Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
36 changes: 30 additions & 6 deletions src/components/my-task/MyTaskList.vue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 데이터 요청하시면서 탠스택 쿼리를 쓰시는 곳에 기준이 있으실까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

보통 GET에는 항상 탠스택 쿼리를 사용하는 것 같습니다.
값을 캐싱해주기 때문에 불필요하게 데이터가 반복적으로 갱신되어 화면에서 깜빡 거리는 것을 최소화할 수 있고,
select 옵션을 통해 값을 가공하거나, isLoading, isPending 등 상태값을 제공해주는 것도 자주 사용하기 때문에
GET을 통해 데이터를 받아올 때에는 별다른 기준 없이 항상 사용하고 있습니다.

Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@

<template #listCards>
<MyTaskListCard
v-for="info in DUMMY_MY_TASK_LIST_DATA"
v-for="info in data?.content"
:key="info.taskId"
:info="info" />
<NoContent v-if="data?.content.length === 0" />
</template>

<template #pagination>
<ListPagination
:page-number="params.page"
:total-page="DUMMY_TOTAL_PAGE"
:page-number="params.page + 1"
:total-page="totalPage || 0"
@update:page-number="onPageChange" />
</template>
</ListContainer>
Expand All @@ -23,16 +24,39 @@
<script setup lang="ts">
import ListPagination from '../lists/ListPagination.vue'
import ListContainer from '../lists/ListContainer.vue'
import { DUMMY_MY_TASK_LIST_DATA } from '@/datas/dummy'
import { useRequestParamsStore } from '@/stores/params'
import MyTaskListCard from './MyTaskListCard.vue'
import MyTaskListBar from './MyTaskListBar.vue'
import { useParseParams } from '../hooks/useParseParams'
import axiosInstance from '@/utils/axios'
import type { MyTaskResponse } from '@/types/manager'
import { useQuery } from '@tanstack/vue-query'
import { computed } from 'vue'
import NoContent from '../lists/NoContent.vue'

const { params } = useRequestParamsStore()
const DUMMY_TOTAL_PAGE = 18
const onPageChange = (value: number) => {
params.page = value
}

// Data Handling
const fetchMyTaskList = async () => {
const { parseRequestParams } = useParseParams()
const parsedParams = parseRequestParams(params)
const response = await axiosInstance.get('/api/tasks/assigned', {
headers: {
Authorization: `Bearer ${import.meta.env.VITE_ACCESS_TOKEN}`
},
params: parsedParams
})
return response.data
}

const { data } = useQuery<MyTaskResponse>({
queryKey: ['myTask', params],
queryFn: fetchMyTaskList
})

const totalPage = computed(() => {
return data.value?.totalPages
})
</script>
5 changes: 3 additions & 2 deletions src/components/my-task/MyTaskListCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
import type { ListCardProps } from '@/types/common'
import ListCardTab from '../lists/ListCardTab.vue'
import type { MyTaskListData } from '@/types/manager'
import { formatDate } from '@/utils/date'

const { info } = defineProps<{ info: MyTaskListData }>()
const myRequestTabList: ListCardProps[] = [
{ content: info.taskCode, width: 120, isTextXs: true },
{ content: info.requestedAt, width: 80 },
{ content: formatDate(info.requestedAt), width: 80 },
{ content: info.mainCategoryName, width: 80 },
{ content: info.categoryName, width: 80 },
{ content: info.title },
{ content: info.requesterName, width: 120, profileImg: info.requesterImg },
{ content: info.taskStatus, width: 64, isStatus: true },
{ content: info.finishedAt, width: 80 }
{ content: info.finishedAt ? formatDate(info.finishedAt) : '', width: 80 }
]
</script>
2 changes: 2 additions & 0 deletions src/components/request-history/RequestHistoryList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
v-for="info in data?.content"
:key="info.taskId"
:info="info" />
<NoContent v-if="data?.content.length === 0" />
</template>

<template #pagination>
Expand All @@ -31,6 +32,7 @@ import axiosInstance from '@/utils/axios'
import { useQuery } from '@tanstack/vue-query'
import { computed } from 'vue'
import type { RequestHistoryResponse } from '@/types/manager'
import NoContent from '../lists/NoContent.vue'

const { params } = useRequestParamsStore()
const onPageChange = (value: number) => {
Expand Down
Loading