From 1763430327d6d722152cc5f7a880d63056870e08 Mon Sep 17 00:00:00 2001
From: Thiago Brezinski <thiagobrez@gmail.com>
Date: Thu, 1 Jun 2023 17:00:39 +0100
Subject: [PATCH] feat(types): add initial Onyx structure types

---
 src/types/AccountType.d.ts                 | 26 +++++++
 src/types/BankAccountType.d.ts             | 24 +++++++
 src/types/CredentialsType.d.ts             |  8 +++
 src/types/IOUType.d.ts                     |  8 +++
 src/types/PayPalMeDataType.d.ts            | 15 ++++
 src/types/PersonalDetailsType.d.ts         | 38 +++++++++++
 src/types/PlaidDataType.d.ts               | 17 +++++
 src/types/PolicyMemberListType.d.ts        |  8 +++
 src/types/PolicyType.d.ts                  | 41 +++++++++++
 src/types/PrivatePersonalDetailsType.d.ts  | 16 +++++
 src/types/ReportActionFragmentType.d.ts    | 32 +++++++++
 src/types/ReportActionType.d.ts            | 35 ++++++++++
 src/types/ReportType.d.ts                  | 79 ++++++++++++++++++++++
 src/types/SessionType.d.ts                 | 14 ++++
 src/types/TaskType.d.ts                    | 20 ++++++
 src/types/UserType.d.ts                    | 15 ++++
 src/types/UserWalletType.d.ts              | 30 ++++++++
 src/types/WalletAdditionalDetailsType.d.ts | 23 +++++++
 src/types/WalletOnfidoDataType.d.ts        | 21 ++++++
 src/types/WalletStatementType.d.ts         |  6 ++
 src/types/WalletTermsType.d.ts             |  8 +++
 src/types/WalletTransferType.d.ts          | 12 ++++
 src/types/common.d.ts                      | 20 ++++++
 23 files changed, 516 insertions(+)
 create mode 100644 src/types/AccountType.d.ts
 create mode 100644 src/types/BankAccountType.d.ts
 create mode 100644 src/types/CredentialsType.d.ts
 create mode 100644 src/types/IOUType.d.ts
 create mode 100644 src/types/PayPalMeDataType.d.ts
 create mode 100644 src/types/PersonalDetailsType.d.ts
 create mode 100644 src/types/PlaidDataType.d.ts
 create mode 100644 src/types/PolicyMemberListType.d.ts
 create mode 100644 src/types/PolicyType.d.ts
 create mode 100644 src/types/PrivatePersonalDetailsType.d.ts
 create mode 100644 src/types/ReportActionFragmentType.d.ts
 create mode 100644 src/types/ReportActionType.d.ts
 create mode 100644 src/types/ReportType.d.ts
 create mode 100644 src/types/SessionType.d.ts
 create mode 100644 src/types/TaskType.d.ts
 create mode 100644 src/types/UserType.d.ts
 create mode 100644 src/types/UserWalletType.d.ts
 create mode 100644 src/types/WalletAdditionalDetailsType.d.ts
 create mode 100644 src/types/WalletOnfidoDataType.d.ts
 create mode 100644 src/types/WalletStatementType.d.ts
 create mode 100644 src/types/WalletTermsType.d.ts
 create mode 100644 src/types/WalletTransferType.d.ts
 create mode 100644 src/types/common.d.ts

