Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
KostiantynFandeliuk committed Sep 20, 2024
1 parent 0a0173c commit 52e8d56
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 30 deletions.
78 changes: 54 additions & 24 deletions blocks/commerce-search-order/commerce-search-order.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,74 @@
/* 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';

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);
import { SignIn } from "@dropins/storefront-auth/containers/SignIn.js";

Check failure on line 3 in blocks/commerce-search-order/commerce-search-order.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
import { OrderSearch } from "@dropins/storefront-order/containers/OrderSearch.js";

Check failure on line 4 in blocks/commerce-search-order/commerce-search-order.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
import { render as authRenderer } from "@dropins/storefront-auth/render.js";

Check failure on line 5 in blocks/commerce-search-order/commerce-search-order.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
import { render as orderRenderer } from "@dropins/storefront-order/render.js";

Check failure on line 6 in blocks/commerce-search-order/commerce-search-order.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
import { getCookie } from "../../scripts/configs.js";

Check failure on line 7 in blocks/commerce-search-order/commerce-search-order.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
import { events } from "@dropins/tools/event-bus.js";

Check failure on line 8 in blocks/commerce-search-order/commerce-search-order.js

View workflow job for this annotation

GitHub Actions / build

`@dropins/tools/event-bus.js` import should occur before import of `../../scripts/configs.js`

Check failure on line 8 in blocks/commerce-search-order/commerce-search-order.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote

const renderSignIn = async (element, email, orderNumber) =>
authRenderer.render(SignIn, {

Check failure on line 11 in blocks/commerce-search-order/commerce-search-order.js

View workflow job for this annotation

GitHub Actions / build

Expected no linebreak before this expression
initialEmailValue: email,
renderSignUpLink: false,
labels: {
formTitleText: email
? "Enter your password to view order details"

Check failure on line 16 in blocks/commerce-search-order/commerce-search-order.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
: "Sign in to view order details",

Check failure on line 17 in blocks/commerce-search-order/commerce-search-order.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
primaryButtonText: "View order",
},
routeForgotPassword: () => "reset-password.html",
routeRedirectOnSignIn: () =>
`/customer/order-details?orderRef=${orderNumber}`,
})(element);

export default async function decorate(block) {
block.innerHTML = '';
block.innerHTML = "";

const isAuthenticated = !!getCookie("auth_dropin_user_token") || false;

events.on("order/data", async (order) => {
block.innerHTML = "";

await orderRenderer.render(OrderSearch, {
orderSearch: order,
isAuth: isAuthenticated,
renderSignIn: async ({ render, formValues }) => {
if (render) {
renderSignIn(
block,
formValues?.email ?? "",
formValues?.number ?? ""
);

return false;
}

const isAuthenticated = !!getCookie('auth_dropin_user_token') || false;
return true;
},
routeCustomerOrder: () => "/customer/order-details",
routeGuestOrder: () => "/order-details",
onError: async (errorInformation) => {
console.info("errorInformation", errorInformation);
},
})(block);
});

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;
},
routeCustomerOrder: () => '/customer/order-details',
routeGuestOrder: () => '/order-details',
routeCustomerOrder: () => "/customer/order-details",
routeGuestOrder: () => "/order-details",
onError: async (errorInformation) => {
console.info('errorInformation', errorInformation);
console.info("errorInformation", errorInformation);
},
})(block);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 52e8d56

Please sign in to comment.