Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOLD for payment 2024-07-22] [HOLD for payment 2024-07-17] [HOLD for payment 2024-07-10] [#Wave-Control: Add NetSuite] Add Support for NetSuite Token Input #43434

Closed
yuwenmemon opened this issue Jun 10, 2024 · 27 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item. Weekly KSv2

Comments

@yuwenmemon
Copy link
Contributor

yuwenmemon commented Jun 10, 2024

Tracking Issue: https://github.com/Expensify/Expensify/issues/377671

Design Doc Section: https://docs.google.com/document/d/1WubNv_VAv78IxG4FKsi9aS0pWESfWvUYbqBAAy5b4bc/edit#heading=h.m7jq555xj2u

HOLD ON https://github.com/Expensify/Expensify/issues/403611


We'll add a new page to guide users through setting up NetSuite to work with Expensify and inputting their tokens to initiate the connection.

  • Route: /settings/workspaces/{policyID}/accounting/netsuite/token-input
  • PageComponent: NetSuiteTokenInputPage
  • Calls ConnectPolicyToNetSuite
    Parameters: JSON object consisting of the fields described above.
    • policyID
    • accountID: NetSuite account Id
    • tokenID: Access token Id
    • tokenSecret: Token secret

This screen takes care of authenticating the NetSuite account with Expensify. While the screen shows 5 steps, the first 4 steps are just informational instructions the user needs to perform on their NetSuite account. Hence this would be a pseudo-multi-step form, which would look similar to the Add bank account workflow but the form will only exist in the last step.

AD_4nXdec5Q7PXSwzTFhOf-oKklLsXh2zq7wZaKTZrBWiWNuAD30NLX0H2MMjtDmM0MUamA8ndUapT187n0dHC0XThi9xIrW_gc7NPfPGKeKtsRxsgDt339SBIqK

The reference for such pseudo-form steps would be similar to FeesStep.

function InstallExpensifyBundle({onNext, screenIndex}: SubStepProps) { // Component name based on the step
    const styles = useThemeStyles();
    const {translate} = useLocalize();

   const titleKey = `workspace.netsuite.tokenInputSteps.${NET_SUITE_TOKEN_INPUT_FORM.STEP_NAMES[screenIndex]}.title` as TranslationPath; // The key for the title based on the step. For example, enableTokenBasedAuth.title. We put these step names in the constant and fetch by the current screenIndex. This ensures we only add 1 component for the first 4 steps.

   
   const descriptionKey = `workspace.netsuite.tokenInputSteps.${NET_SUITE_TOKEN_INPUT_FORM.STEP_NAMES[screenIndex]}.description` as TranslationPath;  // The key for the description based on the step. For example, enableTokenBasedAuth.description




    return (
        <ScrollView style={styles.flex1}>
            <Text style={[styles.textHeadlineLineHeightXXL, styles.ph5, styles.mb3]}>{titleKey}</Text>
            <View style={[styles.ph5]}>
		   <Text>{descriptionKey} </Text> 
                <Button
                    success
                    large
                    style={[styles.w100, styles.mv5]}
                    onPress={onNext}
                    text={translate('common.next')}
                />
            </View>
        </ScrollView>
    );
}
AD_4nXfSWe70sdSHMJPZ-0e7FmNOXounhYNS-pllcX0pojdBgcZgPZD3iGxZWgZi09R1f8nRqrEEWiilLoT3_qfbbLW_oCqdgX3XPy98qKlNPJPn7pejxxM9nY4I

The above screen is the form component step used to take the input from the user, which follows the structure as:

TokenInputFormStep

const STEP_FIELDS = [NET_SUITE_TOKEN_INPUT_KEY.ACCOUNT_ID, NET_SUITE_TOKEN_INPUT_KEY.TOKEN_ID, NET_SUITE_TOKEN_INPUT_KEY.TOKEN_SECRET]; // All the fields relevant for the authentication.

function TokenInputFormStep({onNext, isEditing}: SubStepProps) {
    const {translate} = useLocalize();
    const styles = useThemeStyles();

    const [netSuiteTokenInput] = useOnyx(ONYXKEYS.NET_SUITE_TOKEN_INPUT);

const defaultValues = {
    accountId: netSuiteTokenInput?.[NET_SUITE_TOKEN_INPUT_KEY.ACCOUNT_ID] ?? '',
    tokenId: netSuiteTokenInput?.[NET_SUITE_TOKEN_INPUT_KEY.TOKEN_ID] ?? '',
    tokenSecret: netSuiteTokenInput?.[NET_SUITE_TOKEN_INPUT_KEY.TOKEN_SECRET] ?? '',
};


    const handleSubmit = useNetSuiteTokenInputStepFormSubmit({
        fieldIds: STEP_FIELDS,
        onNext,
        shouldSaveDraft: isEditing,
    });

    return (
        <FormProvider
            formID={ONYXKEYS.FORMS.NET_SUITE_TOKEN_INPUT}
            submitButtonText={translate(isEditing ? 'common.confirm' : 'common.next')}
            validate={validate}
            onSubmit={handleSubmit}
            style={[styles.mh5, styles.flexGrow1]}
        >
            <View>
                <Text style={[styles.textHeadlineLineHeightXXL, styles.mb3]}>{translate('accounting.netsuite.tokenInput.form.credentials')}</Text>
                <View style={[styles.flex1]}>
                    <InputWrapper
                        InputComponent={TextInput} // All the inputs are going to be TextInput.
                        inputID={NET_SUITE_TOKEN_INPUT_KEY.accountId}
                        label={translate('accounting.netsuite.tokenInput.form.accountId')} // Whether we should have a title or description segregation. 
                        aria-label={translate('accounting.netsuite.tokenInput.form.accountId')}
                        role={CONST.ROLE.PRESENTATION}
                        defaultValue={defaultValues.accountId}
                        shouldSaveDraft={!isEditing}
                        containerStyles={[styles.mt6]}
                    />
			<Text>{translate('accounting.netsuite.tokenInput.form.accountIdDescription')}<Text> // Covers for the text 'In NetSuite goto Step > Integration > SOAP Web Services Preferences.'
                </View>

                <View style={[styles.flex1]}>
                    <InputWrapper
                        InputComponent={TextInput} // All the inputs are going to be TextInput.

                        inputID={NET_SUITE_TOKEN_INPUT_KEY.tokenId}
                        label={translate('accounting.netsuite.tokenInput.form.tokenId)}
                        aria-label={translate('accounting.netsuite.tokenInput.form.tokenId)}
                        role={CONST.ROLE.PRESENTATION}
                        defaultValue={defaultValues.tokenId}
                        shouldSaveDraft={!isEditing}
                        containerStyles={[styles.mt6]}
                    />
                </View>

                <View style={[styles.flex1]}>
                    <InputWrapper
                        InputComponent={TextInput} // All the inputs are going to be TextInput.

                        inputID={NET_SUITE_TOKEN_INPUT_KEY.tokenSecret}
                        label={translate('accounting.netsuite.tokenInput.form.tokenSecret')}
                        aria-label={translate('accounting.netsuite.tokenInput.form.tokenSecret)} // Confirm if secret is going to be a secured field like password.
                        role={CONST.ROLE.PRESENTATION}
                        defaultValue={defaultValues.tokenSecret}
                        shouldSaveDraft={!isEditing}
                        containerStyles={[styles.mt6]}
                    />
                </View>
            
            </View>
        </FormProvider>
    );
}

TokenInputFormStep.displayName = TokenInputFormStep;

export default TokenInputFormStep;

Form Container component

function NetSuiteTokenInputForm({ netSuiteTokenInputForm }: TokenInputProps) { // Serves as a container for all the substeps and the form.
    const {translate} = useLocalize();
    const styles = useThemeStyles();

    const values = useMemo(() => getSubstepValues(NET_SUITE_TOKEN_INPUT_KEY, netSuiteTokenInputForm), [netSuiteTokenInputForm]); // Considering it's related to auth and we'll store sensitive data, we shouldn't store the draft here.
    const submit = () => {
        // API Call comes here
        Navigation.goBack(ROUTES.POLICY_ACCOUNTNG.getRoute(policyID));
    };

    const startFrom = useMemo(() => getInitialValuesForTokenInput(values), [values]);

    const {
        componentToRender: SubStep,
        isEditing,
        nextScreen,
        prevScreen,
        moveTo,
        screenIndex,
        goToTheLastStep,
    } = useSubStep({
        bodyContent,
        startFrom,
        onFinished: submit,
    });

    return (
        <ScreenWrapper
            includeSafeAreaPaddingBottom={false}
            testID={NetSuiteTokenInputForm.displayName}
        >
            <HeaderWithBackButton
                title={translate('accounting.netsuite.tokenInput.formTitle')}
                onBackButtonPress={handleBackButtonPress}
            />
            <View style={[styles.ph5, styles.mb5, styles.mt3,]}>
                <InteractiveStepSubHeader // Steps wrapper base component for next button based navigation
                    startStepIndex={1}
                    stepNames={CONST.NET_SUITE_TOKEN_INPUT_FORM.STEP_NAMES}
                />
            </View>
            <SubStep
                isEditing={isEditing}
                onNext={nextScreen}
                onMove={moveTo}
            />
        </ScreenWrapper>
    );
}

NetSuiteTokenInputForm.displayName = NetSuiteTokenInputForm;

export default withOnyx<TokenInputProps, TokenInputPropsOnyxProps>({
    netSuiteTokenInputForm: {
        key: ONYXKEYS.FORMS.NET_SUITE_TOKEN_INPUT_FORM,
    },
})(NetSuiteTokenInputForm);
Issue OwnerCurrent Issue Owner: @
Issue OwnerCurrent Issue Owner: @miljakljajic
@yuwenmemon yuwenmemon added External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item. labels Jun 10, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 10, 2024
Copy link

melvin-bot bot commented Jun 10, 2024

Current assignee @mananjadhav is eligible for the External assigner, not assigning anyone new.

@melvin-bot melvin-bot bot added the Daily KSv2 label Jun 10, 2024
Copy link

melvin-bot bot commented Jun 10, 2024

Triggered auto assignment to @miljakljajic (NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Jun 10, 2024
Copy link

melvin-bot bot commented Jun 10, 2024

⚠️ It looks like this issue is labelled as a New Feature but not tied to any GitHub Project. Keep in mind that all new features should be tied to GitHub Projects in order to properly track external CAP software time ⚠️

@yuwenmemon yuwenmemon removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 10, 2024
Copy link

melvin-bot bot commented Jun 10, 2024

Triggered auto assignment to Design team member for new feature review - @dannymcclain (NewFeature)

@JmillsExpensify JmillsExpensify changed the title [HOLD] [#Wave-Control: Add NetSuite] Add Support for NetSuite Token Input [HOLD #403611] [#Wave-Control: Add NetSuite] Add Support for NetSuite Token Input Jun 17, 2024
@melvin-bot melvin-bot bot added the Overdue label Jun 19, 2024
@yuwenmemon
Copy link
Contributor Author

PRs for adding this API are in

@mananjadhav
Copy link
Collaborator

Thanks for confirming. I'll start working on this one then.

@melvin-bot melvin-bot bot removed the Overdue label Jun 20, 2024
@mananjadhav
Copy link
Collaborator

Started working on this one now.

@mananjadhav
Copy link
Collaborator

While adding the ConnectToNetSuiteButton component, I found several hardcoded copies for Xero and QBO. This could cause problems when we add NetSuite and other integrations. For instance, when connecting to Xero with existing NetSuite connection, the disconnect modal would show: Are you sure you want to disconnect QuickBooks Online to set up Xero ?.

I've added a PR to fix it but it's built on top of the subsidiary PR. So once that is merged, we can push this one. I'll work on the Token Input PR on top of the connect button PR.

@mananjadhav
Copy link
Collaborator

@jamesdeanexpensify @yuwenmemon Would you mind sharing the Spanish translation for all the screens here ? I will work on this tomorrow and if we have Spanish translation before that we can move faster.

@jamesdeanexpensify
Copy link
Contributor

@shmaxey since you're already working on translations for NetSuite. If you have any available for the request above ^^ we can use those, otherwise I can start on them since engineering is asking for these in particular. LMK!

@yuwenmemon yuwenmemon changed the title [HOLD #403611] [#Wave-Control: Add NetSuite] Add Support for NetSuite Token Input [#Wave-Control: Add NetSuite] Add Support for NetSuite Token Input Jun 27, 2024
@jamesdeanexpensify
Copy link
Contributor

I'll start working on these today!

@mananjadhav
Copy link
Collaborator

I can view the document. I am afk but I am assuming all the content is taken care of.

@jamesdeanexpensify
Copy link
Contributor

Spanish translations are in there, yep!

@mananjadhav
Copy link
Collaborator

Thanks for the help here.

Copy link

melvin-bot bot commented Jul 1, 2024

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@JmillsExpensify JmillsExpensify moved this to Release 2: Summer 2024 (Aug) in [#whatsnext] #expense Jul 2, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jul 3, 2024
@melvin-bot melvin-bot bot changed the title [#Wave-Control: Add NetSuite] Add Support for NetSuite Token Input [HOLD for payment 2024-07-10] [#Wave-Control: Add NetSuite] Add Support for NetSuite Token Input Jul 3, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 3, 2024
Copy link

melvin-bot bot commented Jul 3, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Jul 3, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.3-7 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-07-10. 🎊

For reference, here are some details about the assignees on this issue:

  • @mananjadhav requires payment through NewDot Manual Requests

Copy link

melvin-bot bot commented Jul 3, 2024

BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@mananjadhav] Please propose regression test steps to ensure the new feature will work correctly on production in further releases.
  • [@miljakljajic] Link the GH issue for creating/updating the regression test once above steps have been agreed upon.

@mananjadhav
Copy link
Collaborator

Payout for this will be centrally paid, no further action here.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Jul 10, 2024
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2024-07-10] [#Wave-Control: Add NetSuite] Add Support for NetSuite Token Input [HOLD for payment 2024-07-17] [HOLD for payment 2024-07-10] [#Wave-Control: Add NetSuite] Add Support for NetSuite Token Input Jul 10, 2024
Copy link

melvin-bot bot commented Jul 10, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.5-13 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-07-17. 🎊

For reference, here are some details about the assignees on this issue:

  • @mananjadhav requires payment through NewDot Manual Requests

Copy link

melvin-bot bot commented Jul 10, 2024

BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@mananjadhav] Please propose regression test steps to ensure the new feature will work correctly on production in further releases.
  • [@miljakljajic] Link the GH issue for creating/updating the regression test once above steps have been agreed upon.

@github-project-automation github-project-automation bot moved this from Release 2: Summer 2024 (Aug) to Done in [#whatsnext] #expense Jul 10, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Jul 15, 2024
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2024-07-17] [HOLD for payment 2024-07-10] [#Wave-Control: Add NetSuite] Add Support for NetSuite Token Input [HOLD for payment 2024-07-22] [HOLD for payment 2024-07-17] [HOLD for payment 2024-07-10] [#Wave-Control: Add NetSuite] Add Support for NetSuite Token Input Jul 15, 2024
Copy link

melvin-bot bot commented Jul 15, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.6-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-07-22. 🎊

For reference, here are some details about the assignees on this issue:

  • @mananjadhav requires payment through NewDot Manual Requests

Copy link

melvin-bot bot commented Jul 15, 2024

BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@mananjadhav] Please propose regression test steps to ensure the new feature will work correctly on production in further releases.
  • [@miljakljajic] Link the GH issue for creating/updating the regression test once above steps have been agreed upon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item. Weekly KSv2
Projects
Archived in project
Development

No branches or pull requests

5 participants