-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored empty filter function and removed it from useFilterDropdown hook
- Loading branch information
1 parent
654a0bb
commit c716a30
Showing
4 changed files
with
50 additions
and
21 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
...cord/object-filter-dropdown/components/ObjectFilterDropdownRecordRemoveFilterMenuItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...enty-front/src/modules/object-record/object-filter-dropdown/hooks/useEmptyRecordFilter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { objectFilterDropdownSearchInputComponentState } from '@/object-record/object-filter-dropdown/states/objectFilterDropdownSearchInputComponentState'; | ||
import { objectFilterDropdownSelectedRecordIdsComponentState } from '@/object-record/object-filter-dropdown/states/objectFilterDropdownSelectedRecordIdsComponentState'; | ||
import { selectedFilterComponentState } from '@/object-record/object-filter-dropdown/states/selectedFilterComponentState'; | ||
import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; | ||
import { useRecoilCallback } from 'recoil'; | ||
|
||
export const useEmptyRecordFilter = (componentInstanceId?: string) => { | ||
const objectFilterDropdownSearchInputCallbackState = | ||
useRecoilComponentCallbackStateV2( | ||
objectFilterDropdownSearchInputComponentState, | ||
componentInstanceId, | ||
); | ||
|
||
const objectFilterDropdownSelectedRecordIdsCallbackState = | ||
useRecoilComponentCallbackStateV2( | ||
objectFilterDropdownSelectedRecordIdsComponentState, | ||
componentInstanceId, | ||
); | ||
|
||
const selectedFilterCallbackState = useRecoilComponentCallbackStateV2( | ||
selectedFilterComponentState, | ||
componentInstanceId, | ||
); | ||
|
||
const emptyRecordFilter = useRecoilCallback( | ||
({ set }) => | ||
() => { | ||
set(objectFilterDropdownSearchInputCallbackState, ''); | ||
set(objectFilterDropdownSelectedRecordIdsCallbackState, []); | ||
set(selectedFilterCallbackState, undefined); | ||
}, | ||
[ | ||
objectFilterDropdownSearchInputCallbackState, | ||
objectFilterDropdownSelectedRecordIdsCallbackState, | ||
selectedFilterCallbackState, | ||
], | ||
); | ||
|
||
return { | ||
emptyRecordFilter, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters