From ddf4b45d9078c181e8fc018e5a85bb9cd7d8d664 Mon Sep 17 00:00:00 2001 From: Konstantin Fandelyuk Date: Thu, 19 Sep 2024 17:44:22 +0300 Subject: [PATCH] updated props --- .../commerce-search-order.js | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/blocks/commerce-search-order/commerce-search-order.js b/blocks/commerce-search-order/commerce-search-order.js index af8f7011cf..007527061e 100644 --- a/blocks/commerce-search-order/commerce-search-order.js +++ b/blocks/commerce-search-order/commerce-search-order.js @@ -1,42 +1,44 @@ /* eslint-disable import/no-unresolved */ /* eslint-disable import/no-extraneous-dependencies */ -import { SignIn } from '@dropins/storefront-auth/containers/SignIn.js'; -import { OrderSearch } from '@dropins/storefront-order/containers/OrderSearch.js'; -import { render as authRenderer } from '@dropins/storefront-auth/render.js'; -import { render as orderRenderer } from '@dropins/storefront-order/render.js'; -import { getCookie } from '../../scripts/configs.js'; +import { SignIn } from "@dropins/storefront-auth/containers/SignIn.js"; +import { OrderSearch } from "@dropins/storefront-order/containers/OrderSearch.js"; +import { render as authRenderer } from "@dropins/storefront-auth/render.js"; +import { render as orderRenderer } from "@dropins/storefront-order/render.js"; +import { getCookie } from "../../scripts/configs.js"; -const renderSignIn = async (element, email, orderNumber) => authRenderer.render(SignIn, { - initialEmailValue: email, - renderSignUpLink: false, - labels: { - formTitleText: email - ? 'Enter your password to view order details' - : 'Sign in to view order details', - primaryButtonText: 'View order', - }, - routeForgotPassword: () => 'reset-password.html', - routeRedirectOnSignIn: () => `/customer/order-details?orderRef=${orderNumber}`, -})(element); +const renderSignIn = async (element, email, orderNumber) => + authRenderer.render(SignIn, { + initialEmailValue: email, + renderSignUpLink: false, + labels: { + formTitleText: email + ? "Enter your password to view order details" + : "Sign in to view order details", + primaryButtonText: "View order", + }, + routeForgotPassword: () => "reset-password.html", + routeRedirectOnSignIn: () => + `/customer/order-details?orderRef=${orderNumber}`, + })(element); export default async function decorate(block) { - const isAuthenticated = !!getCookie('auth_dropin_user_token') || false; + const isAuthenticated = !!getCookie("auth_dropin_user_token") || false; await orderRenderer.render(OrderSearch, { isAuth: isAuthenticated, renderSignIn: async ({ render, formValues }) => { if (render) { - renderSignIn(block, formValues?.email ?? '', formValues?.number ?? ''); + renderSignIn(block, formValues?.email ?? "", formValues?.number ?? ""); return false; } return true; }, - routeCustomerOrderDetails: () => '/customer/order-details', - routeOrderDetails: () => '/order-details', + routeCustomerOrder: () => "/customer/order-details", + routeGuestOrder: () => "/order-details", onError: async (errorInformation) => { - console.info('errorInformation', errorInformation); + console.info("errorInformation", errorInformation); }, })(block); }