Skip to content

Commit

Permalink
Fix component id to scope id (twentyhq#5035)
Browse files Browse the repository at this point in the history
This pull request fixes the component id to scope id in the
useUpsertRecordV2 function.
  • Loading branch information
lucasbordeau authored Apr 18, 2024
1 parent 8702c71 commit df49575
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useRecoilCallback } from 'recoil';
import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord';
import { recordFieldInputDraftValueComponentSelector } from '@/object-record/record-field/states/selectors/recordFieldInputDraftValueComponentSelector';
import { recordTablePendingRecordIdComponentState } from '@/object-record/record-table/states/recordTablePendingRecordIdComponentState';
import { getScopeIdFromComponentId } from '@/ui/utilities/recoil-scope/utils/getScopeIdFromComponentId';
import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue';
import { extractComponentSelector } from '@/ui/utilities/state/component-state/utils/extractComponentSelector';
import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState';
Expand All @@ -23,8 +24,10 @@ export const useUpsertRecordV2 = ({
persistField: () => void,
entityId: string,
fieldName: string,
tableScopeId: string,
recordTableId: string,
) => {
const tableScopeId = getScopeIdFromComponentId(recordTableId);

const recordTablePendingRecordIdState = extractComponentState(
recordTablePendingRecordIdComponentState,
tableScopeId,
Expand All @@ -34,7 +37,9 @@ export const useUpsertRecordV2 = ({
snapshot,
recordTablePendingRecordIdState,
);
const fieldScopeId = `${entityId}-${fieldName}`;
const fieldScopeId = getScopeIdFromComponentId(
`${entityId}-${fieldName}`,
);

const draftValueSelector = extractComponentSelector(
recordFieldInputDraftValueComponentSelector,
Expand Down

0 comments on commit df49575

Please sign in to comment.