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.
32 lines
910 B
32 lines
910 B
/**
|
|
* 岗位评价管理 hook:拉取评价管理数据 + 回复评价。
|
|
*/
|
|
import { useCallback, useState } from 'react';
|
|
import { fetchJobEvaluationManagement, replyJobReview } from '../api';
|
|
import type { JobEvaluationManagement } from '../types';
|
|
import { useAsyncData } from './useAsyncData';
|
|
|
|
export function useJobEvaluations() {
|
|
const fetcher = useCallback(() => fetchJobEvaluationManagement(), []);
|
|
const { data, loading, error, refresh } = useAsyncData<JobEvaluationManagement>(fetcher);
|
|
|
|
const [replyingId, setReplyingId] = useState<string | null>(null);
|
|
|
|
const reply = useCallback(async (reviewId: string, content: string) => {
|
|
setReplyingId(reviewId);
|
|
try {
|
|
await replyJobReview(reviewId, content);
|
|
} finally {
|
|
setReplyingId(null);
|
|
}
|
|
}, []);
|
|
|
|
return {
|
|
management: data ?? null,
|
|
loading,
|
|
error,
|
|
refresh,
|
|
reply,
|
|
replyingId,
|
|
};
|
|
}
|
|
|