import * as electronSignServices from '@12333/services/apiV2/electronSign';
|
import { useQuery, useQueryClient } from '@tanstack/vue-query';
|
import { getUserCertificationFrontStatusAdapter } from '@12333/utils';
|
import { UserCertificationFrontStatus } from '@12333/constants';
|
import { useUser } from './user';
|
|
type UseMyCertificationAuditInfoOptions = {
|
onSuccess?: (data: API.GetPersonalUserRealResultQueryResult) => void;
|
};
|
|
export function useMyCertificationAuditInfo(options: UseMyCertificationAuditInfoOptions = {}) {
|
const { onSuccess } = options;
|
|
const { updateUserInfo } = useUser();
|
|
const queryClient = useQueryClient();
|
|
const { data, isLoading } = useQuery({
|
queryKey: ['electronSignServices/getPersonalUserRealResult'],
|
queryFn: async () => {
|
return await electronSignServices.getPersonalUserRealResult({}, { showLoading: false });
|
},
|
placeholderData: () => null as API.GetPersonalUserRealResultQueryResult,
|
select(data) {
|
return data;
|
},
|
onSuccess(data) {
|
onSuccess?.(data);
|
},
|
});
|
|
function invalidateCertificationAuditInfo() {
|
updateUserInfo();
|
return queryClient.invalidateQueries({
|
queryKey: ['electronSignServices/getPersonalUserRealResult'],
|
});
|
}
|
|
function ensureCertificationAuditInfo() {
|
return queryClient.ensureQueryData({
|
queryKey: ['electronSignServices/getPersonalUserRealResult'],
|
});
|
}
|
|
return {
|
myCertificationAuditInfo: data,
|
isLoading,
|
invalidateCertificationAuditInfo,
|
ensureCertificationAuditInfo,
|
};
|
}
|