You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
818 B
26 lines
818 B
/**
|
|
* 岗位对比数据 hook
|
|
*/
|
|
import { useCallback } from 'react';
|
|
import { fetchCompareData } from '../api';
|
|
import type { CompareData } from '../types';
|
|
import { useAsyncData } from './useAsyncData';
|
|
|
|
/** 默认对比岗位 id(未显式传入时使用,保持引用稳定避免重复请求) */
|
|
const DEFAULT_COMPARE_JOB_IDS = ['1', '2', '3'];
|
|
|
|
export function useCompareData(jobIds: string[] = DEFAULT_COMPARE_JOB_IDS) {
|
|
const fetcher = useCallback(() => fetchCompareData(jobIds), [jobIds]);
|
|
|
|
const { data, loading, error, refresh } = useAsyncData<CompareData>(fetcher);
|
|
|
|
return {
|
|
jobs: data?.jobs ?? [],
|
|
dimensionScores: data?.dimensionScores ?? [],
|
|
basicInfo: data?.basicInfo ?? { fields: [], values: [] },
|
|
benefits: data?.benefits ?? [],
|
|
loading,
|
|
error,
|
|
refresh,
|
|
};
|
|
}
|