diff --git a/src/types/AccountType.d.ts b/src/types/AccountType.d.ts
new file mode 100644
index 000000000000..b7c1ed797e06
--- /dev/null
+++ b/src/types/AccountType.d.ts
@@ -0,0 +1,26 @@
+import * as CommonTypes from './common';
+
+type AccountType = CommonTypes.BaseState & {
+    /** URL to the assigned guide's appointment booking calendar */
+    guideCalendarLink: string;
+
+    /** User recovery codes for setting up 2-FA */
+    recoveryCodes: string;
+
+    /** Secret key to enable 2FA within the authenticator app */
+    twoFactorAuthSecretKey: string;
+
+    /** Whether or not two factor authentication is required */
+    requiresTwoFactorAuth: boolean;
+
+    /** Whether the account is validated */
+    validated: boolean;
+
+    /** The primaryLogin associated with the account */
+    primaryLogin: string;
+
+    /** The message to be displayed when code requested */
+    message: string;
+};
+
+export default AccountType;
diff --git a/src/types/BankAccountType.d.ts b/src/types/BankAccountType.d.ts
new file mode 100644
index 000000000000..64b3c12952ab
--- /dev/null
+++ b/src/types/BankAccountType.d.ts
@@ -0,0 +1,24 @@
+type BankAccountType = {
+    /** Masked account number */
+    accountNumber: string;
+
+    /** Name of account */
+    addressName: string;
+
+    /** Is the account a savings account? */
+    isSavings: boolean;
+
+    /** Unique identifier for this account in Plaid */
+    plaidAccountID: string;
+
+    /** Routing number for the account */
+    routingNumber: string;
+
+    /** last 4 digits of the account number */
+    mask: string;
+
+    /** Plaid access token, used to then retrieve Assets and Balances */
+    plaidAccessToken: string;
+};
+
+export default BankAccountType;
diff --git a/src/types/CredentialsType.d.ts b/src/types/CredentialsType.d.ts
new file mode 100644
index 000000000000..8149b1f57250
--- /dev/null
+++ b/src/types/CredentialsType.d.ts
@@ -0,0 +1,8 @@
+type CredentialsType = {
+    login: string;
+    password: string;
+    twoFactorAuthCode: string;
+    validateCode: string;
+};
+
+export default CredentialsType;
diff --git a/src/types/IOUType.d.ts b/src/types/IOUType.d.ts
new file mode 100644
index 000000000000..28ba0a5ec7ba
--- /dev/null
+++ b/src/types/IOUType.d.ts
@@ -0,0 +1,8 @@
+type IOUType = {
+    comment: string;
+
+    /** Selected Currency Code of the current IOU */
+    selectedCurrencyCode: string;
+};
+
+export default IOUType;
diff --git a/src/types/PayPalMeDataType.d.ts b/src/types/PayPalMeDataType.d.ts
new file mode 100644
index 000000000000..70b2cb19ed53
--- /dev/null
+++ b/src/types/PayPalMeDataType.d.ts
@@ -0,0 +1,15 @@
+type PayPalMeDataType = {
+    /** This is always 'PayPal.me' */
+    title: 'PayPal.me';
+
+    /** The paypalMe address */
+    description: string;
+
+    /** This is always 'payPalMe' */
+    methodID: 'payPalMe';
+
+    /** This is always 'payPalMe' */
+    accountType: 'payPalMe';
+};
+
+export default PayPalMeDataType;
diff --git a/src/types/PersonalDetailsType.d.ts b/src/types/PersonalDetailsType.d.ts
new file mode 100644
index 000000000000..877410b66306
--- /dev/null
+++ b/src/types/PersonalDetailsType.d.ts
@@ -0,0 +1,38 @@
+type PersonalDetailsType = {
+    // First name of the current user from their personal details
+    firstName: string;
+
+    // Last name of the current user from their personal details
+    lastName: string;
+
+    // Display name of the current user from their personal details
+    displayName: string;
+
+    // Avatar URL of the current user from their personal details
+    avatar: string;
+
+    // Flag to set when Avatar uploading
+    avatarUploading: boolean;
+
+    // login of the current user from their personal details
+    login: string;
+
+    // pronouns of the current user from their personal details
+    pronouns: string;
+
+    // local currency for the user
+    localCurrencyCode: string;
+
+    // timezone of the current user from their personal details
+    timezone: {
+        // Value of selected timezone
+        selected: string;
+
+        // Whether timezone is automatically set
+        // TODO: remove string type after backend fix
+        // Some personal details return 'true' (string) for this value instead of true (boolean)
+        automatic: boolean | string;
+    };
+};
+
+export default PersonalDetailsType;
diff --git a/src/types/PlaidDataType.d.ts b/src/types/PlaidDataType.d.ts
new file mode 100644
index 000000000000..abef9ff55983
--- /dev/null
+++ b/src/types/PlaidDataType.d.ts
@@ -0,0 +1,17 @@
+import BankAccountType from './BankAccountType';
+
+type PlaidDataType = {
+    /** Name of the bank */
+    bankName: string;
+
+    /**
+     * Access token returned by Plaid once the user has logged into their bank.
+     * This token can be used along with internal credentials to query for Plaid Balance or Assets
+     */
+    plaidAccessToken: string;
+
+    /** List of plaid bank accounts */
+    bankAccounts: BankAccountType[];
+};
+
+export default PlaidDataType;
diff --git a/src/types/PolicyMemberListType.d.ts b/src/types/PolicyMemberListType.d.ts
new file mode 100644
index 000000000000..b873373d8f6e
--- /dev/null
+++ b/src/types/PolicyMemberListType.d.ts
@@ -0,0 +1,8 @@
+import * as CommonTypes from './common';
+
+type PolicyMemberListType = CommonTypes.BaseState & {
+    /** Role of the user in the policy */
+    role: string;
+};
+
+export default PolicyMemberListType;
diff --git a/src/types/PolicyType.d.ts b/src/types/PolicyType.d.ts
new file mode 100644
index 000000000000..9b30c5f8c177
--- /dev/null
+++ b/src/types/PolicyType.d.ts
@@ -0,0 +1,41 @@
+import * as CommonTypes from './common';
+
+type PolicyType = CommonTypes.BaseState & {
+    /** The ID of the policy */
+    id: string;
+
+    /** The name of the policy */
+    name: string;
+
+    /** The current user's role in the policy */
+    role: 'admin' | 'auditor' | 'user';
+
+    /** The policy type */
+    type: 'free' | 'personal' | 'corporate' | 'team';
+
+    /** The email of the policy owner */
+    owner: string;
+
+    /** The output currency for the policy */
+    outputCurrency: string;
+
+    /** The URL for the policy avatar */
+    avatar: string;
+
+    /**
+     * Error objects keyed by field name containing errors keyed by microtime
+     * E.x
+     * {
+     *     name: {
+     *        [DateUtils.getMicroseconds()]: 'Sorry, there was an unexpected problem updating your workspace name.',
+     *     }
+     * }
+     */
+    errorFields: {
+        [fieldName: string]: {
+            [microtime: number]: string;
+        };
+    };
+};
+
+export default PolicyType;
diff --git a/src/types/PrivatePersonalDetailsType.d.ts b/src/types/PrivatePersonalDetailsType.d.ts
new file mode 100644
index 000000000000..82a8840589da
--- /dev/null
+++ b/src/types/PrivatePersonalDetailsType.d.ts
@@ -0,0 +1,16 @@
+type PrivatePersonalDetailsType = {
+    legalFirstName: string;
+    legalLastName: string;
+    dob: string;
+
+    /** User's home address */
+    address: {
+        street: string;
+        city: string;
+        state: string;
+        zip: string;
+        country: string;
+    };
+};
+
+export default PrivatePersonalDetailsType;
diff --git a/src/types/ReportActionFragmentType.d.ts b/src/types/ReportActionFragmentType.d.ts
new file mode 100644
index 000000000000..fc5e36045b90
--- /dev/null
+++ b/src/types/ReportActionFragmentType.d.ts
@@ -0,0 +1,32 @@
+type ReportActionFragmentType = {
+    /** The type of the action item fragment. Used to render a corresponding component */
+    type: string;
+
+    /** The text content of the fragment. */
+    text: string;
+
+    /** Used to apply additional styling. Style refers to a predetermined constant and not a class name. e.g. 'normal'
+     * or 'strong'
+     */
+    style: string;
+
+    /** ID of a report */
+    reportID: string;
+
+    /** ID of a policy */
+    policyID: string;
+
+    /** The target of a link fragment e.g. '_blank' */
+    target: string;
+
+    /** The destination of a link fragment e.g. 'https://www.expensify.com' */
+    href: string;
+
+    /** An additional avatar url - not the main avatar url but used within a message. */
+    iconUrl: string;
+
+    /** Fragment edited flag */
+    isEdited: boolean;
+};
+
+export default ReportActionFragmentType;
diff --git a/src/types/ReportActionType.d.ts b/src/types/ReportActionType.d.ts
new file mode 100644
index 000000000000..73b840442d96
--- /dev/null
+++ b/src/types/ReportActionType.d.ts
@@ -0,0 +1,35 @@
+import ReportActionFragmentType from './ReportActionFragmentType';
+
+type ReportActionType = {
+    /** The ID of the reportAction. It is the string representation of the a 64-bit integer. */
+    reportActionID: string;
+
+    /** Name of the action e.g. ADDCOMMENT */
+    actionName: string;
+
+    /** Person who created the action */
+    person: ReportActionFragmentType[];
+
+    /** ISO-formatted datetime */
+    created: string;
+
+    /** report action message */
+    message: ReportActionFragmentType[];
+
+    /** Original message associated with this action */
+    originalMessage: {
+        // The ID of the iou transaction
+        IOUTransactionID: string;
+    };
+
+    /** Whether we have received a response back from the server */
+    isLoading: boolean;
+
+    /** Error message that's come back from the server. */
+    error: string;
+
+    /** Emails of the people to which the whisper was sent to (if any). Returns empty array if it is not a whisper */
+    whisperedTo: string[];
+};
+
+export default ReportActionType;
diff --git a/src/types/ReportType.d.ts b/src/types/ReportType.d.ts
new file mode 100644
index 000000000000..17999e3730d2
--- /dev/null
+++ b/src/types/ReportType.d.ts
@@ -0,0 +1,79 @@
+import * as CommonTypes from './common';
+
+type ReportType = {
+    /** The specific type of chat */
+    chatType: '' | 'policyAnnounce' | 'policyAdmins' | 'domainAll' | 'policyRoom' | 'policyExpenseChat';
+
+    /** Whether there is an outstanding amount in IOU */
+    hasOutstandingIOU: boolean;
+
+    /** List of icons for report participants */
+    icons: CommonTypes.Icon[];
+
+    /** Are we loading more report actions? */
+    isLoadingMoreReportActions: boolean;
+
+    /** Flag to check if the report actions data are loading */
+    isLoadingReportActions: boolean;
+
+    /** Whether the user is not an admin of policyExpenseChat chat */
+    isOwnPolicyExpenseChat: boolean;
+
+    /** Indicates if the report is pinned to the LHN or not */
+    isPinned: boolean;
+
+    /** The email of the last message's actor */
+    lastActorEmail: string;
+
+    /** The text of the last message on the report */
+    lastMessageText: string;
+
+    /** The time of the last message on the report */
+    lastVisibleActionCreated: string;
+
+    /** The last time the report was visited */
+    lastReadTime: string;
+
+    /** The current user's notification preference for this report */
+    notificationPreference: string | number;
+
+    /** The policy name to use for an archived report */
+    oldPolicyName: string;
+
+    /** The email address of the report owner */
+    ownerEmail: string;
+
+    /** List of primarylogins of participants of the report */
+    participants: string[];
+
+    /** Linked policy's ID */
+    policyID: string;
+
+    /** Name of the report */
+    reportName: string;
+
+    /** ID of the report */
+    reportID: string;
+
+    /** The state that the report is currently in */
+    stateNum:
+        | 0 // OPEN
+        | 1 // PROCESSING
+        | 2; // SUBMITTED
+
+    /** The status of the current report */
+    statusNum:
+        | 0 // OPEN
+        | 1 // SUBMITTED
+        | 2 // CLOSED
+        | 3 // APPROVED
+        | 4; // REIMBURSED
+
+    /** Which user role is capable of posting messages on the report */
+    writeCapability: 'all' | 'admins';
+
+    /** The report type */
+    type: string;
+};
+
+export default ReportType;
diff --git a/src/types/SessionType.d.ts b/src/types/SessionType.d.ts
new file mode 100644
index 000000000000..394f3ccc0e75
--- /dev/null
+++ b/src/types/SessionType.d.ts
@@ -0,0 +1,14 @@
+import * as CommonTypes from './common';
+
+type SessionType = CommonTypes.BaseState & {
+    /** The user's email for the current session */
+    email: string;
+
+    /** Currently logged in user authToken */
+    authToken: string;
+
+    /** Currently logged in user accountID */
+    accountID: number;
+};
+
+export default SessionType;
diff --git a/src/types/TaskType.d.ts b/src/types/TaskType.d.ts
new file mode 100644
index 000000000000..1b810fa51459
--- /dev/null
+++ b/src/types/TaskType.d.ts
@@ -0,0 +1,20 @@
+import ReportType from './ReportType';
+
+type TaskType = {
+    /** Title of the Task */
+    title: string;
+
+    /** Description of the Task */
+    description: string;
+
+    /** Share destination of the Task */
+    shareDestination: string;
+
+    /** The task report if it's currently being edited */
+    report: ReportType;
+
+    assignee: string;
+    parentReportID: string;
+};
+
+export default TaskType;
diff --git a/src/types/UserType.d.ts b/src/types/UserType.d.ts
new file mode 100644
index 000000000000..8dd9263a8759
--- /dev/null
+++ b/src/types/UserType.d.ts
@@ -0,0 +1,15 @@
+type UserType = {
+    /** Whether or not the user is subscribed to news updates */
+    isSubscribedToNewsletter: boolean;
+
+    /** Whether we should use the staging version of the secure API server */
+    shouldUseStagingServer: boolean;
+
+    /** Is the user account validated? */
+    validated: boolean;
+
+    /** Whether or not the user is on a public domain email account or not */
+    isFromPublicDomain: boolean;
+};
+
+export default UserType;
diff --git a/src/types/UserWalletType.d.ts b/src/types/UserWalletType.d.ts
new file mode 100644
index 000000000000..699986ebd970
--- /dev/null
+++ b/src/types/UserWalletType.d.ts
@@ -0,0 +1,30 @@
+type UserWalletType = {
+    /** The user's available wallet balance */
+    availableBalance: number;
+
+    /** The user's current wallet balance */
+    currentBalance: number;
+
+    /** What step in the activation flow are we on? */
+    currentStep: string;
+
+    /** Error code returned by the server */
+    errorCode: string;
+
+    /** If we should show the FailedKYC view after the user submitted their info with a non fixable error */
+    shouldShowFailedKYC: boolean;
+
+    /** Status of wallet - e.g. SILVER or GOLD */
+    tierName: string;
+
+    /** Whether we should show the ActivateStep success view after the user finished the KYC flow */
+    shouldShowWalletActivationSuccess: boolean;
+
+    /** The ID of the linked account */
+    walletLinkedAccountID: number;
+
+    /** The type of the linked account (debitCard or bankAccount) */
+    walletLinkedAccountType: string;
+};
+
+export default UserWalletType;
diff --git a/src/types/WalletAdditionalDetailsType.d.ts b/src/types/WalletAdditionalDetailsType.d.ts
new file mode 100644
index 000000000000..a887116bc684
--- /dev/null
+++ b/src/types/WalletAdditionalDetailsType.d.ts
@@ -0,0 +1,23 @@
+import * as CommonTypes from './common';
+
+type WalletAdditionalDetailsType = CommonTypes.BaseState & {
+    /** Questions returned by Idology */
+    questions: {
+        prompt: string;
+        type: string;
+        answer: string[];
+    };
+
+    /** ExpectID ID number related to those questions */
+    idNumber: string;
+
+    /** Error code to determine additional behavior */
+    errorCode: string;
+
+    /** Which field needs attention? */
+    errorFields: {
+        [fieldName: string]: boolean;
+    };
+};
+
+export default WalletAdditionalDetailsType;
diff --git a/src/types/WalletOnfidoDataType.d.ts b/src/types/WalletOnfidoDataType.d.ts
new file mode 100644
index 000000000000..d68bb04e7aaa
--- /dev/null
+++ b/src/types/WalletOnfidoDataType.d.ts
@@ -0,0 +1,21 @@
+type WalletOnfidoDataType = {
+    /** Unique identifier returned from openOnfidoFlow then re-sent to ActivateWallet with Onfido response data */
+    applicantID: string;
+
+    /** Token used to initialize the Onfido SDK token */
+    sdkToken: string;
+
+    /** Loading state to provide feedback when we are waiting for a request to finish */
+    loading: boolean;
+
+    /** Error message to inform the user of any problem that might occur */
+    error: string;
+
+    /** A list of Onfido errors that the user can fix in order to attempt the Onfido flow again */
+    fixableErrors: string[];
+
+    /** Whether the user has accepted the privacy policy of Onfido or not */
+    hasAcceptedPrivacyPolicy: boolean;
+};
+
+export default WalletOnfidoDataType;
diff --git a/src/types/WalletStatementType.d.ts b/src/types/WalletStatementType.d.ts
new file mode 100644
index 000000000000..de2c2842dc77
--- /dev/null
+++ b/src/types/WalletStatementType.d.ts
@@ -0,0 +1,6 @@
+type WalletStatementType = {
+    /** Whether we are currently generating a PDF version of the statement */
+    isGenerating: boolean;
+};
+
+export default WalletStatementType;
diff --git a/src/types/WalletTermsType.d.ts b/src/types/WalletTermsType.d.ts
new file mode 100644
index 000000000000..3107eac315ae
--- /dev/null
+++ b/src/types/WalletTermsType.d.ts
@@ -0,0 +1,8 @@
+import * as CommonTypes from './common';
+
+type WalletTermsType = CommonTypes.BaseState & {
+    /** When the user accepts the Wallet's terms in order to pay an IOU, this is the ID of the chatReport the IOU is linked to */
+    chatReportID: string;
+};
+
+export default WalletTermsType;
diff --git a/src/types/WalletTransferType.d.ts b/src/types/WalletTransferType.d.ts
new file mode 100644
index 000000000000..68152b2a5f16
--- /dev/null
+++ b/src/types/WalletTransferType.d.ts
@@ -0,0 +1,12 @@
+type WalletTransferType = {
+    /** Selected accountID for transfer */
+    selectedAccountID: string | number;
+
+    /** Type to filter the payment Method list */
+    filterPaymentMethodType: 'debitCard' | 'bankAccount';
+
+    /** Whether the success screen is shown to user. */
+    shouldShowSuccess: boolean;
+};
+
+export default WalletTransferType;
diff --git a/src/types/common.d.ts b/src/types/common.d.ts
new file mode 100644
index 000000000000..851dd7b59206
--- /dev/null
+++ b/src/types/common.d.ts
@@ -0,0 +1,20 @@
+import * as React from 'react';
+
+type RedBrickRoadPendingAction = 'add' | 'delete' | 'update';
+
+type BaseState = {
+    success: string;
+    errors: {
+        [key: string]: string;
+    };
+    isLoading: boolean;
+    pendingAction: RedBrickRoadPendingAction;
+};
+
+type Icon = {
+    source: string | React.ReactNode;
+    type: 'avatar' | 'workspace';
+    name: string;
+};
+
+export {RedBrickRoadPendingAction, BaseState, Icon};
