fix: reset fair statistics filters on type switch
This commit is contained in:
@@ -89,11 +89,19 @@ const FairStatistics: React.FC = () => {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
loadFairOptions(fairType);
|
||||
}, [fairType, loadFairOptions]);
|
||||
|
||||
const handleFairTypeChange = (type: RecruitmentFairType) => {
|
||||
if (type === fairType) return;
|
||||
|
||||
// 切换类型时同步清空条件,避免新类型携带旧类型招聘会 ID 发起查询。
|
||||
setSelectedFairId(undefined);
|
||||
setDateRange(null);
|
||||
setSummary(undefined);
|
||||
loadFairOptions(fairType);
|
||||
}, [fairType, loadFairOptions]);
|
||||
setFairOptions([]);
|
||||
setFairType(type);
|
||||
};
|
||||
|
||||
const queryReady = useMemo(() => {
|
||||
if (scope === 'single') return Boolean(selectedFairId);
|
||||
@@ -161,13 +169,13 @@ const FairStatistics: React.FC = () => {
|
||||
<Button.Group>
|
||||
<Button
|
||||
type={fairType === 'online' ? 'primary' : 'default'}
|
||||
onClick={() => setFairType('online')}
|
||||
onClick={() => handleFairTypeChange('online')}
|
||||
>
|
||||
线上招聘会
|
||||
</Button>
|
||||
<Button
|
||||
type={fairType === 'outdoor' ? 'primary' : 'default'}
|
||||
onClick={() => setFairType('outdoor')}
|
||||
onClick={() => handleFairTypeChange('outdoor')}
|
||||
>
|
||||
户外招聘会
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user