Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2888,6 +2888,7 @@ const CONST = {
},
CERTINIA_FFA_BUNDLE_INSTALL_URL: {
PRODUCTION: 'https://login.salesforce.com/packaging/installPackage.apexp?p0=04t4p000001UQVo',
SANDBOX: 'https://test.salesforce.com/packaging/installPackage.apexp?p0=04t4p000001UQVo',
},

CERTINIA_PSA_BUNDLE_VERSION: '1.3',
Expand Down
45 changes: 29 additions & 16 deletions src/components/ConnectToCertiniaFlow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function ConnectToCertiniaFlow({policyID}: ConnectToCertiniaFlowProps) {

const hasReusablePoliciesConnectedToCertinia = useHasReusablePoliciesConnectedTo(CONST.POLICY.CONNECTIONS.NAME.CERTINIA, policyID);

const [isReuseConnectionsPopoverOpen, setIsReuseConnectionsPopoverOpen] = useState(false);
const [reuseConnectionPopoverPosition, setReuseConnectionPopoverPosition] = useState<AnchorPosition | null>(null);
const [isConnectionOptionsPopoverOpen, setIsConnectionOptionsPopoverOpen] = useState(false);
const [connectionOptionsPopoverPosition, setConnectionOptionsPopoverPosition] = useState<AnchorPosition | null>(null);

const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const isAuthError = isAuthenticationError(policy, CONST.POLICY.CONNECTIONS.NAME.CERTINIA);
Expand All @@ -51,47 +51,60 @@ function ConnectToCertiniaFlow({policyID}: ConnectToCertiniaFlowProps) {
text: translate('workspace.certinia.prerequisites.connectButton'),
onSelected: () => {
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_CERTINIA_PREREQUISITES.getRoute(policyID));
setIsReuseConnectionsPopoverOpen(false);
setIsConnectionOptionsPopoverOpen(false);
},
},
{
icon: icons.Copy,
text: translate('workspace.common.reuseExistingConnection'),
icon: icons.LinkCopy,
text: translate('workspace.certinia.prerequisites.connectSandboxButton'),
onSelected: () => {
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_CERTINIA_EXISTING_CONNECTIONS.getRoute(policyID));
setIsReuseConnectionsPopoverOpen(false);
const isSandbox = true;
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_CERTINIA_PREREQUISITES.getRoute(policyID, CONST.CERTINIA_PREREQUISITES.PAGE_NAME.INSTALL_BUNDLE, isSandbox));
Comment thread
ShridharGoel marked this conversation as resolved.
Resolved
setIsConnectionOptionsPopoverOpen(false);
},
},
...(hasReusablePoliciesConnectedToCertinia
? [
{
icon: icons.Copy,
text: translate('workspace.common.reuseExistingConnection'),
onSelected: () => {
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_CERTINIA_EXISTING_CONNECTIONS.getRoute(policyID));
setIsConnectionOptionsPopoverOpen(false);
},
},
]
: []),
];

