Fix post merge (#6699)

Fixed settingsPreviewRecordId state naming.
This commit is contained in:
Lucas Bordeau 2024-08-20 16:45:00 +02:00 committed by GitHub
parent be20a690b3
commit 3ae89d15de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 21 additions and 18 deletions

View File

@ -27,6 +27,7 @@ export const StyledSelectableItem = styled(SelectableItem)`
height: 100%;
width: 100%;
`;
export const MultiRecordSelect = ({
onChange,
onSubmit,

View File

@ -10,7 +10,7 @@ import { FieldContext } from '@/object-record/record-field/contexts/FieldContext
import { BooleanFieldInput } from '@/object-record/record-field/meta-types/input/components/BooleanFieldInput';
import { RatingFieldInput } from '@/object-record/record-field/meta-types/input/components/RatingFieldInput';
import { SettingsDataModelSetFieldValueEffect } from '@/settings/data-model/fields/preview/components/SettingsDataModelSetFieldValueEffect';
import { SettingsDataModelSetRecordEffect } from '@/settings/data-model/fields/preview/components/SettingsDataModelSetRecordEffect';
import { SettingsDataModelSetPreviewRecordEffect } from '@/settings/data-model/fields/preview/components/SettingsDataModelSetRecordEffect';
import { useFieldPreviewValue } from '@/settings/data-model/fields/preview/hooks/useFieldPreviewValue';
import { usePreviewRecord } from '@/settings/data-model/fields/preview/hooks/usePreviewRecord';
import { FieldMetadataType } from '~/generated-metadata/graphql';
@ -96,7 +96,7 @@ export const SettingsDataModelFieldPreview = ({
return (
<>
{previewRecord ? (
<SettingsDataModelSetRecordEffect
<SettingsDataModelSetPreviewRecordEffect
fieldName={fieldName}
record={previewRecord}
/>

View File

@ -1,7 +1,7 @@
import { useSetRecordFieldValue } from '@/object-record/record-store/contexts/RecordFieldValueSelectorContext';
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector';
import { previewRecordIdState } from '@/settings/data-model/fields/preview/states/previewRecordIdState';
import { settingsPreviewRecordIdState } from '@/settings/data-model/fields/preview/states/settingsPreviewRecordIdState';
import { useEffect } from 'react';
import { useRecoilValue, useSetRecoilState } from 'recoil';
import { isDefined } from '~/utils/isDefined';
@ -17,10 +17,10 @@ export const SettingsDataModelSetFieldValueEffect = ({
fieldName,
value,
}: SettingsDataModelSetFieldValueEffectProps) => {
const previewRecordId = useRecoilValue(previewRecordIdState);
const settingsPreviewRecordId = useRecoilValue(settingsPreviewRecordIdState);
const upsertedPreviewRecord = useRecoilValue(
recordStoreFamilyState(previewRecordId ?? ''),
recordStoreFamilyState(settingsPreviewRecordId ?? ''),
);
const setFieldValue = useSetRecoilState(

View File

@ -1,34 +1,36 @@
import { useSetRecordFieldValue } from '@/object-record/record-store/contexts/RecordFieldValueSelectorContext';
import { useUpsertRecordsInStore } from '@/object-record/record-store/hooks/useUpsertRecordsInStore';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { previewRecordIdState } from '@/settings/data-model/fields/preview/states/previewRecordIdState';
import { settingsPreviewRecordIdState } from '@/settings/data-model/fields/preview/states/settingsPreviewRecordIdState';
import { useEffect } from 'react';
import { useSetRecoilState } from 'recoil';
type SettingsDataModelSetRecordEffectProps = {
type SettingsDataModelSetPreviewRecordEffectProps = {
record: ObjectRecord;
fieldName: string;
};
export const SettingsDataModelSetRecordEffect = ({
export const SettingsDataModelSetPreviewRecordEffect = ({
record,
fieldName,
}: SettingsDataModelSetRecordEffectProps) => {
}: SettingsDataModelSetPreviewRecordEffectProps) => {
const { upsertRecords: upsertRecordsInStore } = useUpsertRecordsInStore();
const setRecordFieldValue = useSetRecordFieldValue();
const setPreviewRecordId = useSetRecoilState(previewRecordIdState);
const setSettingsPreviewRecordId = useSetRecoilState(
settingsPreviewRecordIdState,
);
useEffect(() => {
upsertRecordsInStore([record]);
setRecordFieldValue(record.id, fieldName, record[fieldName]);
setPreviewRecordId(record.id);
setSettingsPreviewRecordId(record.id);
}, [
record,
upsertRecordsInStore,
setRecordFieldValue,
fieldName,
setPreviewRecordId,
setSettingsPreviewRecordId,
]);
return null;

View File

@ -1,6 +0,0 @@
import { createState } from 'twenty-ui';
export const previewRecordIdState = createState<string | null>({
key: 'previewRecordId',
defaultValue: null,
});

View File

@ -0,0 +1,6 @@
import { createState } from 'twenty-ui';
export const settingsPreviewRecordIdState = createState<string | null>({
key: 'settingsPreviewRecordIdState',
defaultValue: null,
});