| | |
| | | EnumTaskStatus, |
| | | EnumUserGender, |
| | | EnumTaskUserApplyStatus, |
| | | EnumReadScene, |
| | | } from '@12333/constants'; |
| | | import _ from 'lodash'; |
| | | import { OrderUtils, trim } from '@12333/utils'; |
| | |
| | | |
| | | type UseTaskInfoOptions = { |
| | | id: MaybeRef<string>; |
| | | readScene?: string | EnumReadScene; |
| | | onSuccess?: (data: API.GetTaskInfoQueryResult) => any; |
| | | }; |
| | | |
| | | export function useTaskInfo({ id, onSuccess }: UseTaskInfoOptions) { |
| | | export function useTaskInfo({ id, readScene, onSuccess }: UseTaskInfoOptions) { |
| | | const { |
| | | isLoading, |
| | | isError, |
| | | data: detail, |
| | | refetch, |
| | | } = useQuery({ |
| | | queryKey: ['taskServices/getTaskInfo', id], |
| | | queryKey: ['taskServices/getTaskInfo', id, readScene], |
| | | queryFn: async () => { |
| | | return await taskServices.getTaskInfo( |
| | | { id: unref(id) }, |
| | | { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | const params: API.APIgetTaskInfoParams = { |
| | | id: unref(id), |
| | | }; |
| | | if (!!readScene) { |
| | | params.readScene = Number(readScene); |
| | | } |
| | | return await taskServices.getTaskInfo(params, { |
| | | showLoading: false, |
| | | }); |
| | | }, |
| | | placeholderData: () => ({} as API.GetTaskInfoQueryResult), |
| | | onSuccess(data) { |