Skip to content

Commit

Permalink
Merge pull request #42383 from hungvu193/fix-42376
Browse files Browse the repository at this point in the history
[Wave Collect] [Xero]  Fix: When you click “Sync now” you see the Quickbooks Online text very briefly
  • Loading branch information
lakchote authored May 21, 2024
2 parents 4059db3 + c444695 commit 9d57ceb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,8 @@ const CONST = {
XERO: 'xero',
},
SYNC_STAGE_NAME: {
STARTING_IMPORT: 'startingImport',
STARTING_IMPORT_QBO: 'startingImportQBO',
STARTING_IMPORT_XERO: 'startingImportXero',
QBO_IMPORT_MAIN: 'quickbooksOnlineImportMain',
QBO_IMPORT_CUSTOMERS: 'quickbooksOnlineImportCustomers',
QBO_IMPORT_EMPLOYEES: 'quickbooksOnlineImportEmployees',
Expand Down
4 changes: 3 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2396,7 +2396,9 @@ export default {
return 'Checking QuickBooks Online connection';
case 'quickbooksOnlineImportMain':
return 'Importing your QuickBooks Online data';
case 'startingImport':
case 'startingImportXero':
return 'Importing your Xero data';
case 'startingImportQBO':
return 'Importing your QuickBooks Online data';
case 'quickbooksOnlineSyncTitle':
return 'Synchronizing QuickBooks Online data';
Expand Down
4 changes: 3 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2400,7 +2400,9 @@ export default {
return 'Revisando conexión a QuickBooks Online';
case 'quickbooksOnlineImportMain':
return 'Importando datos desde QuickBooks Online';
case 'startingImport':
case 'startingImportXero':
return 'Importando datos desde Xero';
case 'startingImportQBO':
return 'Importando datos desde QuickBooks Online';
case 'quickbooksOnlineSyncTitle':
return 'Sincronizando datos desde QuickBooks Online';
Expand Down
24 changes: 12 additions & 12 deletions src/libs/actions/connections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,13 @@ function updatePolicyConnectionConfig<TConnectionName extends ConnectionName, TS
* @param connectionName - Name of the connection, QBO/Xero
*/
function syncConnection(policyID: string, connectionName: PolicyConnectionName | undefined) {
const isQBOConnection = connectionName === CONST.POLICY.CONNECTIONS.NAME.QBO;
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`,
value: {
stageInProgress: CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.STARTING_IMPORT,
stageInProgress: isQBOConnection ? CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.STARTING_IMPORT_QBO : CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.STARTING_IMPORT_XERO,
connectionName,
},
},
Expand All @@ -146,18 +147,17 @@ function syncConnection(policyID: string, connectionName: PolicyConnectionName |
},
];

const parameters: SyncPolicyToQuickbooksOnlineParams | SyncPolicyToXeroParams =
connectionName === CONST.POLICY.CONNECTIONS.NAME.QBO
? ({
policyID,
idempotencyKey: policyID,
} as SyncPolicyToQuickbooksOnlineParams)
: ({
policyID,
idempotencyKey: policyID,
} as SyncPolicyToXeroParams);
const parameters: SyncPolicyToQuickbooksOnlineParams | SyncPolicyToXeroParams = isQBOConnection
? ({
policyID,
idempotencyKey: policyID,
} as SyncPolicyToQuickbooksOnlineParams)
: ({
policyID,
idempotencyKey: policyID,
} as SyncPolicyToXeroParams);

API.read(connectionName === CONST.POLICY.CONNECTIONS.NAME.QBO ? READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE : READ_COMMANDS.SYNC_POLICY_TO_XERO, parameters, {
API.read(isQBOConnection ? READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE : READ_COMMANDS.SYNC_POLICY_TO_XERO, parameters, {
optimisticData,
failureData,
});
Expand Down

0 comments on commit 9d57ceb

Please sign in to comment.