Skip to content

Commit

Permalink
added order and account 6
Browse files Browse the repository at this point in the history
  • Loading branch information
KostiantynFandeliuk committed Dec 3, 2024
1 parent 08fe252 commit 198e15b
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions blocks/commerce-orders-list/commerce-orders-list.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,46 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable import/no-extraneous-dependencies */
import { render as accountRenderer } from '@dropins/storefront-account/render.js';
import { OrdersList } from '@dropins/storefront-account/containers/OrdersList.js';
import { readBlockConfig } from '../../scripts/aem.js';
import { checkIsAuthenticated } from '../../scripts/configs.js';
import { render as accountRenderer } from "@dropins/storefront-account/render.js";
import { OrdersList } from "@dropins/storefront-account/containers/OrdersList.js";
import { readBlockConfig } from "../../scripts/aem.js";
import { checkIsAuthenticated } from "../../scripts/configs.js";
import {
CUSTOMER_LOGIN_PATH,
CUSTOMER_ORDER_DETAILS_PATH,
CUSTOMER_ORDERS_PATH,
CUSTOMER_RETURN_DETAILS_PATH,
UPS_TRACKING_URL,
} from '../../scripts/constants.js';
} from "../../scripts/constants.js";

// Initialize
import '../../scripts/initializers/account.js';
import "../../scripts/initializers/account.js";

export default async function decorate(block) {
const { 'minified-view': minifiedViewConfig = 'false' } = readBlockConfig(block);
const { "minified-view": minifiedViewConfig = "false" } =
readBlockConfig(block);

if (!checkIsAuthenticated()) {
window.location.href = CUSTOMER_LOGIN_PATH;
} else {
await accountRenderer.render(OrdersList, {
minifiedView: minifiedViewConfig === 'true',
minifiedView: minifiedViewConfig === "true",
routeTracking: ({ carrier, number }) => {
if (carrier === 'ups') {
if (carrier === "ups") {
return `${UPS_TRACKING_URL}?tracknum=${number}`;
}
return '';
return "";
},
routeOrdersList: () => CUSTOMER_ORDERS_PATH,
routeOrderDetails: (orderNumber) => `${CUSTOMER_ORDER_DETAILS_PATH}?orderRef=${orderNumber}`,
routeReturnDetails: ({ orderNumber, returnNumber }) => `${CUSTOMER_RETURN_DETAILS_PATH}?orderRef=${orderNumber}&returnRef=${returnNumber}`,
routeOrderProduct: (productData) => (productData ? `/products/${productData.product.urlKey}/${productData.product.sku}` : '#'),
routeOrderDetails: (orderNumber) =>
`${CUSTOMER_ORDER_DETAILS_PATH}?orderRef=${orderNumber}`,
routeReturnDetails: ({ orderNumber, returnNumber }) =>
`${CUSTOMER_RETURN_DETAILS_PATH}?orderRef=${orderNumber}&returnRef=${returnNumber}`,
routeOrderProduct: (productData) =>
productData
? `/products/${productData?.product?.urlKey ?? ""}/${
productData?.product?.sku ?? ""
}`
: "#",
})(block);
}
}

0 comments on commit 198e15b

Please sign in to comment.