Skip to content

Commit

Permalink
Order initializer adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
sivaschenko committed Nov 20, 2024
1 parent dc95953 commit 64f7418
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions scripts/initializers/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ await initializeDropin(async () => {
const orderRef = searchParams.get('orderRef');
const returnRef = searchParams.get('returnRef');
const isTokenProvided = orderRef && orderRef.length > 20;
const labels = await fetchPlaceholders();
const langDefinitions = {
default: {
...labels,
},
};

// Handle redirects for user details pages
if (pathname === ORDER_DETAILS_PATH
Expand All @@ -31,8 +37,22 @@ await initializeDropin(async () => {
|| pathname === CUSTOMER_RETURN_DETAILS_PATH
|| pathname === CREATE_RETURN_PATH
|| pathname === CUSTOMER_CREATE_RETURN_PATH) {
await handleUserOrdersRedirects(pathname, isAccountPage, orderRef, returnRef, isTokenProvided);
await handleUserOrdersRedirects(
pathname,
isAccountPage,
orderRef,
returnRef,
isTokenProvided,
langDefinitions,
);
return;
}

await initializers.mountImmediately(initialize, {
langDefinitions,
orderRef,
returnRef,
});
})();

async function handleUserOrdersRedirects(
Expand All @@ -41,15 +61,8 @@ async function handleUserOrdersRedirects(
orderRef,
returnRef,
isTokenProvided,
langDefinitions,
) {
const labels = await fetchPlaceholders();

const langDefinitions = {
default: {
...labels,
},
};

let targetPath = null;
if (pathname.includes(CUSTOMER_ORDERS_PATH)) {
return;
Expand Down

0 comments on commit 64f7418

Please sign in to comment.