Skip to content

Commit

Permalink
fix: fix args passed to assertFieldMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
thaisguigon committed Mar 25, 2024
1 parent dac5253 commit df8eb8e
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useContext } from 'react';
import { useRecoilState } from 'recoil';

import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector';
import { FieldMetadataType } from '~/generated-metadata/graphql';

import { FieldContext } from '../../contexts/FieldContext';
import { assertFieldMetadata } from '../../types/guards/assertFieldMetadata';
Expand All @@ -10,7 +11,11 @@ import { isFieldBoolean } from '../../types/guards/isFieldBoolean';
export const useBooleanField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);

assertFieldMetadata('BOOLEAN', isFieldBoolean, fieldDefinition);
assertFieldMetadata(
FieldMetadataType.Boolean,
isFieldBoolean,
fieldDefinition,
);

const fieldName = fieldDefinition.metadata.fieldName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useRecoilState, useRecoilValue } from 'recoil';

import { useRecordFieldInput } from '@/object-record/record-field/hooks/useRecordFieldInput';
import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector';
import { FieldMetadataType } from '~/generated-metadata/graphql';
import { canBeCastAsIntegerOrNull } from '~/utils/cast-as-integer-or-null';
import { convertCurrencyToCurrencyMicros } from '~/utils/convert-currency-amount';

Expand All @@ -16,7 +17,11 @@ import { isFieldCurrencyValue } from '../../types/guards/isFieldCurrencyValue';
export const useCurrencyField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);

assertFieldMetadata('CURRENCY', isFieldCurrency, fieldDefinition);
assertFieldMetadata(
FieldMetadataType.Currency,
isFieldCurrency,
fieldDefinition,
);

const fieldName = fieldDefinition.metadata.fieldName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useRecoilState } from 'recoil';
import { useRecordFieldInput } from '@/object-record/record-field/hooks/useRecordFieldInput';
import { FieldDateTimeValue } from '@/object-record/record-field/types/FieldMetadata';
import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector';
import { FieldMetadataType } from '~/generated-metadata/graphql';

import { FieldContext } from '../../contexts/FieldContext';
import { assertFieldMetadata } from '../../types/guards/assertFieldMetadata';
Expand All @@ -13,7 +14,11 @@ export const useDateTimeField = () => {
const { entityId, fieldDefinition, hotkeyScope, clearable } =
useContext(FieldContext);

assertFieldMetadata('DATE_TIME', isFieldDateTime, fieldDefinition);
assertFieldMetadata(
FieldMetadataType.DateTime,
isFieldDateTime,
fieldDefinition,
);

const fieldName = fieldDefinition.metadata.fieldName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useRecoilState, useRecoilValue } from 'recoil';
import { useRecordFieldInput } from '@/object-record/record-field/hooks/useRecordFieldInput';
import { FieldEmailValue } from '@/object-record/record-field/types/FieldMetadata';
import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector';
import { FieldMetadataType } from '~/generated-metadata/graphql';

import { FieldContext } from '../../contexts/FieldContext';
import { assertFieldMetadata } from '../../types/guards/assertFieldMetadata';
Expand All @@ -12,7 +13,7 @@ import { isFieldEmail } from '../../types/guards/isFieldEmail';
export const useEmailField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);

assertFieldMetadata('EMAIL', isFieldEmail, fieldDefinition);
assertFieldMetadata(FieldMetadataType.Email, isFieldEmail, fieldDefinition);

const fieldName = fieldDefinition.metadata.fieldName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useRecoilState, useRecoilValue } from 'recoil';

import { useRecordFieldInput } from '@/object-record/record-field/hooks/useRecordFieldInput';
import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector';
import { FieldMetadataType } from '~/generated-metadata/graphql';

import { FieldContext } from '../../contexts/FieldContext';
import { usePersistField } from '../../hooks/usePersistField';
Expand All @@ -14,7 +15,11 @@ import { isFieldFullNameValue } from '../../types/guards/isFieldFullNameValue';
export const useFullNameField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);

assertFieldMetadata('FULL_NAME', isFieldFullName, fieldDefinition);
assertFieldMetadata(
FieldMetadataType.FullName,
isFieldFullName,
fieldDefinition,
);

const fieldName = fieldDefinition.metadata.fieldName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useRecoilState, useRecoilValue } from 'recoil';

import { useRecordFieldInput } from '@/object-record/record-field/hooks/useRecordFieldInput';
import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector';
import { FieldMetadataType } from '~/generated-metadata/graphql';

import { FieldContext } from '../../contexts/FieldContext';
import { usePersistField } from '../../hooks/usePersistField';
Expand All @@ -14,7 +15,7 @@ import { isFieldLinkValue } from '../../types/guards/isFieldLinkValue';
export const useLinkField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);

