3157 refactor scoped states to move to v3 (#3180)
* renaming * renaming * create getDropdownScopeInjectors * update useDropdown * create internal hooks folder * update record-table states to be scoped states * update record-table selectors to be scoped selectors * create utils scope injector * refactor record-table wip * refactor record-table wip * wip * inject scopeId in selectors * update intenal hooks * update intenal hooks * update intenal hooks * update intenal hooks * update intenal hooks * update intenal hooks * update internal hooks * update internal hooks * update internal hooks * update internal hooks * update useTableColumns * update states and hooks * refactoring * refactoring * refactoring * refactoring * refactoring * refactoring * refactoring * refactoring * refactoring * fix scopeId not in context * fix lint errors * fix error in story * fix errors: wip * fix errors * fix error * fix jest test * fix scopeId not defined * fix jest test * Bug fixes --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
|
||||
import { ActivityType } from '@/activities/types/Activity';
|
||||
import { selectedRowIdsSelector } from '@/object-record/record-table/states/selectors/selectedRowIdsSelector';
|
||||
import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';
|
||||
import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';
|
||||
|
||||
import {
|
||||
ActivityTargetableEntity,
|
||||
@ -10,9 +11,16 @@ import {
|
||||
|
||||
import { useOpenCreateActivityDrawer } from './useOpenCreateActivityDrawer';
|
||||
|
||||
export const useOpenCreateActivityDrawerForSelectedRowIds = () => {
|
||||
export const useOpenCreateActivityDrawerForSelectedRowIds = (
|
||||
recordTableScopeId: string,
|
||||
) => {
|
||||
const openCreateActivityDrawer = useOpenCreateActivityDrawer();
|
||||
|
||||
const { selectedRowIdsScopeInjector } = getRecordTableScopeInjector();
|
||||
|
||||
const { injectSelectorSnapshotValueWithRecordTableScopeId } =
|
||||
useRecordTableScopedStates(recordTableScopeId);
|
||||
|
||||
return useRecoilCallback(
|
||||
({ snapshot }) =>
|
||||
(
|
||||
@ -20,9 +28,12 @@ export const useOpenCreateActivityDrawerForSelectedRowIds = () => {
|
||||
entityType: ActivityTargetableEntityType,
|
||||
relatedEntities?: ActivityTargetableEntity[],
|
||||
) => {
|
||||
const selectedRowIds = snapshot
|
||||
.getLoadable(selectedRowIdsSelector)
|
||||
.getValue();
|
||||
const selectedRowIds =
|
||||
injectSelectorSnapshotValueWithRecordTableScopeId(
|
||||
snapshot,
|
||||
selectedRowIdsScopeInjector,
|
||||
);
|
||||
|
||||
let activityTargetableEntityArray: ActivityTargetableEntity[] =
|
||||
selectedRowIds.map((id: string) => ({
|
||||
type: entityType,
|
||||
@ -37,6 +48,10 @@ export const useOpenCreateActivityDrawerForSelectedRowIds = () => {
|
||||
targetableEntities: activityTargetableEntityArray,
|
||||
});
|
||||
},
|
||||
[openCreateActivityDrawer],
|
||||
[
|
||||
injectSelectorSnapshotValueWithRecordTableScopeId,
|
||||
openCreateActivityDrawer,
|
||||
selectedRowIdsScopeInjector,
|
||||
],
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user