Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create return 2 #203

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2eb34af
Integrate CreateReturn container
Ferri0 Nov 8, 2024
3559135
Add order build (manually)
Ferri0 Nov 8, 2024
6532e25
test 1
KostiantynFandeliuk Nov 11, 2024
c61f4d6
test 2
KostiantynFandeliuk Nov 11, 2024
4c92188
test 3
KostiantynFandeliuk Nov 11, 2024
a8e5179
test 4
KostiantynFandeliuk Nov 11, 2024
7c785a5
test 5
KostiantynFandeliuk Nov 11, 2024
6282add
test 5
KostiantynFandeliuk Nov 11, 2024
6233f18
test 6
KostiantynFandeliuk Nov 11, 2024
26c5218
test 7
KostiantynFandeliuk Nov 11, 2024
0f7d94b
test 8
KostiantynFandeliuk Nov 11, 2024
1cb674b
test 9
KostiantynFandeliuk Nov 11, 2024
928c050
test 10
KostiantynFandeliuk Nov 11, 2024
30ad58c
test 11
KostiantynFandeliuk Nov 11, 2024
d3d7d32
test 12
KostiantynFandeliuk Nov 11, 2024
3a7d24c
test 12
KostiantynFandeliuk Nov 11, 2024
e79279a
test 12
KostiantynFandeliuk Nov 11, 2024
529008f
test bug? 1
KostiantynFandeliuk Nov 12, 2024
48ca069
test bug? 2
KostiantynFandeliuk Nov 12, 2024
ec63fb4
test bug? 4
KostiantynFandeliuk Nov 12, 2024
161945f
test bug? 5
KostiantynFandeliuk Nov 12, 2024
5c19054
test bug? 6
KostiantynFandeliuk Nov 12, 2024
fca0819
test bug? 7
KostiantynFandeliuk Nov 12, 2024
8cdeb33
test bug? 8
KostiantynFandeliuk Nov 12, 2024
cc98b47
test bug? 9
KostiantynFandeliuk Nov 12, 2024
8d93122
test bug? 10
KostiantynFandeliuk Nov 12, 2024
f5ebdd0
test bug? 11
KostiantynFandeliuk Nov 12, 2024
f7c39d6
errors link
KostiantynFandeliuk Nov 12, 2024
fe0d224
test bug? 13
KostiantynFandeliuk Nov 12, 2024
01441ea
test bug? 14
KostiantynFandeliuk Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions blocks/commerce-create-return/commerce-create-return.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* stylelint-disable no-empty-source */

body:not(.columns) main div.order-create-return {
margin-top: var(--spacing-large);
}
15 changes: 15 additions & 0 deletions blocks/commerce-create-return/commerce-create-return.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable import/no-extraneous-dependencies */
import { render as orderRenderer } from '@dropins/storefront-order/render.js';
import { CreateReturn } from '@dropins/storefront-order/containers/CreateReturn.js';
import { checkIsAuthenticated } from '../../scripts/configs.js';
import { ORDER_DETAILS_PATH, CUSTOMER_ORDER_DETAILS_PATH } from '../../scripts/constants.js';

// Initialize
import '../../scripts/initializers/order.js';

export default async function decorate(block) {
await orderRenderer.render(CreateReturn, {
routeReturnSuccess: (orderData) => (checkIsAuthenticated() ? `${CUSTOMER_ORDER_DETAILS_PATH}?orderRef=${orderData.number}` : `${ORDER_DETAILS_PATH}?orderRef=${orderData.token}`),
})(block);
}
13 changes: 12 additions & 1 deletion blocks/commerce-order-status/commerce-order-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@
import { render as orderRenderer } from '@dropins/storefront-order/render.js';
import { OrderStatus } from '@dropins/storefront-order/containers/OrderStatus.js';
import { checkIsAuthenticated } from '../../scripts/configs.js';
import { CREATE_RETURN_PATH, CUSTOMER_CREATE_RETURN_PATH } from '../../scripts/constants.js';

// Initialize
import '../../scripts/initializers/order.js';

