Fix component id to scope id (#5035)

This pull request fixes the component id to scope id in the
useUpsertRecordV2 function.
This commit is contained in:
Lucas Bordeau
2024-04-18 15:24:15 +02:00
committed by GitHub
parent 8702c71d45
commit df49575c3e

View File

@ -3,6 +3,7 @@ import { useRecoilCallback } from 'recoil';
import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord'; import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord';
import { recordFieldInputDraftValueComponentSelector } from '@/object-record/record-field/states/selectors/recordFieldInputDraftValueComponentSelector'; import { recordFieldInputDraftValueComponentSelector } from '@/object-record/record-field/states/selectors/recordFieldInputDraftValueComponentSelector';
import { recordTablePendingRecordIdComponentState } from '@/object-record/record-table/states/recordTablePendingRecordIdComponentState'; 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 { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue';
import { extractComponentSelector } from '@/ui/utilities/state/component-state/utils/extractComponentSelector'; import { extractComponentSelector } from '@/ui/utilities/state/component-state/utils/extractComponentSelector';
import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState'; import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState';
@ -23,8 +24,10 @@ export const useUpsertRecordV2 = ({
persistField: () => void, persistField: () => void,
entityId: string, entityId: string,
fieldName: string, fieldName: string,
tableScopeId: string, recordTableId: string,
) => { ) => {
const tableScopeId = getScopeIdFromComponentId(recordTableId);
const recordTablePendingRecordIdState = extractComponentState( const recordTablePendingRecordIdState = extractComponentState(
recordTablePendingRecordIdComponentState, recordTablePendingRecordIdComponentState,
tableScopeId, tableScopeId,
@ -34,7 +37,9 @@ export const useUpsertRecordV2 = ({
snapshot, snapshot,
recordTablePendingRecordIdState, recordTablePendingRecordIdState,
); );
const fieldScopeId = `${entityId}-${fieldName}`; const fieldScopeId = getScopeIdFromComponentId(
`${entityId}-${fieldName}`,
);
const draftValueSelector = extractComponentSelector( const draftValueSelector = extractComponentSelector(
recordFieldInputDraftValueComponentSelector, recordFieldInputDraftValueComponentSelector,