useEffect(() => {
if (!isAuthError && hasReusablePoliciesConnectedToCertinia) {
if (!isAuthError) {
// We could ignore the lint error here because this effect has no dependencies, and would only run once.
// eslint-disable-next-line react-hooks/set-state-in-effect
setIsReuseConnectionsPopoverOpen(true);
setIsConnectionOptionsPopoverOpen(true);
return;
}
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_CERTINIA_PREREQUISITES.getRoute(policyID));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useLayoutEffect(() => {
if (!isReuseConnectionsPopoverOpen) {
if (!isConnectionOptionsPopoverOpen) {
return;
}

calculatePopoverPosition(threeDotsMenuContainerRef, anchorAlignment).then(setReuseConnectionPopoverPosition);
}, [isReuseConnectionsPopoverOpen, calculatePopoverPosition, threeDotsMenuContainerRef]);
calculatePopoverPosition(threeDotsMenuContainerRef, anchorAlignment).then(setConnectionOptionsPopoverPosition);
}, [isConnectionOptionsPopoverOpen, calculatePopoverPosition, threeDotsMenuContainerRef]);

if (!reuseConnectionPopoverPosition) {
if (!connectionOptionsPopoverPosition) {
return null;
}

return (
<PopoverMenu
isVisible={isReuseConnectionsPopoverOpen}
isVisible={isConnectionOptionsPopoverOpen}
onClose={() => {
setIsReuseConnectionsPopoverOpen(false);
setIsConnectionOptionsPopoverOpen(false);
}}
menuItems={connectionOptions}
onItemSelected={(item) => {
Expand All @@ -100,7 +113,7 @@ function ConnectToCertiniaFlow({policyID}: ConnectToCertiniaFlowProps) {
}
item.onSelected();
}}
anchorPosition={reuseConnectionPopoverPosition}
anchorPosition={connectionOptionsPopoverPosition}
anchorAlignment={anchorAlignment}
anchorRef={threeDotsMenuContainerRef}
/>
Expand Down
1 change: 1 addition & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5088,6 +5088,7 @@ ${amount} für ${merchant} – ${date}`,
oauth: 'Über Salesforce anmelden',
oauthDescription: 'Um die Einrichtung abzuschließen, müssen Sie sich über Salesforce und Certinia anmelden.\n\nVerwenden Sie die Schaltfläche unten, um fortzufahren.',
connectButton: 'Mit Certinia verbinden',
connectSandboxButton: 'Mit Certinia Sandbox verbinden',
},
import: {
chartOfAccounts: 'Kontenplan',
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5187,6 +5187,7 @@ const translations = {
oauth: 'Log in through Salesforce',
oauthDescription: "To finish setup, you'll have to sign in through Salesforce and Certinia.\n\nUse the button below to continue.",
connectButton: 'Connect to Certinia',
connectSandboxButton: 'Connect to Certinia Sandbox',
},
import: {
chartOfAccounts: 'Chart of accounts',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4963,6 +4963,7 @@ ${amount} para ${merchant} - ${date}`,
oauth: 'Inicia sesión con Salesforce',
oauthDescription: 'Para terminar la configuración, tendrás que iniciar sesión a través de Salesforce y Certinia.\n\nUsa el botón de abajo para continuar.',
connectButton: 'Conectar con Certinia',
connectSandboxButton: 'Conectar con Certinia Sandbox',
},
import: {
chartOfAccounts: 'Plan de cuentas',
Expand Down
1 change: 1 addition & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5100,6 +5100,7 @@ ${amount} pour ${merchant} - ${date}`,
oauth: 'Se connecter via Salesforce',
oauthDescription: 'Pour terminer la configuration, vous devez vous connecter via Salesforce et Certinia.\n\nUtilisez le bouton ci-dessous pour continuer.',
connectButton: 'Se connecter à Certinia',
connectSandboxButton: 'Se connecter à Certinia Sandbox',
},
import: {
chartOfAccounts: 'Plan comptable',
Expand Down
1 change: 1 addition & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5073,6 +5073,7 @@ ${amount} per ${merchant} - ${date}`,
oauth: 'Accedi tramite Salesforce',
oauthDescription: 'Per completare la configurazione, dovrai accedere tramite Salesforce e Certinia.\n\nUsa il pulsante qui sotto per continuare.',
connectButton: 'Connetti a Certinia',
connectSandboxButton: 'Connetti a Certinia Sandbox',
},
import: {
chartOfAccounts: 'Piano dei conti',
Expand Down
1 change: 1 addition & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5019,6 +5019,7 @@ ${integrationName === CONST.ONBOARDING_ACCOUNTING_MAPPING.other ? 'あなたの'
oauth: 'Salesforce からログイン',
oauthDescription: '設定を完了するには、Salesforce と Certinia を通じてサインインする必要があります。\n\n続行するには、下のボタンを使用してください。',
connectButton: 'Certinia に接続',
connectSandboxButton: 'Certinia Sandbox に接続',
},
import: {
chartOfAccounts: '勘定科目表',
Expand Down
1 change: 1 addition & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5063,6 +5063,7 @@ ${amount} voor ${merchant} - ${date}`,
oauth: 'Log in via Salesforce',
oauthDescription: 'Om de installatie te voltooien, moet je je aanmelden via Salesforce en Certinia.\n\nGebruik de knop hieronder om door te gaan.',
connectButton: 'Verbind met Certinia',
connectSandboxButton: 'Verbind met Certinia Sandbox',
},
import: {
chartOfAccounts: 'Rekeningschema',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5049,6 +5049,7 @@ ${amount} dla ${merchant} - ${date}`,
oauth: 'Zaloguj się przez Salesforce',
oauthDescription: 'Aby zakończyć konfigurację, musisz się zalogować przez Salesforce i Certinia.\n\nUżyj przycisku poniżej, żeby kontynuować.',
connectButton: 'Połącz z Certinia',
connectSandboxButton: 'Połącz z Certinia Sandbox',
},
import: {
chartOfAccounts: 'Plan kont',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5054,6 +5054,7 @@ ${amount} para ${merchant} - ${date}`,
oauth: 'Entrar pelo Salesforce',
oauthDescription: 'Para concluir a configuração, você precisa entrar pelo Salesforce e pela Certinia.\n\nUse o botão abaixo para continuar.',
connectButton: 'Conectar ao Certinia',
connectSandboxButton: 'Conectar ao Certinia Sandbox',
},
import: {
chartOfAccounts: 'Plano de contas',
Expand Down
1 change: 1 addition & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4919,6 +4919,7 @@ ${amount},商户:${merchant} - 日期:${date}`,
oauth: '通过 Salesforce 登录',
oauthDescription: '要完成设置,您需要通过 Salesforce 和 Certinia 登录。\n\n请使用下方按钮继续。',
connectButton: '连接到 Certinia',
connectSandboxButton: '连接到 Certinia Sandbox',
},
import: {
chartOfAccounts: '会计科目表',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import CertiniaPrerequisitesStep from './prerequisites/CertiniaPrerequisitesStep

type CertiniaPrerequisitesStepExtraProps = SubPageProps & {
onConnect: () => void;
isSandbox: boolean;
};

type CertiniaPrerequisitesPageProps = PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.ACCOUNTING.CERTINIA_PREREQUISITES>;
Expand All @@ -41,19 +42,20 @@ function CertiniaPrerequisitesPage({route}: CertiniaPrerequisitesPageProps) {
const {translate} = useLocalize();
const {environmentURL} = useEnvironment();
const policyID: string = route.params.policyID;
const isSandbox = route.params.isSandbox === 'true';
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const config = policy?.connections?.financialforce?.config;
const shouldBeBlocked = !!config?.isConfigured && !isAuthenticationError(policy, CONST.POLICY.CONNECTIONS.NAME.CERTINIA);

const handleConnect = () => {
connectPolicyToFinancialForce(policyID, false, environmentURL);
connectPolicyToFinancialForce(policyID, isSandbox, environmentURL);
Navigation.dismissModal();
};

const {CurrentPage, nextPage, prevPage, pageIndex, moveTo, currentPageName} = useSubPage<CertiniaPrerequisitesStepExtraProps>({
pages,
onFinished: handleConnect,
buildRoute: (pageName) => ROUTES.POLICY_ACCOUNTING_CERTINIA_PREREQUISITES.getRoute(policyID, pageName),
buildRoute: (pageName) => ROUTES.POLICY_ACCOUNTING_CERTINIA_PREREQUISITES.getRoute(policyID, pageName, isSandbox || undefined),
});

const handleBackButtonPress = () => {
Expand Down Expand Up @@ -93,6 +95,7 @@ function CertiniaPrerequisitesPage({route}: CertiniaPrerequisitesPageProps) {
onMove={moveTo}
currentPageName={currentPageName}
onConnect={handleConnect}
isSandbox={isSandbox}
/>
</ConnectionLayout>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import {View} from 'react-native';

type CertiniaPrerequisitesStepProps = SubPageProps & {
onConnect: () => void;
isSandbox: boolean;
};

function CertiniaPrerequisitesStep({onNext, currentPageName, onConnect}: CertiniaPrerequisitesStepProps) {
function CertiniaPrerequisitesStep({onNext, currentPageName, onConnect, isSandbox}: CertiniaPrerequisitesStepProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const {isOffline} = useNetwork();
Expand All @@ -41,7 +42,7 @@ function CertiniaPrerequisitesStep({onNext, currentPageName, onConnect}: Certini
<Text style={[styles.textStrong, styles.mb2]}>{translate('workspace.certinia.prerequisites.installBundlePSAHeader')}</Text>
<Text style={styles.textNormal}>
{translate('workspace.certinia.prerequisites.installBundleDescription')}{' '}
<TextLink href={CONST.CERTINIA_PSA_BUNDLE_INSTALL_URL.PRODUCTION}>
<TextLink href={isSandbox ? CONST.CERTINIA_PSA_BUNDLE_INSTALL_URL.SANDBOX : CONST.CERTINIA_PSA_BUNDLE_INSTALL_URL.PRODUCTION}>
{translate('workspace.certinia.prerequisites.installBundlePSALink', {version: CONST.CERTINIA_PSA_BUNDLE_VERSION})}
</TextLink>
</Text>
Expand All @@ -50,7 +51,7 @@ function CertiniaPrerequisitesStep({onNext, currentPageName, onConnect}: Certini
<Text style={[styles.textStrong, styles.mb2]}>{translate('workspace.certinia.prerequisites.installBundleFFAHeader')}</Text>
<Text style={styles.textNormal}>
{translate('workspace.certinia.prerequisites.installBundleDescription')}{' '}
<TextLink href={CONST.CERTINIA_FFA_BUNDLE_INSTALL_URL.PRODUCTION}>
<TextLink href={isSandbox ? CONST.CERTINIA_FFA_BUNDLE_INSTALL_URL.SANDBOX : CONST.CERTINIA_FFA_BUNDLE_INSTALL_URL.PRODUCTION}>
{translate('workspace.certinia.prerequisites.installBundleFFALink', {version: CONST.CERTINIA_FFA_BUNDLE_VERSION})}
</TextLink>
</Text>
Expand Down
Loading