import * as dictionaryServices from '@/services/api/Dictionary';
|
import { useQuery, useQueryClient } from '@tanstack/vue-query';
|
|
export function useInsureProductSettingAllList() {
|
const { data: allInsureProductSettingList, refetch } = useQuery({
|
queryKey: ['dictionaryServices/getInsureProductSettingAllList'],
|
queryFn: async () => {
|
let res = await dictionaryServices.getInsureProductSettingAllList({}, { showLoading: false });
|
return res;
|
},
|
placeholderData: () => [] as API.InsureProductSettingDto[],
|
});
|
|
return {
|
allInsureProductSettingList,
|
refetch,
|
};
|
}
|
|
export function useUserInsureProductSetting() {
|
const { data: allUserInsureProductSettingList, refetch } = useQuery({
|
queryKey: ['dictionaryServices/getUserInsureProductSetting'],
|
queryFn: async () => {
|
let res = await dictionaryServices.getUserInsureProductSetting({ showLoading: false });
|
return res;
|
},
|
placeholderData: () => [] as API.InsureProductSettingDto[],
|
});
|
|
function getInsureProductByIdNumber(productIdNumber: string) {
|
return allUserInsureProductSettingList.value.find((x) => x.productIdNumber === productIdNumber);
|
}
|
|
function getInsureProductIdByIdNumber(productIdNumber: string) {
|
const insureProduct = getInsureProductByIdNumber(productIdNumber);
|
return insureProduct?.id ?? '';
|
}
|
|
return {
|
allUserInsureProductSettingList,
|
getInsureProductByIdNumber,
|
getInsureProductIdByIdNumber,
|
refetch,
|
};
|
}
|
|
type UseInsureProductSchemeAllListOptions = {
|
insureProductId?: MaybeRef<string>;
|
};
|
|
export function useInsureProductSchemeAllList(options: UseInsureProductSchemeAllListOptions = {}) {
|
const { insureProductId } = options;
|
|
const { data: allInsureProductSchemeList, refetch } = useQuery({
|
queryKey: ['dictionaryServices/getInsureProductSchemeAllList', insureProductId],
|
queryFn: async () => {
|
let res = await dictionaryServices.getInsureProductSchemeAllList(
|
{
|
insureProductId: unref(insureProductId),
|
},
|
{ showLoading: false }
|
);
|
return res;
|
},
|
placeholderData: () => [] as API.InsureProductSchemeDto[],
|
enabled: computed(() => !!unref(insureProductId)),
|
staleTime: Infinity,
|
});
|
|
return {
|
allInsureProductSchemeList,
|
refetch,
|
};
|
}
|