assertFieldMetadata('LINK', isFieldLink, fieldDefinition);
assertFieldMetadata(FieldMetadataType.Link, isFieldLink, fieldDefinition);

const fieldName = fieldDefinition.metadata.fieldName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useRecoilState, useRecoilValue } from 'recoil';
import { useRecordFieldInput } from '@/object-record/record-field/hooks/useRecordFieldInput';
import { FieldNumberValue } from '@/object-record/record-field/types/FieldMetadata';
import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector';
import { FieldMetadataType } from '~/generated-metadata/graphql';
import {
canBeCastAsIntegerOrNull,
castAsIntegerOrNull,
Expand All @@ -17,7 +18,7 @@ import { isFieldNumber } from '../../types/guards/isFieldNumber';
export const useNumberField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);

assertFieldMetadata('NUMBER', isFieldNumber, fieldDefinition);
assertFieldMetadata(FieldMetadataType.Number, isFieldNumber, fieldDefinition);

const fieldName = fieldDefinition.metadata.fieldName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useRecoilState, useRecoilValue } from 'recoil';
import { useRecordFieldInput } from '@/object-record/record-field/hooks/useRecordFieldInput';
import { FieldPhoneValue } from '@/object-record/record-field/types/FieldMetadata';
import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector';
import { FieldMetadataType } from '~/generated-metadata/graphql';

import { FieldContext } from '../../contexts/FieldContext';
import { usePersistField } from '../../hooks/usePersistField';
Expand All @@ -14,7 +15,7 @@ import { isFieldPhone } from '../../types/guards/isFieldPhone';
export const usePhoneField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);

assertFieldMetadata('TEXT', isFieldPhone, fieldDefinition);
assertFieldMetadata(FieldMetadataType.Text, isFieldPhone, fieldDefinition);

const fieldName = fieldDefinition.metadata.fieldName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useGetButtonIcon } from '@/object-record/record-field/hooks/useGetButto
import { useRecordFieldInput } from '@/object-record/record-field/hooks/useRecordFieldInput';
import { FieldRelationValue } from '@/object-record/record-field/types/FieldMetadata';
import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector';
import { FieldMetadataType } from '~/generated-metadata/graphql';

import { FieldContext } from '../../contexts/FieldContext';
import { assertFieldMetadata } from '../../types/guards/assertFieldMetadata';
Expand All @@ -14,7 +15,12 @@ import { isFieldRelation } from '../../types/guards/isFieldRelation';
export const useRelationField = () => {
const { entityId, fieldDefinition, maxWidth } = useContext(FieldContext);
const button = useGetButtonIcon();
assertFieldMetadata('RELATION', isFieldRelation, fieldDefinition);

assertFieldMetadata(
FieldMetadataType.Relation,
isFieldRelation,
fieldDefinition,
);

const fieldName = fieldDefinition.metadata.fieldName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useRecoilState, useRecoilValue } from 'recoil';
import { useRecordFieldInput } from '@/object-record/record-field/hooks/useRecordFieldInput';
import { FieldTextValue } from '@/object-record/record-field/types/FieldMetadata';
import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector';
import { FieldMetadataType } from '~/generated-metadata/graphql';

import { FieldContext } from '../../contexts/FieldContext';
import { assertFieldMetadata } from '../../types/guards/assertFieldMetadata';
Expand All @@ -14,7 +15,7 @@ export const useTextField = () => {
const { entityId, fieldDefinition, hotkeyScope, maxWidth } =
useContext(FieldContext);

assertFieldMetadata('TEXT', isFieldText, fieldDefinition);
assertFieldMetadata(FieldMetadataType.Text, isFieldText, fieldDefinition);

const fieldName = fieldDefinition.metadata.fieldName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useRecoilState } from 'recoil';
import { FieldUUidValue } from '@/object-record/record-field/types/FieldMetadata';
import { isFieldUuid } from '@/object-record/record-field/types/guards/isFieldUuid';
import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector';
import { FieldMetadataType } from '~/generated-metadata/graphql';

import { FieldContext } from '../../contexts/FieldContext';
import { assertFieldMetadata } from '../../types/guards/assertFieldMetadata';
Expand All @@ -12,7 +13,7 @@ import { isFieldTextValue } from '../../types/guards/isFieldTextValue';
export const useUuidField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);

assertFieldMetadata('UUID', isFieldUuid, fieldDefinition);
assertFieldMetadata(FieldMetadataType.Uuid, isFieldUuid, fieldDefinition);

const fieldName = fieldDefinition.metadata.fieldName;

Expand Down

0 comments on commit df8eb8e

Please sign in to comment.