Skip to content

Commit

Permalink
close rhp on select and highlight current xero org chosen
Browse files Browse the repository at this point in the history
  • Loading branch information
lakchote committed May 1, 2024
1 parent 5f33ba7 commit 3943778
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {StackScreenProps} from '@react-navigation/stack';
import React from 'react';
import React, { useMemo } from 'react';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import ScrollView from '@components/ScrollView';
Expand All @@ -16,6 +16,9 @@ import withPolicy from '@pages/workspace/withPolicy';
import type {WithPolicyProps} from '@pages/workspace/withPolicy';
import CONST from '@src/CONST';
import type SCREENS from '@src/SCREENS';
import ROUTES from '@src/ROUTES';
import { findCurrentXeroOrganization, getXeroTenants } from '@libs/PolicyUtils';
import Navigation from '@libs/Navigation/Navigation';

type XeroOrganizationConfigurationPageProps = WithPolicyProps & StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.ACCOUNTING.XERO_ORGANIZATION>;
function XeroOrganizationConfigurationPage({
Expand All @@ -26,6 +29,8 @@ function XeroOrganizationConfigurationPage({
}: XeroOrganizationConfigurationPageProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const tenants = useMemo(() => getXeroTenants(policy ?? undefined), [policy]);
const currentXeroOrganization = findCurrentXeroOrganization(tenants, policy?.connections?.xero?.config?.tenantID);

const policyID = policy?.id ?? '';

Expand All @@ -42,6 +47,7 @@ function XeroOrganizationConfigurationPage({
}

updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, 'tenantID', keyForList);
Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING.getRoute(policyID));
};

return (
Expand All @@ -62,7 +68,7 @@ function XeroOrganizationConfigurationPage({
ListItem={RadioListItem}
onSelectRow={saveSelection}
sections={[{data: sections}]}
initiallyFocusedOptionKey={organizationID}
initiallyFocusedOptionKey={currentXeroOrganization?.id}
/>
</ScrollView>
</ScreenWrapper>
Expand Down

0 comments on commit 3943778

Please sign in to comment.