diff --git a/contributingGuides/FORMS.md b/contributingGuides/FORMS.md
index d87f9f889090..b2f912277dc5 100644
--- a/contributingGuides/FORMS.md
+++ b/contributingGuides/FORMS.md
@@ -10,7 +10,7 @@ Any form input needs to be wrapped in [InputWrapper](https://github.com/Expensif
@@ -248,7 +248,7 @@ function onSubmit(values) {
@@ -263,7 +263,7 @@ const BankAccountForm = () => (
@@ -271,7 +271,7 @@ const BankAccountForm = () => (
>
diff --git a/src/CONST.ts b/src/CONST.ts
index a939f0942839..e33fc3eb23fb 100755
--- a/src/CONST.ts
+++ b/src/CONST.ts
@@ -195,45 +195,6 @@ const CONST = {
DOMAIN: '@expensify.sms',
},
BANK_ACCOUNT: {
- BANK_INFO_STEP: {
- INPUT_KEY: {
- ROUTING_NUMBER: 'routingNumber',
- ACCOUNT_NUMBER: 'accountNumber',
- PLAID_MASK: 'plaidMask',
- IS_SAVINGS: 'isSavings',
- BANK_NAME: 'bankName',
- PLAID_ACCOUNT_ID: 'plaidAccountID',
- PLAID_ACCESS_TOKEN: 'plaidAccessToken',
- },
- },
- PERSONAL_INFO_STEP: {
- INPUT_KEY: {
- FIRST_NAME: 'firstName',
- LAST_NAME: 'lastName',
- DOB: 'dob',
- SSN_LAST_4: 'ssnLast4',
- STREET: 'requestorAddressStreet',
- CITY: 'requestorAddressCity',
- STATE: 'requestorAddressState',
- ZIP_CODE: 'requestorAddressZipCode',
- },
- },
- BUSINESS_INFO_STEP: {
- INPUT_KEY: {
- COMPANY_NAME: 'companyName',
- COMPANY_TAX_ID: 'companyTaxID',
- COMPANY_WEBSITE: 'website',
- COMPANY_PHONE: 'companyPhone',
- STREET: 'addressStreet',
- CITY: 'addressCity',
- STATE: 'addressState',
- ZIP_CODE: 'addressZipCode',
- INCORPORATION_TYPE: 'incorporationType',
- INCORPORATION_DATE: 'incorporationDate',
- INCORPORATION_STATE: 'incorporationState',
- HAS_NO_CONNECTION_TO_CANNABIS: 'hasNoConnectionToCannabis',
- },
- },
BENEFICIAL_OWNER_INFO_STEP: {
SUBSTEP: {
IS_USER_UBO: 1,
@@ -242,11 +203,6 @@ const CONST = {
ARE_THERE_MORE_UBOS: 4,
UBOS_LIST: 5,
},
- INPUT_KEY: {
- OWNS_MORE_THAN_25_PERCENT: 'ownsMoreThan25Percent',
- HAS_OTHER_BENEFICIAL_OWNERS: 'hasOtherBeneficialOwners',
- BENEFICIAL_OWNERS: 'beneficialOwners',
- },
BENEFICIAL_OWNER_DATA: {
BENEFICIAL_OWNER_KEYS: 'beneficialOwnerKeys',
PREFIX: 'beneficialOwner',
@@ -270,13 +226,6 @@ const CONST = {
EXIT: 'EXIT',
},
},
- COMPLETE_VERIFICATION: {
- INPUT_KEY: {
- IS_AUTHORIZED_TO_USE_BANK_ACCOUNT: 'isAuthorizedToUseBankAccount',
- CERTIFY_TRUE_INFORMATION: 'certifyTrueInformation',
- ACCEPT_TERMS_AND_CONDITIONS: 'acceptTermsAndConditions',
- },
- },
ERROR: {
MISSING_ROUTING_NUMBER: '402 Missing routingNumber',
MAX_ROUTING_NUMBER: '402 Maximum Size Exceeded routingNumber',
diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts
index 751ee105ceb7..0735bc53e56c 100755
--- a/src/ONYXKEYS.ts
+++ b/src/ONYXKEYS.ts
@@ -1,7 +1,9 @@
import type {OnyxEntry} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import type CONST from './CONST';
+import type * as FormTypes from './types/form';
import type * as OnyxTypes from './types/onyx';
+import type AssertTypesEqual from './types/utils/AssertTypesEqual';
import type DeepValueOf from './types/utils/DeepValueOf';
/**
@@ -237,9 +239,6 @@ const ONYXKEYS = {
// The last update ID that was applied to the client
ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT: 'OnyxUpdatesLastUpdateIDAppliedToClient',
- // Receipt upload modal
- RECEIPT_MODAL: 'receiptModal',
-
// The access token to be used with the Mapbox library
MAPBOX_ACCESS_TOKEN: 'mapboxAccessToken',
@@ -379,12 +378,85 @@ const ONYXKEYS = {
},
} as const;
-type OnyxKeysMap = typeof ONYXKEYS;
-type OnyxCollectionKey = ValueOf;
-type OnyxKey = DeepValueOf>;
-type OnyxFormKey = ValueOf;
+type AllOnyxKeys = DeepValueOf;
+
+type OnyxFormValuesMapping = {
+ [ONYXKEYS.FORMS.ADD_DEBIT_CARD_FORM]: FormTypes.AddDebitCardForm;
+ [ONYXKEYS.FORMS.WORKSPACE_SETTINGS_FORM]: FormTypes.WorkspaceSettingsForm;
+ [ONYXKEYS.FORMS.WORKSPACE_RATE_AND_UNIT_FORM]: FormTypes.WorkspaceRateAndUnitForm;
+ [ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM]: FormTypes.CloseAccountForm;
+ [ONYXKEYS.FORMS.PROFILE_SETTINGS_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.DISPLAY_NAME_FORM]: FormTypes.DisplayNameForm;
+ [ONYXKEYS.FORMS.ROOM_NAME_FORM]: FormTypes.RoomNameForm;
+ [ONYXKEYS.FORMS.REPORT_DESCRIPTION_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.LEGAL_NAME_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.WORKSPACE_INVITE_MESSAGE_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.DATE_OF_BIRTH_FORM]: FormTypes.DateOfBirthForm;
+ [ONYXKEYS.FORMS.HOME_ADDRESS_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.NEW_ROOM_FORM]: FormTypes.NewRoomForm;
+ [ONYXKEYS.FORMS.ROOM_SETTINGS_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.NEW_TASK_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.EDIT_TASK_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.MONEY_REQUEST_DESCRIPTION_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.MONEY_REQUEST_MERCHANT_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.MONEY_REQUEST_AMOUNT_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.MONEY_REQUEST_DATE_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.NEW_CONTACT_METHOD_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.WAYPOINT_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.SETTINGS_STATUS_SET_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.SETTINGS_STATUS_CLEAR_DATE_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.SETTINGS_STATUS_SET_CLEAR_AFTER_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.PRIVATE_NOTES_FORM]: FormTypes.PrivateNotesForm;
+ [ONYXKEYS.FORMS.I_KNOW_A_TEACHER_FORM]: FormTypes.IKnowTeacherForm;
+ [ONYXKEYS.FORMS.INTRO_SCHOOL_PRINCIPAL_FORM]: FormTypes.IntroSchoolPrincipalForm;
+ [ONYXKEYS.FORMS.REPORT_VIRTUAL_CARD_FRAUD]: FormTypes.Form;
+ [ONYXKEYS.FORMS.REPORT_PHYSICAL_CARD_FORM]: FormTypes.Form;
+ [ONYXKEYS.FORMS.GET_PHYSICAL_CARD_FORM]: FormTypes.GetPhysicalCardForm;
+ [ONYXKEYS.FORMS.REPORT_FIELD_EDIT_FORM]: FormTypes.ReportFieldEditForm;
+ [ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM]: FormTypes.ReimbursementAccountForm;
+ [ONYXKEYS.FORMS.PERSONAL_BANK_ACCOUNT]: FormTypes.PersonalBankAccountForm;
+};
-type OnyxValues = {
+type OnyxFormDraftValuesMapping = {
+ [K in keyof OnyxFormValuesMapping as `${K}Draft`]: OnyxFormValuesMapping[K];
+};
+
+type OnyxCollectionValuesMapping = {
+ [ONYXKEYS.COLLECTION.DOWNLOAD]: OnyxTypes.Download;
+ [ONYXKEYS.COLLECTION.POLICY]: OnyxTypes.Policy;
+ [ONYXKEYS.COLLECTION.POLICY_DRAFTS]: OnyxTypes.Policy;
+ [ONYXKEYS.COLLECTION.POLICY_CATEGORIES]: OnyxTypes.PolicyCategories;
+ [ONYXKEYS.COLLECTION.POLICY_TAGS]: OnyxTypes.PolicyTags;
+ [ONYXKEYS.COLLECTION.POLICY_MEMBERS]: OnyxTypes.PolicyMembers;
+ [ONYXKEYS.COLLECTION.POLICY_MEMBERS_DRAFTS]: OnyxTypes.PolicyMember;
+ [ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_CATEGORIES]: OnyxTypes.RecentlyUsedCategories;
+ [ONYXKEYS.COLLECTION.POLICY_REPORT_FIELDS]: OnyxTypes.PolicyReportFields;
+ [ONYXKEYS.COLLECTION.DEPRECATED_POLICY_MEMBER_LIST]: OnyxTypes.PolicyMembers;
+ [ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT]: OnyxTypes.InvitedEmailsToAccountIDs;
+ [ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT]: string;
+ [ONYXKEYS.COLLECTION.REPORT]: OnyxTypes.Report;
+ [ONYXKEYS.COLLECTION.REPORT_METADATA]: OnyxTypes.ReportMetadata;
+ [ONYXKEYS.COLLECTION.REPORT_ACTIONS]: OnyxTypes.ReportActions;
+ [ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS]: OnyxTypes.ReportActionsDrafts;
+ [ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS]: OnyxTypes.ReportActionReactions;
+ [ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT]: string;
+ [ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT_NUMBER_OF_LINES]: number;
+ [ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE]: boolean;
+ [ONYXKEYS.COLLECTION.REPORT_USER_IS_TYPING]: OnyxTypes.ReportUserIsTyping;
+ [ONYXKEYS.COLLECTION.REPORT_USER_IS_LEAVING_ROOM]: boolean;
+ [ONYXKEYS.COLLECTION.SECURITY_GROUP]: OnyxTypes.SecurityGroup;
+ [ONYXKEYS.COLLECTION.TRANSACTION]: OnyxTypes.Transaction;
+ [ONYXKEYS.COLLECTION.TRANSACTION_DRAFT]: OnyxTypes.Transaction;
+ [ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS]: OnyxTypes.TransactionViolations;
+ [ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT]: OnyxTypes.Transaction;
+ [ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS]: OnyxTypes.RecentlyUsedTags;
+ [ONYXKEYS.COLLECTION.SELECTED_TAB]: string;
+ [ONYXKEYS.COLLECTION.PRIVATE_NOTES_DRAFT]: string;
+ [ONYXKEYS.COLLECTION.NEXT_STEP]: OnyxTypes.ReportNextStep;
+ [ONYXKEYS.COLLECTION.POLICY_TAX_RATE]: string[];
+};
+
+type OnyxValuesMapping = {
[ONYXKEYS.ACCOUNT]: OnyxTypes.Account;
[ONYXKEYS.ACCOUNT_MANAGER_REPORT_ID]: string;
[ONYXKEYS.NVP_IS_FIRST_TIME_NEW_EXPENSIFY_USER]: boolean;
@@ -465,113 +537,23 @@ type OnyxValues = {
[ONYXKEYS.LAST_VISITED_PATH]: string | undefined;
[ONYXKEYS.RECENTLY_USED_REPORT_FIELDS]: OnyxTypes.RecentlyUsedReportFields;
[ONYXKEYS.UPDATE_REQUIRED]: boolean;
+ [ONYXKEYS.PLAID_CURRENT_EVENT]: string;
+};
- // Collections
- [ONYXKEYS.COLLECTION.DOWNLOAD]: OnyxTypes.Download;
- [ONYXKEYS.COLLECTION.POLICY]: OnyxTypes.Policy;
- [ONYXKEYS.COLLECTION.POLICY_DRAFTS]: OnyxTypes.Policy;
- [ONYXKEYS.COLLECTION.POLICY_CATEGORIES]: OnyxTypes.PolicyCategories;
- [ONYXKEYS.COLLECTION.POLICY_TAGS]: OnyxTypes.PolicyTags;
- [ONYXKEYS.COLLECTION.POLICY_MEMBERS]: OnyxTypes.PolicyMembers;
- [ONYXKEYS.COLLECTION.POLICY_MEMBERS_DRAFTS]: OnyxTypes.PolicyMember;
- [ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_CATEGORIES]: OnyxTypes.RecentlyUsedCategories;
- [ONYXKEYS.COLLECTION.POLICY_REPORT_FIELDS]: OnyxTypes.PolicyReportFields;
- [ONYXKEYS.COLLECTION.DEPRECATED_POLICY_MEMBER_LIST]: OnyxTypes.PolicyMembers;
- [ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT]: OnyxTypes.InvitedEmailsToAccountIDs | undefined;
- [ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT]: string | undefined;
- [ONYXKEYS.COLLECTION.REPORT]: OnyxTypes.Report;
- [ONYXKEYS.COLLECTION.REPORT_METADATA]: OnyxTypes.ReportMetadata;
- [ONYXKEYS.COLLECTION.REPORT_ACTIONS]: OnyxTypes.ReportActions;
- [ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS]: OnyxTypes.ReportActionsDrafts;
- [ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS]: OnyxTypes.ReportActionReactions;
- [ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT]: string;
- [ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT_NUMBER_OF_LINES]: number;
- [ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE]: boolean;
- [ONYXKEYS.COLLECTION.REPORT_USER_IS_TYPING]: OnyxTypes.ReportUserIsTyping;
- [ONYXKEYS.COLLECTION.REPORT_USER_IS_LEAVING_ROOM]: boolean;
- [ONYXKEYS.COLLECTION.SECURITY_GROUP]: OnyxTypes.SecurityGroup;
- [ONYXKEYS.COLLECTION.TRANSACTION]: OnyxTypes.Transaction;
- [ONYXKEYS.COLLECTION.TRANSACTION_DRAFT]: OnyxTypes.Transaction;
- [ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS]: OnyxTypes.TransactionViolations;
- [ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT]: OnyxTypes.Transaction;
- [ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS]: OnyxTypes.RecentlyUsedTags;
- [ONYXKEYS.COLLECTION.SELECTED_TAB]: string;
- [ONYXKEYS.COLLECTION.PRIVATE_NOTES_DRAFT]: string;
- [ONYXKEYS.COLLECTION.NEXT_STEP]: OnyxTypes.ReportNextStep;
+type OnyxValues = OnyxValuesMapping & OnyxCollectionValuesMapping & OnyxFormValuesMapping & OnyxFormDraftValuesMapping;
- // Forms
- [ONYXKEYS.FORMS.ADD_DEBIT_CARD_FORM]: OnyxTypes.AddDebitCardForm;
- [ONYXKEYS.FORMS.ADD_DEBIT_CARD_FORM_DRAFT]: OnyxTypes.AddDebitCardForm;
- [ONYXKEYS.FORMS.WORKSPACE_SETTINGS_FORM]: OnyxTypes.WorkspaceSettingsForm;
- [ONYXKEYS.FORMS.WORKSPACE_SETTINGS_FORM_DRAFT]: OnyxTypes.WorkspaceSettingsForm;
- [ONYXKEYS.FORMS.WORKSPACE_RATE_AND_UNIT_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.WORKSPACE_RATE_AND_UNIT_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM]: OnyxTypes.CloseAccountForm;
- [ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM_DRAFT]: OnyxTypes.CloseAccountForm;
- [ONYXKEYS.FORMS.PROFILE_SETTINGS_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.PROFILE_SETTINGS_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.DISPLAY_NAME_FORM]: OnyxTypes.DisplayNameForm;
- [ONYXKEYS.FORMS.DISPLAY_NAME_FORM_DRAFT]: OnyxTypes.DisplayNameForm;
- [ONYXKEYS.FORMS.ROOM_NAME_FORM]: OnyxTypes.RoomNameForm;
- [ONYXKEYS.FORMS.ROOM_NAME_FORM_DRAFT]: OnyxTypes.RoomNameForm;
- [ONYXKEYS.FORMS.REPORT_DESCRIPTION_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.REPORT_DESCRIPTION_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.LEGAL_NAME_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.LEGAL_NAME_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.WORKSPACE_INVITE_MESSAGE_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.WORKSPACE_INVITE_MESSAGE_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.DATE_OF_BIRTH_FORM]: OnyxTypes.DateOfBirthForm;
- [ONYXKEYS.FORMS.DATE_OF_BIRTH_FORM_DRAFT]: OnyxTypes.DateOfBirthForm;
- [ONYXKEYS.FORMS.HOME_ADDRESS_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.HOME_ADDRESS_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.NEW_ROOM_FORM]: OnyxTypes.NewRoomForm;
- [ONYXKEYS.FORMS.NEW_ROOM_FORM_DRAFT]: OnyxTypes.NewRoomForm;
- [ONYXKEYS.FORMS.ROOM_SETTINGS_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.ROOM_SETTINGS_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.NEW_TASK_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.NEW_TASK_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.EDIT_TASK_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.EDIT_TASK_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.MONEY_REQUEST_DESCRIPTION_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.MONEY_REQUEST_DESCRIPTION_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.MONEY_REQUEST_MERCHANT_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.MONEY_REQUEST_MERCHANT_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.MONEY_REQUEST_AMOUNT_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.MONEY_REQUEST_AMOUNT_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.MONEY_REQUEST_DATE_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.MONEY_REQUEST_DATE_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.NEW_CONTACT_METHOD_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.NEW_CONTACT_METHOD_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.WAYPOINT_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.WAYPOINT_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.SETTINGS_STATUS_SET_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.SETTINGS_STATUS_SET_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.SETTINGS_STATUS_CLEAR_DATE_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.SETTINGS_STATUS_CLEAR_DATE_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.SETTINGS_STATUS_SET_CLEAR_AFTER_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.SETTINGS_STATUS_SET_CLEAR_AFTER_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.PRIVATE_NOTES_FORM]: OnyxTypes.PrivateNotesForm;
- [ONYXKEYS.FORMS.PRIVATE_NOTES_FORM_DRAFT]: OnyxTypes.PrivateNotesForm;
- [ONYXKEYS.FORMS.I_KNOW_A_TEACHER_FORM]: OnyxTypes.IKnowATeacherForm;
- [ONYXKEYS.FORMS.I_KNOW_A_TEACHER_FORM_DRAFT]: OnyxTypes.IKnowATeacherForm;
- [ONYXKEYS.FORMS.INTRO_SCHOOL_PRINCIPAL_FORM]: OnyxTypes.IntroSchoolPrincipalForm;
- [ONYXKEYS.FORMS.INTRO_SCHOOL_PRINCIPAL_FORM_DRAFT]: OnyxTypes.IntroSchoolPrincipalForm;
- [ONYXKEYS.FORMS.REPORT_VIRTUAL_CARD_FRAUD]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.REPORT_VIRTUAL_CARD_FRAUD_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.REPORT_PHYSICAL_CARD_FORM]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.REPORT_PHYSICAL_CARD_FORM_DRAFT]: OnyxTypes.Form;
- [ONYXKEYS.FORMS.GET_PHYSICAL_CARD_FORM]: OnyxTypes.GetPhysicalCardForm;
- [ONYXKEYS.FORMS.GET_PHYSICAL_CARD_FORM_DRAFT]: OnyxTypes.GetPhysicalCardForm;
- [ONYXKEYS.FORMS.REPORT_FIELD_EDIT_FORM]: OnyxTypes.ReportFieldEditForm;
- [ONYXKEYS.FORMS.REPORT_FIELD_EDIT_FORM_DRAFT]: OnyxTypes.Form;
- // @ts-expect-error Different values are defined under the same key: ReimbursementAccount and ReimbursementAccountForm
- [ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM]: OnyxTypes.ReimbursementAccountForm;
- [ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT]: OnyxTypes.ReimbursementAccountForm;
- [ONYXKEYS.FORMS.PERSONAL_BANK_ACCOUNT]: OnyxTypes.PersonalBankAccount;
- [ONYXKEYS.FORMS.PERSONAL_BANK_ACCOUNT_DRAFT]: OnyxTypes.PersonalBankAccount;
-};
+type OnyxCollectionKey = keyof OnyxCollectionValuesMapping;
+type OnyxFormKey = keyof OnyxFormValuesMapping;
+type OnyxFormDraftKey = keyof OnyxFormDraftValuesMapping;
+type OnyxValueKey = keyof OnyxValuesMapping;
+
+type OnyxKey = OnyxValueKey | OnyxCollectionKey | OnyxFormKey | OnyxFormDraftKey;
+type OnyxValue = OnyxEntry;
-type OnyxKeyValue = OnyxEntry;
+type MissingOnyxKeysError = `Error: Types don't match, OnyxKey type is missing: ${Exclude}`;
+/** If this type errors, it means that the `OnyxKey` type is missing some keys. */
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+type AssertOnyxKeys = AssertTypesEqual;
export default ONYXKEYS;
-export type {OnyxKey, OnyxCollectionKey, OnyxValues, OnyxKeyValue, OnyxFormKey, OnyxKeysMap};
+export type {OnyxValues, OnyxKey, OnyxCollectionKey, OnyxValue, OnyxValueKey, OnyxFormKey, OnyxFormValuesMapping, OnyxFormDraftKey};
diff --git a/src/components/AddressForm.js b/src/components/AddressForm.js
index aee1b652b22c..1bd55004074a 100644
--- a/src/components/AddressForm.js
+++ b/src/components/AddressForm.js
@@ -9,6 +9,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import * as ValidationUtils from '@libs/ValidationUtils';
import CONST from '@src/CONST';
+import INPUT_IDS from '@src/types/form/HomeAddressForm';
import AddressSearch from './AddressSearch';
import CountrySelector from './CountrySelector';
import FormProvider from './Form/FormProvider';
@@ -127,7 +128,7 @@ function AddressForm({city, country, formID, onAddressChanged, onSubmit, shouldS
{
onAddressChanged(data, key);
@@ -136,12 +137,12 @@ function AddressForm({city, country, formID, onAddressChanged, onSubmit, shouldS
}}
defaultValue={street1 || ''}
renamedInputKeys={{
- street: 'addressLine1',
- street2: 'addressLine2',
- city: 'city',
- state: 'state',
- zipCode: 'zipPostCode',
- country: 'country',
+ street: INPUT_IDS.ADDRESS_LINE_1,
+ street2: INPUT_IDS.ADDRESS_LINE_2,
+ city: INPUT_IDS.CITY,
+ state: INPUT_IDS.STATE,
+ zipCode: INPUT_IDS.ZIP_POST_CODE,
+ country: INPUT_IDS.COUNTRY,
}}
maxInputLength={CONST.FORM_CHARACTER_LIMIT}
shouldSaveDraft={shouldSaveDraft}
@@ -150,7 +151,7 @@ function AddressForm({city, country, formID, onAddressChanged, onSubmit, shouldS
@@ -173,7 +174,7 @@ function AddressForm({city, country, formID, onAddressChanged, onSubmit, shouldS
;
+
+type RegisterInput = (inputID: keyof Form, shouldSubmitForm: boolean, inputProps: InputProps) => InputProps;
type FormContext = {
registerInput: RegisterInput;
};
@@ -10,3 +14,5 @@ export default createContext({
throw new Error('Registered input should be wrapped with FormWrapper');
},
});
+
+export type {RegisterInput};
diff --git a/src/components/Form/FormProvider.tsx b/src/components/Form/FormProvider.tsx
index 8cf6df2fa8f5..ad09b68a5f39 100644
--- a/src/components/Form/FormProvider.tsx
+++ b/src/components/Form/FormProvider.tsx
@@ -9,21 +9,23 @@ import * as ValidationUtils from '@libs/ValidationUtils';
import Visibility from '@libs/Visibility';
import * as FormActions from '@userActions/FormActions';
import CONST from '@src/CONST';
+import type {TranslationPaths} from '@src/languages/types';
import type {OnyxFormKey} from '@src/ONYXKEYS';
import ONYXKEYS from '@src/ONYXKEYS';
-import type {Form, Network} from '@src/types/onyx';
-import type {FormValueType} from '@src/types/onyx/Form';
-import type {Errors} from '@src/types/onyx/OnyxCommon';
+import type {Form} from '@src/types/form';
+import type {Network} from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
+import type {RegisterInput} from './FormContext';
import FormContext from './FormContext';
import FormWrapper from './FormWrapper';
-import type {BaseInputProps, FormProps, InputRefs, OnyxFormKeyWithoutDraft, OnyxFormValues, OnyxFormValuesFields, RegisterInput, ValueTypeKey} from './types';
+import type {FormInputErrors, FormOnyxValues, FormProps, InputComponentBaseProps, InputRefs, ValueTypeKey} from './types';
// In order to prevent Checkbox focus loss when the user are focusing a TextInput and proceeds to toggle a CheckBox in web and mobile web.
// 200ms delay was chosen as a result of empirical testing.
// More details: https://github.com/Expensify/App/pull/16444#issuecomment-1482983426
const VALIDATE_DELAY = 200;
+type GenericFormInputErrors = Partial>;
type InitialDefaultValue = false | Date | '';
function getInitialValueByType(valueType?: ValueTypeKey): InitialDefaultValue {
@@ -53,10 +55,10 @@ type FormProviderOnyxProps = {
type FormProviderProps = FormProviderOnyxProps &
FormProps & {
/** Children to render. */
- children: ((props: {inputValues: OnyxFormValues}) => ReactNode) | ReactNode;
+ children: ((props: {inputValues: FormOnyxValues}) => ReactNode) | ReactNode;
/** Callback to validate the form */
- validate?: (values: OnyxFormValuesFields) => Errors;
+ validate?: (values: FormOnyxValues) => FormInputErrors;
/** Should validate function be called when input loose focus */
shouldValidateOnBlur?: boolean;
@@ -72,7 +74,7 @@ type FormProviderProps = FormProvider
};
type FormRef = {
- resetForm: (optionalValue: OnyxFormValues) => void;
+ resetForm: (optionalValue: FormOnyxValues) => void;
};
function FormProvider(
@@ -95,11 +97,11 @@ function FormProvider(
const inputRefs = useRef({});
const touchedInputs = useRef>({});
const [inputValues, setInputValues] = useState