export default async function decorate(block) {
await orderRenderer.render(OrderStatus, {
routeCreateReturn: (orderData) => (checkIsAuthenticated() ? `/customer/create-return?orderId=${orderData.id}` : `/create-return?orderId=${orderData.id}`),
routeCreateReturn: ({ token, number: orderNumber }) => {
const isAuthenticated = checkIsAuthenticated();

const { searchParams } = new URL(window.location.href);
const orderRefFromUrl = searchParams.get('orderRef');
const newOrderRef = isAuthenticated ? orderNumber : token;

const encodedOrderRef = encodeURIComponent(orderRefFromUrl || newOrderRef);

return checkIsAuthenticated() ? `${CUSTOMER_CREATE_RETURN_PATH}?orderRef=${encodedOrderRef}` : `${CREATE_RETURN_PATH}?orderRef=${encodedOrderRef}`;
},
routeOnSuccess: () => '/cart',
})(block);
}
4 changes: 3 additions & 1 deletion blocks/commerce-returns-list/commerce-returns-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
} else {
await orderRenderer.render(ReturnsList, {
minifiedView: minifiedViewConfig === 'true',
routeReturnDetails: ({ orderNumber, returnNumber }) => `${CUSTOMER_RETURN_DETAILS_PATH}?orderRef=${orderNumber}&returnRef=${returnNumber}`,
routeReturnDetails: (props) => {

Check failure on line 27 in blocks/commerce-returns-list/commerce-returns-list.js

View workflow job for this annotation

GitHub Actions / build

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`
return `${CUSTOMER_RETURN_DETAILS_PATH}?orderRef=${props?.orderNumber}&returnRef=${props?.returnNumber}`

Check failure on line 28 in blocks/commerce-returns-list/commerce-returns-list.js

View workflow job for this annotation

GitHub Actions / build

Missing semicolon
},
routeOrderDetails: ({ orderNumber }) => `${CUSTOMER_ORDER_DETAILS_PATH}?orderRef=${orderNumber}`,
routeReturnsList: () => CUSTOMER_RETURNS_PATH,
routeProductDetails: (productData) => (productData ? `/products/${productData.product.urlKey}/${productData.product.sku}` : '#'),
Expand Down
44 changes: 32 additions & 12 deletions scripts/__dropins__/storefront-order/api.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/*! Copyright 2024 Adobe
All Rights Reserved. */
import{Initializer as I}from"@dropins/tools/lib.js";import{events as d}from"@dropins/tools/event-bus.js";import{f as n,h as m}from"./chunks/fetch-graphql.js";import{g as P,r as U,s as Y,a as q,b as Q}from"./chunks/fetch-graphql.js";import{h as l}from"./chunks/network-error.js";import{P as u,a as _,G as c,O as p,B as O,R as h,c as T}from"./chunks/transform-order-details.js";import{O as D,A as R}from"./chunks/getGuestOrder.graphql.js";import{t as G}from"./chunks/getCustomer.js";import{a as H,g as K}from"./chunks/getCustomer.js";import{g as J}from"./chunks/getAttributesForm.js";import{g as W}from"./chunks/getStoreConfig.js";import{g as Z}from"./chunks/getCustomerOrdersReturn.js";import{c as re,r as te}from"./chunks/requestGuestOrderCancel.js";import{r as se}from"./chunks/reorderItems.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/convertCase.js";const b=`
query ORDER_BY_NUMBER($orderNumber: String!) {
import{Initializer as I}from"@dropins/tools/lib.js";import{events as o}from"@dropins/tools/event-bus.js";import{f as n,h as m}from"./chunks/fetch-graphql.js";import{g as U,r as Y,s as q,a as Q,b as H}from"./chunks/fetch-graphql.js";import{h as l}from"./chunks/network-error.js";import{P as u,a as _,G as p,O as c,B as O,R as D,c as b}from"./chunks/transform-order-details.js";import{O as R,A as h}from"./chunks/getGuestOrder.graphql.js";import{t as T}from"./chunks/getCustomer.js";import{g as j,a as J}from"./chunks/getCustomer.js";import{g as W}from"./chunks/getAttributesForm.js";import{g as Z}from"./chunks/getStoreConfig.js";import{g as re}from"./chunks/getCustomerOrdersReturn.js";import{g as ae,r as se}from"./chunks/requestReturn.js";import{c as oe,r as ie}from"./chunks/requestGuestOrderCancel.js";import{r as me}from"./chunks/reorderItems.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/convertCase.js";import"./chunks/transform-attributes-form.js";const G=`
query ORDER_BY_NUMBER($orderNumber: String!, $pageSize: Int) {
customer {
orders(
filter: { number: { eq: $orderNumber } }
Expand All @@ -17,9 +15,28 @@ query ORDER_BY_NUMBER($orderNumber: String!) {
carrier
shipping_method
is_virtual
returns {
returns(pageSize: $pageSize) {
...OrderReturns
}
items_eligible_for_return {
...OrderItemDetails
... on BundleOrderItem {
...BundleOrderItemDetails
}
... on GiftCardOrderItem {
...GiftCardDetails
product {
...ProductDetails
}
}
... on DownloadableOrderItem {
product_name
downloadable_links {
sort_order
title
}
}
}
applied_coupons {
code
}
Expand Down Expand Up @@ -88,13 +105,13 @@ query ORDER_BY_NUMBER($orderNumber: String!) {
}
${u}
${_}
${c}
${p}
${c}
${O}
${D}
${R}
${h}
`,f=async(e,r,t)=>await n(b,{method:"GET",cache:"force-cache",variables:{orderNumber:e}}).then(a=>{var s;return(s=a.errors)!=null&&s.length?m(a.errors):T(t??"orderData",a,r)}).catch(l),y=`
${D}
`,y=async({orderId:e,returnRef:r,queryType:t,returnsPageSize:a=50})=>await n(G,{method:"GET",cache:"force-cache",variables:{orderNumber:e,pageSize:a}}).then(s=>{var d;return(d=s.errors)!=null&&d.length?m(s.errors):b(t??"orderData",s,r)}).catch(l),f=`
query ORDER_BY_TOKEN($token: String!) {
guestOrderByToken(input: { token: $token }) {
email
Expand All @@ -110,7 +127,10 @@ query ORDER_BY_TOKEN($token: String!) {
gift_receipt_included
available_actions
is_virtual
returns {
items_eligible_for_return {
...OrderItemDetails
}
returns(pageSize: 50) {
...OrderReturns
}
payment_methods {
Expand Down Expand Up @@ -182,10 +202,10 @@ query ORDER_BY_TOKEN($token: String!) {
}
${u}
${_}
${c}
${p}
${c}
${O}
${D}
${R}
${h}
`,A=async(e,r)=>await n(y,{method:"GET",cache:"no-cache",variables:{token:e}}).then(t=>{var a;return(a=t.errors)!=null&&a.length?m(t.errors):G(t,r)}).catch(l),$=async e=>{var i;const r=(e==null?void 0:e.orderRef)??"",t=(e==null?void 0:e.returnRef)??"",a=r&&typeof(e==null?void 0:e.orderRef)=="string"&&((i=e==null?void 0:e.orderRef)==null?void 0:i.length)>20,s=(e==null?void 0:e.orderData)??null;if(s){d.emit("order/data",{...s,returnNumber:t});return}if(!r){console.error("Order Token or number not received.");return}const o=a?await A(r,t):await f(r,t,"orderData");o?d.emit("order/data",{...o,returnNumber:t}):d.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},E=new I({init:async e=>{const r={};E.config.setConfig({...r,...e}),$(e).catch(console.error)},listeners:()=>[]}),v=E.config;export{re as cancelOrder,v as config,n as fetchGraphQl,J as getAttributesForm,P as getConfig,H as getCustomer,Z as getCustomerOrdersReturn,K as getGuestOrder,f as getOrderDetailsById,W as getStoreConfig,A as guestOrderByToken,E as initialize,U as removeFetchGraphQlHeader,se as reorderItems,te as requestGuestOrderCancel,Y as setEndpoint,q as setFetchGraphQlHeader,Q as setFetchGraphQlHeaders};
${D}
`,$=async(e,r)=>await n(f,{method:"GET",cache:"no-cache",variables:{token:e}}).then(t=>{var a;return(a=t.errors)!=null&&a.length?m(t.errors):T(t,r)}).catch(l),A="orderData",C=async e=>{var i;const r=typeof(e==null?void 0:e.orderRef)=="string"?e==null?void 0:e.orderRef:"",t=typeof(e==null?void 0:e.returnRef)=="string"?e==null?void 0:e.returnRef:"",a=r&&typeof(e==null?void 0:e.orderRef)=="string"&&((i=e==null?void 0:e.orderRef)==null?void 0:i.length)>20,s=(e==null?void 0:e.orderData)??null;if(s){o.emit("order/data",{...s,returnNumber:t});return}if(!r){console.error("Order Token or number not received.");return}const d=a?await $(r,t):await y({orderId:r,returnRef:t,queryType:A});d?o.emit("order/data",{...d,returnNumber:t}):o.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},E=new I({init:async e=>{const r={};E.config.setConfig({...r,...e}),C(e).catch(console.error)},listeners:()=>[]}),x=E.config;export{oe as cancelOrder,x as config,n as fetchGraphQl,W as getAttributesForm,ae as getAttributesList,U as getConfig,j as getCustomer,re as getCustomerOrdersReturn,J as getGuestOrder,y as getOrderDetailsById,Z as getStoreConfig,$ as guestOrderByToken,E as initialize,Y as removeFetchGraphQlHeader,me as reorderItems,ie as requestGuestOrderCancel,se as requestReturn,q as setEndpoint,Q as setFetchGraphQlHeader,H as setFetchGraphQlHeaders};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { AttributesFormModel } from '../../data/models';

export declare const getAttributesList: (entityType: string) => Promise<AttributesFormModel[] | [
]>;
//# sourceMappingURL=getAttributesList.d.ts.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare const GET_ATTRIBUTES_LIST = "\n query GET_ATTRIBUTES_LIST($entityType: AttributeEntityTypeEnum!) {\n attributesList(entityType: $entityType) {\n items {\n ... on CustomerAttributeMetadata {\n multiline_count\n sort_order\n validate_rules {\n name\n value\n }\n }\n ... on ReturnItemAttributeMetadata {\n sort_order\n }\n code\n label\n default_value\n frontend_input\n is_unique\n is_required\n options {\n is_default\n label\n value\n }\n }\n errors {\n type\n message\n }\n }\n }\n";
//# sourceMappingURL=getAttributesList.graphql.d.ts.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './getAttributesList';
//# sourceMappingURL=index.d.ts.map
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CustomerOrdersReturnModel } from '../../data/models';

export declare const getCustomerOrdersReturn: () => Promise<CustomerOrdersReturnModel | null>;
export declare const getCustomerOrdersReturn: (pageSize?: number) => Promise<CustomerOrdersReturnModel | null>;
//# sourceMappingURL=getCustomerOrdersReturn.d.ts.map
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GetOrderDetailsByIdProps } from '../../types';
import { TransformedData } from '../../data/models';

export declare const getOrderDetailsById: <T extends "orderData">(orderId?: string, returnRef?: string, queryType?: T | undefined) => Promise<TransformedData<T>>;
export declare const getOrderDetailsById: <T extends "orderData">({ orderId, returnRef, queryType, returnsPageSize, }: GetOrderDetailsByIdProps) => Promise<TransformedData<T>>;
//# sourceMappingURL=getOrderDetailsById.d.ts.map
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export declare const PRODUCT_DETAILS_FRAGMENT = "\n fragment ProductDetails on ProductInterface {\n __typename\n canonical_url\n url_key\n uid\n name\n sku\n only_x_left_in_stock\n stock_status\n thumbnail {\n label\n url\n }\n price_range {\n maximum_price {\n regular_price {\n currency\n value\n }\n }\n }\n }\n";
export declare const PRICE_DETAILS_FRAGMENT = "\n fragment PriceDetails on OrderItemInterface {\n prices {\n price_including_tax {\n value\n currency\n }\n original_price {\n value\n currency\n }\n original_price_including_tax {\n value\n currency\n }\n price {\n value\n currency\n }\n }\n }\n";
export declare const GIFT_CARD_DETAILS_FRAGMENT = "\n fragment GiftCardDetails on GiftCardOrderItem {\n ...PriceDetails\n gift_message {\n message\n }\n gift_card {\n recipient_name\n recipient_email\n sender_name\n sender_email\n message\n }\n }\n";
export declare const ORDER_ITEM_DETAILS_FRAGMENT = "\n fragment OrderItemDetails on OrderItemInterface {\n __typename\n status\n product_name\n product_url_key\n id\n quantity_ordered\n quantity_shipped\n quantity_canceled\n quantity_invoiced\n quantity_refunded\n quantity_returned\n product_sale_price {\n value\n currency\n }\n selected_options {\n label\n value\n }\n product {\n ...ProductDetails\n }\n ...PriceDetails\n }\n";
export declare const ORDER_ITEM_DETAILS_FRAGMENT = "\n fragment OrderItemDetails on OrderItemInterface {\n __typename\n status\n product_sku\n eligible_for_return\n product_name\n product_url_key\n id\n quantity_ordered\n quantity_shipped\n quantity_canceled\n quantity_invoiced\n quantity_refunded\n product_sale_price {\n value\n currency\n }\n selected_options {\n label\n value\n }\n product {\n ...ProductDetails\n }\n ...PriceDetails\n }\n";
export declare const BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT = "\n fragment BundleOrderItemDetails on BundleOrderItem {\n ...PriceDetails\n bundle_options {\n uid\n label\n values {\n uid\n product_name\n }\n }\n }\n";
//# sourceMappingURL=orderItemsFragment.graphql.d.ts.map
2 changes: 2 additions & 0 deletions scripts/__dropins__/storefront-order/api/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export * from './getAttributesForm';
export * from './getCustomer';
export * from './getStoreConfig';
export * from './getCustomerOrdersReturn';
export * from './getAttributesList';
export * from './requestReturn';
export * from './cancelOrder';
export * from './requestGuestOrderCancel';
export * from './reorderItems';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare const REQUEST_RETURN_ORDER_FRAGMENT = "\n fragment OrderReturn on Return {\n __typename\n uid\n status\n number\n created_at\n }\n";
//# sourceMappingURL=fragments.d.ts.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare const REQUEST_RETURN_ORDER: string;
//# sourceMappingURL=requestReturn.graphql.d.ts.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './requestReturn';
//# sourceMappingURL=index.d.ts.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { RequestReturnProps } from '../../types';

export declare const requestReturn: (form: RequestReturnProps) => Promise<{
uid: string;
number: string;
status: string;
createdAt: string;
}>;
//# sourceMappingURL=requestReturn.d.ts.map
Loading
Loading