@commercelayer/react-components 4.13.6 → 4.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/customers/CustomerContainer.js +1 -1
- package/lib/cjs/components/customers/MyIdentityLink.d.ts +4 -0
- package/lib/cjs/components/customers/MyIdentityLink.js +1 -1
- package/lib/cjs/context/CustomerContext.d.ts +2 -0
- package/lib/cjs/hooks/useCustomerContainer.d.ts +2 -1
- package/lib/cjs/hooks/useCustomerContainer.js +1 -1
- package/lib/cjs/reducers/OrderReducer.d.ts +1 -0
- package/lib/cjs/reducers/OrderReducer.js +1 -1
- package/lib/cjs/utils/getApplicationLink.d.ts +4 -1
- package/lib/cjs/utils/getApplicationLink.js +1 -1
- package/lib/esm/components/customers/CustomerContainer.js +1 -1
- package/lib/esm/components/customers/MyIdentityLink.d.ts +4 -0
- package/lib/esm/components/customers/MyIdentityLink.js +1 -1
- package/lib/esm/context/CustomerContext.d.ts +2 -0
- package/lib/esm/hooks/useCustomerContainer.d.ts +2 -1
- package/lib/esm/hooks/useCustomerContainer.js +1 -1
- package/lib/esm/reducers/OrderReducer.d.ts +1 -0
- package/lib/esm/reducers/OrderReducer.js +1 -1
- package/lib/esm/utils/getApplicationLink.d.ts +4 -1
- package/lib/esm/utils/getApplicationLink.js +1 -1
- package/package.json +23 -23
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CustomerContainer=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),CustomerReducer_1=tslib_1.__importStar(require("../../reducers/CustomerReducer")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),CustomerContext_1=tslib_1.__importDefault(require("../../context/CustomerContext")),isGuestToken_1=require("../../utils/isGuestToken");function CustomerContainer(props){const{children,isGuest}=props,[state,dispatch]=(0,react_1.useReducer)(CustomerReducer_1.default,CustomerReducer_1.customerInitialState),{order,addResourceToInclude,include,updateOrder,includeLoaded,withoutIncludes}=(0,react_1.useContext)(OrderContext_1.default),config=(0,react_1.useContext)(CommerceLayerContext_1.default);(0,react_1.useEffect)(()=>{if(config.accessToken){if(isGuest??(0,isGuestToken_1.isGuestToken)(config.accessToken))return;include?.includes("available_customer_payment_sources.payment_source")?includeLoaded?.["available_customer_payment_sources.payment_source"]||addResourceToInclude({newResourceLoaded:{"available_customer_payment_sources.payment_source":!0,"available_customer_payment_sources.payment_method":!0}}):addResourceToInclude({newResource:["available_customer_payment_sources.payment_source","available_customer_payment_sources.payment_method"]})}},[config.accessToken,include?.length,Object.keys(includeLoaded??{}).length]),(0,react_1.useEffect)(()=>{if(config.accessToken){if(isGuest??(0,isGuestToken_1.isGuestToken)(config.accessToken))return;state.customers==null&&(0,CustomerReducer_1.getCustomerInfo)({config,dispatch}),state.addresses==null&&(0,CustomerReducer_1.getCustomerAddresses)({config,dispatch,isOrderAvailable:withoutIncludes!=null}),order?.available_customer_payment_sources&&(0,CustomerReducer_1.getCustomerPaymentSources)({dispatch,order}),config.accessToken&&order==null&&include==null&&includeLoaded==null&&withoutIncludes===void 0&&function(){return tslib_1.__awaiter(this,void 0,void 0,function*(){yield(0,CustomerReducer_1.getCustomerOrders)({config,dispatch}),yield(0,CustomerReducer_1.getCustomerSubscriptions)({config,dispatch}),yield(0,CustomerReducer_1.getCustomerPayments)({config,dispatch})})}()}},[config.accessToken,order?.payment_source!=null,isGuest]);const contextValue=(0,react_1.useMemo)(()=>Object.assign(Object.assign({isGuest},state),{saveCustomerUser:customerEmail=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield(0,CustomerReducer_1.saveCustomerUser)({config,customerEmail,dispatch,updateOrder,order})}),setCustomerErrors:errors=>{(0,CustomerReducer_1.setCustomerErrors)(errors,dispatch)},setCustomerEmail:customerEmail=>{(0,CustomerReducer_1.setCustomerEmail)(customerEmail,dispatch)},getCustomerPaymentSources:()=>{(0,CustomerReducer_1.getCustomerPaymentSources)({dispatch,order})},deleteCustomerAddress:_a=>tslib_1.__awaiter(this,[_a],void 0,function*({customerAddressId}){yield(0,CustomerReducer_1.deleteCustomerAddress)({customerAddressId,dispatch,config,addresses:state.addresses})}),setResourceTrigger:props2=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield(0,CustomerReducer_1.setResourceTrigger)(Object.assign(Object.assign({},props2),{dispatch,config}))}),createCustomerAddress:address=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield(0,CustomerReducer_1.createCustomerAddress)({address,config,dispatch,state})}),getCustomerOrders:_b=>tslib_1.__awaiter(this,[_b],void 0,function*({pageNumber,pageSize}){yield(0,CustomerReducer_1.getCustomerOrders)({config,dispatch,pageNumber,pageSize})}),getCustomerSubscriptions:_c=>tslib_1.__awaiter(this,[_c],void 0,function*({pageNumber,pageSize,id}){yield(0,CustomerReducer_1.getCustomerSubscriptions)({config,dispatch,pageNumber,pageSize,id})})}),[state,isGuest]);return(0,jsx_runtime_1.jsx)(CustomerContext_1.default.Provider,{value:contextValue,children})}exports.CustomerContainer=CustomerContainer,exports.default=CustomerContainer;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CustomerContainer=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),CustomerReducer_1=tslib_1.__importStar(require("../../reducers/CustomerReducer")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),CustomerContext_1=tslib_1.__importDefault(require("../../context/CustomerContext")),isGuestToken_1=require("../../utils/isGuestToken");function CustomerContainer(props){const{children,isGuest}=props,[state,dispatch]=(0,react_1.useReducer)(CustomerReducer_1.default,CustomerReducer_1.customerInitialState),{order,addResourceToInclude,include,updateOrder,includeLoaded,withoutIncludes}=(0,react_1.useContext)(OrderContext_1.default),config=(0,react_1.useContext)(CommerceLayerContext_1.default);(0,react_1.useEffect)(()=>{if(config.accessToken){if(isGuest??(0,isGuestToken_1.isGuestToken)(config.accessToken))return;include?.includes("available_customer_payment_sources.payment_source")?includeLoaded?.["available_customer_payment_sources.payment_source"]||addResourceToInclude({newResourceLoaded:{"available_customer_payment_sources.payment_source":!0,"available_customer_payment_sources.payment_method":!0}}):addResourceToInclude({newResource:["available_customer_payment_sources.payment_source","available_customer_payment_sources.payment_method"]})}},[config.accessToken,include?.length,Object.keys(includeLoaded??{}).length]),(0,react_1.useEffect)(()=>{if(config.accessToken){if(isGuest??(0,isGuestToken_1.isGuestToken)(config.accessToken))return;state.customers==null&&(0,CustomerReducer_1.getCustomerInfo)({config,dispatch}),state.addresses==null&&(0,CustomerReducer_1.getCustomerAddresses)({config,dispatch,isOrderAvailable:withoutIncludes!=null}),order?.available_customer_payment_sources&&(0,CustomerReducer_1.getCustomerPaymentSources)({dispatch,order}),config.accessToken&&order==null&&include==null&&includeLoaded==null&&withoutIncludes===void 0&&function(){return tslib_1.__awaiter(this,void 0,void 0,function*(){yield(0,CustomerReducer_1.getCustomerOrders)({config,dispatch}),yield(0,CustomerReducer_1.getCustomerSubscriptions)({config,dispatch}),yield(0,CustomerReducer_1.getCustomerPayments)({config,dispatch})})}()}},[config.accessToken,order?.payment_source!=null,isGuest]);const contextValue=(0,react_1.useMemo)(()=>Object.assign(Object.assign({isGuest},state),{saveCustomerUser:customerEmail=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield(0,CustomerReducer_1.saveCustomerUser)({config,customerEmail,dispatch,updateOrder,order})}),setCustomerErrors:errors=>{(0,CustomerReducer_1.setCustomerErrors)(errors,dispatch)},setCustomerEmail:customerEmail=>{(0,CustomerReducer_1.setCustomerEmail)(customerEmail,dispatch)},getCustomerPaymentSources:()=>{(0,CustomerReducer_1.getCustomerPaymentSources)({dispatch,order})},deleteCustomerAddress:_a=>tslib_1.__awaiter(this,[_a],void 0,function*({customerAddressId}){yield(0,CustomerReducer_1.deleteCustomerAddress)({customerAddressId,dispatch,config,addresses:state.addresses})}),setResourceTrigger:props2=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield(0,CustomerReducer_1.setResourceTrigger)(Object.assign(Object.assign({},props2),{dispatch,config}))}),createCustomerAddress:address=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield(0,CustomerReducer_1.createCustomerAddress)({address,config,dispatch,state})}),getCustomerOrders:_b=>tslib_1.__awaiter(this,[_b],void 0,function*({pageNumber,pageSize}){yield(0,CustomerReducer_1.getCustomerOrders)({config,dispatch,pageNumber,pageSize})}),getCustomerSubscriptions:_c=>tslib_1.__awaiter(this,[_c],void 0,function*({pageNumber,pageSize,id}){yield(0,CustomerReducer_1.getCustomerSubscriptions)({config,dispatch,pageNumber,pageSize,id})}),reloadCustomerAddresses:()=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield(0,CustomerReducer_1.getCustomerAddresses)({config,dispatch,isOrderAvailable:withoutIncludes!=null})})}),[state,isGuest]);return(0,jsx_runtime_1.jsx)(CustomerContext_1.default.Provider,{value:contextValue,children})}exports.CustomerContainer=CustomerContainer,exports.default=CustomerContainer;
|
|
@@ -34,6 +34,10 @@ interface Props extends Omit<JSX.IntrinsicElements['a'], 'children'> {
|
|
|
34
34
|
* The domain of your forked application
|
|
35
35
|
*/
|
|
36
36
|
customDomain?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The reset password url
|
|
39
|
+
*/
|
|
40
|
+
resetPasswordUrl?: string;
|
|
37
41
|
}
|
|
38
42
|
/**
|
|
39
43
|
* This component generates a link to the hosted mfe-identity application.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MyIdentityLink=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),getDomain_1=require("../../utils/getDomain"),organization_1=require("../../utils/organization");function MyIdentityLink(props){const{label,children,type,clientId,scope,returnUrl,customDomain}=props,p=tslib_1.__rest(props,["label","children","type","clientId","scope","returnUrl","customDomain"]),{accessToken,endpoint}=(0,react_1.useContext)(CommerceLayerContext_1.default),[href,setHref]=(0,react_1.useState)(void 0);if(accessToken==null||endpoint==null)throw new Error("Cannot use `MyIdentityLink` outside of `CommerceLayer`");const{domain,slug}=(0,getDomain_1.getDomain)(endpoint);(0,react_1.useEffect)(()=>((0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{accessToken}}).then(config=>{var _a;if(!((_a=config?.links)===null||_a===void 0)&&_a.identity)setHref(config.links.identity);else{const link=(0,getApplicationLink_1.getApplicationLink)({slug,accessToken,applicationType:"identity",domain,modeType:type,clientId,scope,returnUrl:returnUrl??window.location.href,customDomain});setHref(link)}}),()=>{setHref(void 0)}),[]);const parentProps=Object.assign({label,href,clientId,scope},p);return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("a",Object.assign({href},p,{children:label}))}exports.MyIdentityLink=MyIdentityLink,exports.default=MyIdentityLink;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MyIdentityLink=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),getDomain_1=require("../../utils/getDomain"),organization_1=require("../../utils/organization");function MyIdentityLink(props){const{label,children,type,clientId,scope,returnUrl,customDomain,resetPasswordUrl}=props,p=tslib_1.__rest(props,["label","children","type","clientId","scope","returnUrl","customDomain","resetPasswordUrl"]),{accessToken,endpoint}=(0,react_1.useContext)(CommerceLayerContext_1.default),[href,setHref]=(0,react_1.useState)(void 0);if(accessToken==null||endpoint==null)throw new Error("Cannot use `MyIdentityLink` outside of `CommerceLayer`");const{domain,slug}=(0,getDomain_1.getDomain)(endpoint);(0,react_1.useEffect)(()=>((0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{accessToken}}).then(config=>{var _a;if(!((_a=config?.links)===null||_a===void 0)&&_a.identity)setHref(config.links.identity);else{const link=(0,getApplicationLink_1.getApplicationLink)({slug,accessToken,applicationType:"identity",domain,modeType:type,clientId,scope,returnUrl:returnUrl??window.location.href,resetPasswordUrl,customDomain});setHref(link)}}),()=>{setHref(void 0)}),[]);const parentProps=Object.assign({label,href,clientId,scope},p);return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("a",Object.assign({href},p,{children:label}))}exports.MyIdentityLink=MyIdentityLink,exports.default=MyIdentityLink;
|
|
@@ -11,6 +11,7 @@ export type InitialCustomerContext = Partial<{
|
|
|
11
11
|
setResourceTrigger: typeof setResourceTrigger;
|
|
12
12
|
getCustomerOrders: (props: Partial<Parameters<typeof getCustomerOrders>[0]>) => Promise<void>;
|
|
13
13
|
getCustomerSubscriptions: (props: Partial<Parameters<typeof getCustomerSubscriptions>[0]>) => Promise<void>;
|
|
14
|
+
reloadCustomerAddresses: () => Promise<void>;
|
|
14
15
|
} & CustomerState>;
|
|
15
16
|
export declare const defaultCustomerContext: {};
|
|
16
17
|
declare const CustomerContext: import("react").Context<Partial<{
|
|
@@ -24,5 +25,6 @@ declare const CustomerContext: import("react").Context<Partial<{
|
|
|
24
25
|
setResourceTrigger: typeof setResourceTrigger;
|
|
25
26
|
getCustomerOrders: (props: Partial<Parameters<typeof getCustomerOrders>[0]>) => Promise<void>;
|
|
26
27
|
getCustomerSubscriptions: (props: Partial<Parameters<typeof getCustomerSubscriptions>[0]>) => Promise<void>;
|
|
28
|
+
reloadCustomerAddresses: () => Promise<void>;
|
|
27
29
|
} & Partial<import("../reducers/CustomerReducer").CustomerActionPayload>>>;
|
|
28
30
|
export default CustomerContext;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { type InitialCustomerContext } from '../context/CustomerContext';
|
|
1
2
|
import { type setResourceTrigger, type CustomerState } from '../reducers/CustomerReducer';
|
|
2
3
|
type TCustomer = Omit<CustomerState, 'errors' | 'isGuest'> & {
|
|
3
4
|
setResourceTrigger?: typeof setResourceTrigger;
|
|
4
|
-
}
|
|
5
|
+
} & Pick<InitialCustomerContext, 'reloadCustomerAddresses'>;
|
|
5
6
|
interface TReturnCustomer extends Omit<TCustomer, 'errors' | 'isGuest'> {
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useCustomerContainer=void 0;const tslib_1=require("tslib"),CustomerContext_1=tslib_1.__importDefault(require("../context/CustomerContext")),react_1=require("react");function useCustomerContainer(){const ctx=(0,react_1.useContext)(CustomerContext_1.default);if("addresses"in ctx)return{addresses:ctx.addresses,payments:ctx.payments,orders:ctx.orders,subscriptions:ctx.subscriptions,customerEmail:ctx.customerEmail,customers:ctx.customers,setResourceTrigger:ctx.setResourceTrigger};throw new Error("Cannot use `useCustomerContainer` outside of <CustomerContainer/>")}exports.useCustomerContainer=useCustomerContainer,exports.default=useCustomerContainer;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useCustomerContainer=void 0;const tslib_1=require("tslib"),CustomerContext_1=tslib_1.__importDefault(require("../context/CustomerContext")),react_1=require("react");function useCustomerContainer(){const ctx=(0,react_1.useContext)(CustomerContext_1.default);if("addresses"in ctx)return{addresses:ctx.addresses,payments:ctx.payments,orders:ctx.orders,subscriptions:ctx.subscriptions,customerEmail:ctx.customerEmail,customers:ctx.customers,setResourceTrigger:ctx.setResourceTrigger,reloadCustomerAddresses:ctx.reloadCustomerAddresses};throw new Error("Cannot use `useCustomerContainer` outside of <CustomerContainer/>")}exports.useCustomerContainer=useCustomerContainer,exports.default=useCustomerContainer;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.orderInitialState=exports.removeGiftCardOrCouponCode=exports.setGiftCardOrCouponCode=exports.saveAddressToCustomerAddressBook=exports.setOrderErrors=exports.unsetOrderState=exports.addToCart=exports.addResourceToInclude=exports.setOrder=exports.updateOrder=exports.getApiOrder=exports.createOrder=void 0;const tslib_1=require("tslib"),localStorage_1=require("../utils/localStorage"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),getErrors_1=tslib_1.__importStar(require("../utils/getErrors")),organization_1=require("../utils/organization"),events_1=require("../utils/events"),actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"];function createOrder(params){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(params){const{persistKey,state,dispatch,config,orderMetadata:metadata,orderAttributes={},setLocalOrder}=params;if(state?.orderId)return state.orderId;const sdk=config!=null?(0,getSdk_1.default)(config):void 0;try{if(sdk==null)return"";const o=yield sdk?.orders.create(Object.assign({metadata},orderAttributes));return dispatch&&dispatch({type:"setOrderId",payload:{orderId:o?.id}}),persistKey&&setLocalOrder&&setLocalOrder(persistKey,o.id),o.id}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders"});console.error("Create order",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors,dispatch})}}return""})}exports.createOrder=createOrder;const getApiOrder=params=>tslib_1.__awaiter(void 0,void 0,void 0,function*(){const{id,dispatch,config,clearWhenPlaced,persistKey,deleteLocalOrder,state}=params,sdk=config!=null?(0,getSdk_1.default)(config):void 0;try{if(sdk==null)return;const options={};state?.include&&state.include.length>0&&(options.include=state.include);const order=yield sdk.orders.retrieve(id??"",options);return clearWhenPlaced&&order.editable===!1?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders"});console.error("Retrieve order",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors,dispatch});return}});exports.getApiOrder=getApiOrder;function updateOrder(_a){return tslib_1.__awaiter(this,arguments,void 0,function*({id,attributes,dispatch,config,include,state}){const sdk=config!=null?(0,getSdk_1.default)(config):void 0;try{if(sdk==null)return{success:!1};const resource=Object.assign(Object.assign({},attributes),{id});yield sdk.orders.update(resource,{include});const order=yield(0,exports.getApiOrder)({id,config,dispatch,state});return dispatch&&order&&dispatch({type:"setOrder",payload:{order}}),{success:!0,order}}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders"});return dispatch&&(setOrderErrors({errors,dispatch}),dispatch({type:"setErrors",payload:{errors}})),{success:!1,error}}})}exports.updateOrder=updateOrder;const setOrder=(order,dispatch)=>{dispatch&&dispatch({type:"setOrder",payload:{order}})};exports.setOrder=setOrder;function addResourceToInclude({resourcesIncluded=[],dispatch,newResource,newResourceLoaded,resourceIncludedLoaded}){const payload={include:void 0,includeLoaded:void 0};if(newResource){const resources=typeof newResource=="string"?[newResource]:newResource;payload.include=[...new Set([...resourcesIncluded,...resources])],resources.forEach(resource=>{const includeLoaded=Object.assign(Object.assign({},payload.includeLoaded),{[resource]:!0});payload.includeLoaded=includeLoaded})}else delete payload.include;const payloadIncludeLoaded=Object.assign(Object.assign(Object.assign({},resourceIncludedLoaded),newResourceLoaded),payload.includeLoaded&&payload.includeLoaded);payload.includeLoaded=payloadIncludeLoaded,dispatch&&dispatch({type:"setIncludesResource",payload:Object.assign(Object.assign({},payload),{withoutIncludes:!1})})}exports.addResourceToInclude=addResourceToInclude;function addToCart(params){return tslib_1.__awaiter(this,void 0,void 0,function*(){var _a,_b,_c,_d;const{skuCode,bundleCode,quantity,config,dispatch,lineItem,state,errors=[],buyNowMode,checkoutUrl,lineItemOption,openMiniCart=!0}=params;try{if(config){const sdk=(0,getSdk_1.default)(config),id=yield createOrder(params);if(id){const order=sdk.orders.relationship(id),name=lineItem?.name,imageUrl=lineItem?.imageUrl,metadata=lineItem?.metadata,frequency=lineItem?.frequency,externalPrice=lineItem?.externalPrice;if(buyNowMode)if(!((_a=state?.order)===null||_a===void 0)&&_a.line_items)yield Promise.all((_b=state?.order)===null||_b===void 0?void 0:_b.line_items.map(lineItem2=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield sdk.line_items.delete(lineItem2.id)})));else{const{line_items:lineItems}=yield sdk.orders.retrieve(id,{fields:["line_items"],include:["line_items"]});lineItems&&lineItems?.length>0&&(yield Promise.all(lineItems.map(lineItem2=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield sdk.line_items.delete(lineItem2.id)}))))}const attrs={order,sku_code:skuCode,name,image_url:imageUrl,quantity:quantity??1,_update_quantity:!0,bundle_code:bundleCode,metadata,frequency};externalPrice===!0&&(attrs._external_price=externalPrice);const newLineItem=yield sdk.line_items.create(attrs);if(lineItemOption!=null){const{skuOptionId,options,quantity:quantity2}=lineItemOption,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:quantity2??1,options,sku_option:skuOption,line_item:lineItemRel};yield sdk.line_item_options.create(lineItemOptionsAttributes),yield(0,exports.getApiOrder)(Object.assign({id},params))}else yield(0,exports.getApiOrder)(Object.assign(Object.assign({id},params),{state}));if(!(0,isEmpty_1.default)(errors)&&dispatch&&dispatch({type:"setErrors",payload:{errors:[]}}),buyNowMode){const{organization}=(0,organization_1.getOrganizationSlug)((
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.orderInitialState=exports.removeGiftCardOrCouponCode=exports.setGiftCardOrCouponCode=exports.saveAddressToCustomerAddressBook=exports.setOrderErrors=exports.unsetOrderState=exports.addToCart=exports.addResourceToInclude=exports.setOrder=exports.updateOrder=exports.getApiOrder=exports.createOrder=void 0;const tslib_1=require("tslib"),localStorage_1=require("../utils/localStorage"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),getErrors_1=tslib_1.__importStar(require("../utils/getErrors")),organization_1=require("../utils/organization"),events_1=require("../utils/events"),actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"];function createOrder(params){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(params){const{persistKey,state,dispatch,config,orderMetadata:metadata,orderAttributes={},setLocalOrder}=params;if(state?.orderId)return state.orderId;const sdk=config!=null?(0,getSdk_1.default)(config):void 0;try{if(sdk==null)return"";const o=yield sdk?.orders.create(Object.assign({metadata},orderAttributes));return dispatch&&dispatch({type:"setOrderId",payload:{orderId:o?.id}}),persistKey&&setLocalOrder&&setLocalOrder(persistKey,o.id),o.id}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders"});console.error("Create order",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors,dispatch})}}return""})}exports.createOrder=createOrder;const getApiOrder=params=>tslib_1.__awaiter(void 0,void 0,void 0,function*(){const{id,dispatch,config,clearWhenPlaced,persistKey,deleteLocalOrder,state}=params,sdk=config!=null?(0,getSdk_1.default)(config):void 0;try{if(sdk==null)return;const options={};state?.include&&state.include.length>0&&(options.include=state.include);const order=yield sdk.orders.retrieve(id??"",options);return clearWhenPlaced&&order.editable===!1?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders"});console.error("Retrieve order",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors,dispatch});return}});exports.getApiOrder=getApiOrder;function updateOrder(_a){return tslib_1.__awaiter(this,arguments,void 0,function*({id,attributes,dispatch,config,include,state}){const sdk=config!=null?(0,getSdk_1.default)(config):void 0;try{if(sdk==null)return{success:!1};const resource=Object.assign(Object.assign({},attributes),{id});yield sdk.orders.update(resource,{include});const order=yield(0,exports.getApiOrder)({id,config,dispatch,state});return dispatch&&order&&dispatch({type:"setOrder",payload:{order}}),{success:!0,order}}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders"});return dispatch&&(setOrderErrors({errors,dispatch}),dispatch({type:"setErrors",payload:{errors}})),{success:!1,error}}})}exports.updateOrder=updateOrder;const setOrder=(order,dispatch)=>{dispatch&&dispatch({type:"setOrder",payload:{order}})};exports.setOrder=setOrder;function addResourceToInclude({resourcesIncluded=[],dispatch,newResource,newResourceLoaded,resourceIncludedLoaded}){const payload={include:void 0,includeLoaded:void 0};if(newResource){const resources=typeof newResource=="string"?[newResource]:newResource;payload.include=[...new Set([...resourcesIncluded,...resources])],resources.forEach(resource=>{const includeLoaded=Object.assign(Object.assign({},payload.includeLoaded),{[resource]:!0});payload.includeLoaded=includeLoaded})}else delete payload.include;const payloadIncludeLoaded=Object.assign(Object.assign(Object.assign({},resourceIncludedLoaded),newResourceLoaded),payload.includeLoaded&&payload.includeLoaded);payload.includeLoaded=payloadIncludeLoaded,dispatch&&dispatch({type:"setIncludesResource",payload:Object.assign(Object.assign({},payload),{withoutIncludes:!1})})}exports.addResourceToInclude=addResourceToInclude;function addToCart(params){return tslib_1.__awaiter(this,void 0,void 0,function*(){var _a,_b,_c,_d,_e;const{skuCode,bundleCode,quantity,config,dispatch,lineItem,state,errors=[],buyNowMode,checkoutUrl,lineItemOption,openMiniCart=!0}=params;try{if(config){const sdk=(0,getSdk_1.default)(config),id=yield createOrder(params);if(id){const order=sdk.orders.relationship(id),name=lineItem?.name,imageUrl=lineItem?.imageUrl,metadata=lineItem?.metadata,frequency=lineItem?.frequency,externalPrice=lineItem?.externalPrice;if(buyNowMode)if(!((_a=state?.order)===null||_a===void 0)&&_a.line_items)yield Promise.all((_b=state?.order)===null||_b===void 0?void 0:_b.line_items.map(lineItem2=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield sdk.line_items.delete(lineItem2.id)})));else{const{line_items:lineItems}=yield sdk.orders.retrieve(id,{fields:["line_items"],include:["line_items"]});lineItems&&lineItems?.length>0&&(yield Promise.all(lineItems.map(lineItem2=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield sdk.line_items.delete(lineItem2.id)}))))}const attrs={order,sku_code:skuCode,name,image_url:imageUrl,quantity:quantity??1,_update_quantity:(_c=lineItem?._update_quantity)!==null&&_c!==void 0?_c:!0,bundle_code:bundleCode,metadata,frequency};externalPrice===!0&&(attrs._external_price=externalPrice);const newLineItem=yield sdk.line_items.create(attrs);if(lineItemOption!=null){const{skuOptionId,options,quantity:quantity2}=lineItemOption,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:quantity2??1,options,sku_option:skuOption,line_item:lineItemRel};yield sdk.line_item_options.create(lineItemOptionsAttributes),yield(0,exports.getApiOrder)(Object.assign({id},params))}else yield(0,exports.getApiOrder)(Object.assign(Object.assign({id},params),{state}));if(!(0,isEmpty_1.default)(errors)&&dispatch&&dispatch({type:"setErrors",payload:{errors:[]}}),buyNowMode){const{organization}=(0,organization_1.getOrganizationSlug)((_d=config.endpoint)!==null&&_d!==void 0?_d:""),params2=`${id}?accessToken=${(_e=config.accessToken)!==null&&_e!==void 0?_e:""}`,redirectUrl=checkoutUrl?`${checkoutUrl}/${params2}`:`https://${organization}.checkout.commercelayer.app/${params2}`;location.href=redirectUrl}else openMiniCart&&(0,events_1.publish)("open-cart");return{success:!0,orderId:id}}}return{success:!1}}catch(error){const errors2=(0,getErrors_1.default)({error,resource:"orders"});return console.error("Add to cart",errors2),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors2,dispatch}),{success:!1}}})}exports.addToCart=addToCart;const unsetOrderState=dispatch=>{dispatch({type:"setOrderId",payload:{orderId:""}}),dispatch({type:"setOrder",payload:{order:void 0}})};exports.unsetOrderState=unsetOrderState;function setOrderErrors({dispatch,errors=[]}){return dispatch&&dispatch({type:"setErrors",payload:{errors}}),{success:!1}}exports.setOrderErrors=setOrderErrors;const saveAddressToCustomerAddressBook=({type,value,dispatch})=>{const k=`_save_${type}_to_customer_address_book`,v=`${value.toString()}`;(0,localStorage_1.setCustomerOrderParam)(k,v),dispatch&&dispatch({type:"setSaveAddressToCustomerAddressBook",payload:{[k]:v}})};exports.saveAddressToCustomerAddressBook=saveAddressToCustomerAddressBook;function setGiftCardOrCouponCode(_a){return tslib_1.__awaiter(this,arguments,void 0,function*({code,codeType,dispatch,config,order,include,state}){try{if(config&&order&&code&&dispatch){const attributes={[codeType]:code},{success,order:currentOrder,error}=yield updateOrder({id:order.id,attributes,config,include,dispatch,state});if(!success)throw error;return dispatch({type:"setErrors",payload:{errors:[]}}),{success,order:currentOrder}}return{success:!1}}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders",field:codeType});return dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}})}exports.setGiftCardOrCouponCode=setGiftCardOrCouponCode;function removeGiftCardOrCouponCode(_a){return tslib_1.__awaiter(this,arguments,void 0,function*({codeType,dispatch,config,order,include,state}){try{if(config&&order&&dispatch){const attributes={[codeType]:""},orderUpdated=yield updateOrder({id:order.id,attributes,config,include,dispatch,state});return dispatch({type:"setErrors",payload:{errors:[]}}),{success:!0,order:orderUpdated?.order}}return{success:!1}}catch(error){const errors=(0,getErrors_1.default)({error,resource:"orders",field:codeType});return console.error("Remove gift card o coupon code",errors),dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}})}exports.removeGiftCardOrCouponCode=removeGiftCardOrCouponCode,exports.orderInitialState={loading:!0,orderId:"",order:void 0,errors:[],include:void 0,withoutIncludes:!0};const orderReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,actionType);exports.default=orderReducer;
|
|
@@ -6,6 +6,7 @@ type ApplicationTypeProps<T extends ApplicationType = ApplicationType> = T exten
|
|
|
6
6
|
clientId?: string;
|
|
7
7
|
scope?: string;
|
|
8
8
|
returnUrl?: string;
|
|
9
|
+
resetPasswordUrl?: string;
|
|
9
10
|
} : T extends 'identity' ? {
|
|
10
11
|
applicationType: T;
|
|
11
12
|
orderId?: string;
|
|
@@ -13,6 +14,7 @@ type ApplicationTypeProps<T extends ApplicationType = ApplicationType> = T exten
|
|
|
13
14
|
clientId: string;
|
|
14
15
|
scope: string;
|
|
15
16
|
returnUrl: string;
|
|
17
|
+
resetPasswordUrl?: string;
|
|
16
18
|
} : {
|
|
17
19
|
applicationType: Omit<T, 'my-account' | 'identity'>;
|
|
18
20
|
orderId: string;
|
|
@@ -20,6 +22,7 @@ type ApplicationTypeProps<T extends ApplicationType = ApplicationType> = T exten
|
|
|
20
22
|
clientId?: string;
|
|
21
23
|
scope?: string;
|
|
22
24
|
returnUrl?: string;
|
|
25
|
+
resetPasswordUrl?: string;
|
|
23
26
|
};
|
|
24
27
|
interface TArgs {
|
|
25
28
|
accessToken: string;
|
|
@@ -28,5 +31,5 @@ interface TArgs {
|
|
|
28
31
|
customDomain?: string;
|
|
29
32
|
}
|
|
30
33
|
type Props = ApplicationTypeProps & TArgs;
|
|
31
|
-
export declare function getApplicationLink({ orderId, accessToken, slug, domain, applicationType, modeType, clientId, scope, returnUrl, customDomain }: Props): string;
|
|
34
|
+
export declare function getApplicationLink({ orderId, accessToken, slug, domain, applicationType, modeType, clientId, scope, returnUrl, resetPasswordUrl, customDomain }: Props): string;
|
|
32
35
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getApplicationLink=void 0;function getApplicationLink({orderId,accessToken,slug,domain,applicationType,modeType,clientId,scope,returnUrl,customDomain}){var _a;const env=domain==="commercelayer.io"?"":"stg.",t=applicationType==="identity"?modeType==="login"?"":"signup":"",c=clientId?`&clientId=${clientId}`:"",s=scope?`&scope=${scope}`:"",r=returnUrl?`&returnUrl=${returnUrl}`:"",params=applicationType==="identity"?`${c}${s}${r}`:"",domainName=customDomain??`${slug}.${env}commercelayer.app`,application=customDomain?"":`/${applicationType.toString()}`;return`https://${domainName}${application}/${(_a=orderId??t)!==null&&_a!==void 0?_a:""}?accessToken=${accessToken}${params}`}exports.getApplicationLink=getApplicationLink;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getApplicationLink=void 0;function getApplicationLink({orderId,accessToken,slug,domain,applicationType,modeType,clientId,scope,returnUrl,resetPasswordUrl,customDomain}){var _a;const env=domain==="commercelayer.io"?"":"stg.",t=applicationType==="identity"?modeType==="login"?"":"signup":"",c=clientId?`&clientId=${clientId}`:"",s=scope?`&scope=${scope}`:"",r=returnUrl?`&returnUrl=${returnUrl}`:"",p=resetPasswordUrl?`&resetPasswordUrl=${resetPasswordUrl}`:"",params=applicationType==="identity"?`${c}${s}${r}${p}`:"",domainName=customDomain??`${slug}.${env}commercelayer.app`,application=customDomain?"":`/${applicationType.toString()}`;return`https://${domainName}${application}/${(_a=orderId??t)!==null&&_a!==void 0?_a:""}?accessToken=${accessToken}${params}`}exports.getApplicationLink=getApplicationLink;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useReducer,useMemo}from"react";import customerReducer,{customerInitialState,getCustomerAddresses,getCustomerOrders,getCustomerPaymentSources,setCustomerEmail,setCustomerErrors,deleteCustomerAddress,createCustomerAddress,saveCustomerUser,getCustomerPayments,getCustomerSubscriptions,getCustomerInfo,setResourceTrigger}from"../../reducers/CustomerReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import CustomerContext from"../../context/CustomerContext";import{isGuestToken}from"../../utils/isGuestToken";export function CustomerContainer(props){const{children,isGuest}=props,[state,dispatch]=useReducer(customerReducer,customerInitialState),{order,addResourceToInclude,include,updateOrder,includeLoaded,withoutIncludes}=useContext(OrderContext),config=useContext(CommerceLayerContext);useEffect(()=>{if(config.accessToken){if(isGuest??isGuestToken(config.accessToken))return;include?.includes("available_customer_payment_sources.payment_source")?includeLoaded?.["available_customer_payment_sources.payment_source"]||addResourceToInclude({newResourceLoaded:{"available_customer_payment_sources.payment_source":!0,"available_customer_payment_sources.payment_method":!0}}):addResourceToInclude({newResource:["available_customer_payment_sources.payment_source","available_customer_payment_sources.payment_method"]})}},[config.accessToken,include?.length,Object.keys(includeLoaded??{}).length]),useEffect(()=>{if(config.accessToken){if(isGuest??isGuestToken(config.accessToken))return;if(state.customers==null&&getCustomerInfo({config,dispatch}),state.addresses==null&&getCustomerAddresses({config,dispatch,isOrderAvailable:withoutIncludes!=null}),order?.available_customer_payment_sources&&getCustomerPaymentSources({dispatch,order}),config.accessToken&&order==null&&include==null&&includeLoaded==null&&withoutIncludes===void 0){async function getCustomerData(){await getCustomerOrders({config,dispatch}),await getCustomerSubscriptions({config,dispatch}),await getCustomerPayments({config,dispatch})}getCustomerData()}}},[config.accessToken,order?.payment_source!=null,isGuest]);const contextValue=useMemo(()=>({isGuest,...state,saveCustomerUser:async customerEmail=>{await saveCustomerUser({config,customerEmail,dispatch,updateOrder,order})},setCustomerErrors:errors=>{setCustomerErrors(errors,dispatch)},setCustomerEmail:customerEmail=>{setCustomerEmail(customerEmail,dispatch)},getCustomerPaymentSources:()=>{getCustomerPaymentSources({dispatch,order})},deleteCustomerAddress:async({customerAddressId})=>{await deleteCustomerAddress({customerAddressId,dispatch,config,addresses:state.addresses})},setResourceTrigger:async props2=>await setResourceTrigger({...props2,dispatch,config}),createCustomerAddress:async address=>{await createCustomerAddress({address,config,dispatch,state})},getCustomerOrders:async({pageNumber,pageSize})=>{await getCustomerOrders({config,dispatch,pageNumber,pageSize})},getCustomerSubscriptions:async({pageNumber,pageSize,id})=>{await getCustomerSubscriptions({config,dispatch,pageNumber,pageSize,id})}}),[state,isGuest]);return _jsx(CustomerContext.Provider,{value:contextValue,children})}export default CustomerContainer;
|
|
2
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useReducer,useMemo}from"react";import customerReducer,{customerInitialState,getCustomerAddresses,getCustomerOrders,getCustomerPaymentSources,setCustomerEmail,setCustomerErrors,deleteCustomerAddress,createCustomerAddress,saveCustomerUser,getCustomerPayments,getCustomerSubscriptions,getCustomerInfo,setResourceTrigger}from"../../reducers/CustomerReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import CustomerContext from"../../context/CustomerContext";import{isGuestToken}from"../../utils/isGuestToken";export function CustomerContainer(props){const{children,isGuest}=props,[state,dispatch]=useReducer(customerReducer,customerInitialState),{order,addResourceToInclude,include,updateOrder,includeLoaded,withoutIncludes}=useContext(OrderContext),config=useContext(CommerceLayerContext);useEffect(()=>{if(config.accessToken){if(isGuest??isGuestToken(config.accessToken))return;include?.includes("available_customer_payment_sources.payment_source")?includeLoaded?.["available_customer_payment_sources.payment_source"]||addResourceToInclude({newResourceLoaded:{"available_customer_payment_sources.payment_source":!0,"available_customer_payment_sources.payment_method":!0}}):addResourceToInclude({newResource:["available_customer_payment_sources.payment_source","available_customer_payment_sources.payment_method"]})}},[config.accessToken,include?.length,Object.keys(includeLoaded??{}).length]),useEffect(()=>{if(config.accessToken){if(isGuest??isGuestToken(config.accessToken))return;if(state.customers==null&&getCustomerInfo({config,dispatch}),state.addresses==null&&getCustomerAddresses({config,dispatch,isOrderAvailable:withoutIncludes!=null}),order?.available_customer_payment_sources&&getCustomerPaymentSources({dispatch,order}),config.accessToken&&order==null&&include==null&&includeLoaded==null&&withoutIncludes===void 0){async function getCustomerData(){await getCustomerOrders({config,dispatch}),await getCustomerSubscriptions({config,dispatch}),await getCustomerPayments({config,dispatch})}getCustomerData()}}},[config.accessToken,order?.payment_source!=null,isGuest]);const contextValue=useMemo(()=>({isGuest,...state,saveCustomerUser:async customerEmail=>{await saveCustomerUser({config,customerEmail,dispatch,updateOrder,order})},setCustomerErrors:errors=>{setCustomerErrors(errors,dispatch)},setCustomerEmail:customerEmail=>{setCustomerEmail(customerEmail,dispatch)},getCustomerPaymentSources:()=>{getCustomerPaymentSources({dispatch,order})},deleteCustomerAddress:async({customerAddressId})=>{await deleteCustomerAddress({customerAddressId,dispatch,config,addresses:state.addresses})},setResourceTrigger:async props2=>await setResourceTrigger({...props2,dispatch,config}),createCustomerAddress:async address=>{await createCustomerAddress({address,config,dispatch,state})},getCustomerOrders:async({pageNumber,pageSize})=>{await getCustomerOrders({config,dispatch,pageNumber,pageSize})},getCustomerSubscriptions:async({pageNumber,pageSize,id})=>{await getCustomerSubscriptions({config,dispatch,pageNumber,pageSize,id})},reloadCustomerAddresses:async()=>{await getCustomerAddresses({config,dispatch,isOrderAvailable:withoutIncludes!=null})}}),[state,isGuest]);return _jsx(CustomerContext.Provider,{value:contextValue,children})}export default CustomerContainer;
|
|
@@ -34,6 +34,10 @@ interface Props extends Omit<JSX.IntrinsicElements['a'], 'children'> {
|
|
|
34
34
|
* The domain of your forked application
|
|
35
35
|
*/
|
|
36
36
|
customDomain?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The reset password url
|
|
39
|
+
*/
|
|
40
|
+
resetPasswordUrl?: string;
|
|
37
41
|
}
|
|
38
42
|
/**
|
|
39
43
|
* This component generates a link to the hosted mfe-identity application.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import Parent from"../utils/Parent";import CommerceLayerContext from"../../context/CommerceLayerContext";import{getApplicationLink}from"../../utils/getApplicationLink";import{getDomain}from"../../utils/getDomain";import{getOrganizationConfig}from"../../utils/organization";export function MyIdentityLink(props){const{label,children,type,clientId,scope,returnUrl,customDomain,...p}=props,{accessToken,endpoint}=useContext(CommerceLayerContext),[href,setHref]=useState(void 0);if(accessToken==null||endpoint==null)throw new Error("Cannot use `MyIdentityLink` outside of `CommerceLayer`");const{domain,slug}=getDomain(endpoint);useEffect(()=>(getOrganizationConfig({accessToken,endpoint,params:{accessToken}}).then(config=>{if(config?.links?.identity)setHref(config.links.identity);else{const link=getApplicationLink({slug,accessToken,applicationType:"identity",domain,modeType:type,clientId,scope,returnUrl:returnUrl??window.location.href,customDomain});setHref(link)}}),()=>{setHref(void 0)}),[]);const parentProps={label,href,clientId,scope,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("a",{href,...p,children:label})}export default MyIdentityLink;
|
|
2
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import Parent from"../utils/Parent";import CommerceLayerContext from"../../context/CommerceLayerContext";import{getApplicationLink}from"../../utils/getApplicationLink";import{getDomain}from"../../utils/getDomain";import{getOrganizationConfig}from"../../utils/organization";export function MyIdentityLink(props){const{label,children,type,clientId,scope,returnUrl,customDomain,resetPasswordUrl,...p}=props,{accessToken,endpoint}=useContext(CommerceLayerContext),[href,setHref]=useState(void 0);if(accessToken==null||endpoint==null)throw new Error("Cannot use `MyIdentityLink` outside of `CommerceLayer`");const{domain,slug}=getDomain(endpoint);useEffect(()=>(getOrganizationConfig({accessToken,endpoint,params:{accessToken}}).then(config=>{if(config?.links?.identity)setHref(config.links.identity);else{const link=getApplicationLink({slug,accessToken,applicationType:"identity",domain,modeType:type,clientId,scope,returnUrl:returnUrl??window.location.href,resetPasswordUrl,customDomain});setHref(link)}}),()=>{setHref(void 0)}),[]);const parentProps={label,href,clientId,scope,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("a",{href,...p,children:label})}export default MyIdentityLink;
|
|
@@ -11,6 +11,7 @@ export type InitialCustomerContext = Partial<{
|
|
|
11
11
|
setResourceTrigger: typeof setResourceTrigger;
|
|
12
12
|
getCustomerOrders: (props: Partial<Parameters<typeof getCustomerOrders>[0]>) => Promise<void>;
|
|
13
13
|
getCustomerSubscriptions: (props: Partial<Parameters<typeof getCustomerSubscriptions>[0]>) => Promise<void>;
|
|
14
|
+
reloadCustomerAddresses: () => Promise<void>;
|
|
14
15
|
} & CustomerState>;
|
|
15
16
|
export declare const defaultCustomerContext: {};
|
|
16
17
|
declare const CustomerContext: import("react").Context<Partial<{
|
|
@@ -24,5 +25,6 @@ declare const CustomerContext: import("react").Context<Partial<{
|
|
|
24
25
|
setResourceTrigger: typeof setResourceTrigger;
|
|
25
26
|
getCustomerOrders: (props: Partial<Parameters<typeof getCustomerOrders>[0]>) => Promise<void>;
|
|
26
27
|
getCustomerSubscriptions: (props: Partial<Parameters<typeof getCustomerSubscriptions>[0]>) => Promise<void>;
|
|
28
|
+
reloadCustomerAddresses: () => Promise<void>;
|
|
27
29
|
} & Partial<import("../reducers/CustomerReducer").CustomerActionPayload>>>;
|
|
28
30
|
export default CustomerContext;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { type InitialCustomerContext } from '../context/CustomerContext';
|
|
1
2
|
import { type setResourceTrigger, type CustomerState } from '../reducers/CustomerReducer';
|
|
2
3
|
type TCustomer = Omit<CustomerState, 'errors' | 'isGuest'> & {
|
|
3
4
|
setResourceTrigger?: typeof setResourceTrigger;
|
|
4
|
-
}
|
|
5
|
+
} & Pick<InitialCustomerContext, 'reloadCustomerAddresses'>;
|
|
5
6
|
interface TReturnCustomer extends Omit<TCustomer, 'errors' | 'isGuest'> {
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import CustomerContext from"../context/CustomerContext";import{useContext}from"react";export function useCustomerContainer(){const ctx=useContext(CustomerContext);if("addresses"in ctx)return{addresses:ctx.addresses,payments:ctx.payments,orders:ctx.orders,subscriptions:ctx.subscriptions,customerEmail:ctx.customerEmail,customers:ctx.customers,setResourceTrigger:ctx.setResourceTrigger};throw new Error("Cannot use `useCustomerContainer` outside of <CustomerContainer/>")}export default useCustomerContainer;
|
|
2
|
+
import CustomerContext from"../context/CustomerContext";import{useContext}from"react";export function useCustomerContainer(){const ctx=useContext(CustomerContext);if("addresses"in ctx)return{addresses:ctx.addresses,payments:ctx.payments,orders:ctx.orders,subscriptions:ctx.subscriptions,customerEmail:ctx.customerEmail,customers:ctx.customers,setResourceTrigger:ctx.setResourceTrigger,reloadCustomerAddresses:ctx.reloadCustomerAddresses};throw new Error("Cannot use `useCustomerContainer` outside of <CustomerContainer/>")}export default useCustomerContainer;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{setCustomerOrderParam}from"../utils/localStorage";import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import getSdk from"../utils/getSdk";import getErrors,{setErrors}from"../utils/getErrors";import{getOrganizationSlug}from"../utils/organization";import{publish}from"../utils/events";const actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"];export async function createOrder(params){if(params){const{persistKey,state,dispatch,config,orderMetadata:metadata,orderAttributes={},setLocalOrder}=params;if(state?.orderId)return state.orderId;const sdk=config!=null?getSdk(config):void 0;try{if(sdk==null)return"";const o=await sdk?.orders.create({metadata,...orderAttributes});return dispatch&&dispatch({type:"setOrderId",payload:{orderId:o?.id}}),persistKey&&setLocalOrder&&setLocalOrder(persistKey,o.id),o.id}catch(error){const errors=getErrors({error,resource:"orders"});console.error("Create order",errors),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors,dispatch})}}return""}export const getApiOrder=async params=>{const{id,dispatch,config,clearWhenPlaced,persistKey,deleteLocalOrder,state}=params,sdk=config!=null?getSdk(config):void 0;try{if(sdk==null)return;const options={};state?.include&&state.include.length>0&&(options.include=state.include);const order=await sdk.orders.retrieve(id??"",options);return clearWhenPlaced&&order.editable===!1?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=getErrors({error,resource:"orders"});console.error("Retrieve order",errors),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors,dispatch});return}};export async function updateOrder({id,attributes,dispatch,config,include,state}){const sdk=config!=null?getSdk(config):void 0;try{if(sdk==null)return{success:!1};const resource={...attributes,id};await sdk.orders.update(resource,{include});const order=await getApiOrder({id,config,dispatch,state});return dispatch&&order&&dispatch({type:"setOrder",payload:{order}}),{success:!0,order}}catch(error){const errors=getErrors({error,resource:"orders"});return dispatch&&(setOrderErrors({errors,dispatch}),dispatch({type:"setErrors",payload:{errors}})),{success:!1,error}}}export const setOrder=(order,dispatch)=>{dispatch&&dispatch({type:"setOrder",payload:{order}})};export function addResourceToInclude({resourcesIncluded=[],dispatch,newResource,newResourceLoaded,resourceIncludedLoaded}){const payload={include:void 0,includeLoaded:void 0};if(newResource){const resources=typeof newResource=="string"?[newResource]:newResource;payload.include=[...new Set([...resourcesIncluded,...resources])],resources.forEach(resource=>{const includeLoaded={...payload.includeLoaded,[resource]:!0};payload.includeLoaded=includeLoaded})}else delete payload.include;const payloadIncludeLoaded={...resourceIncludedLoaded,...newResourceLoaded,...payload.includeLoaded&&payload.includeLoaded};payload.includeLoaded=payloadIncludeLoaded,dispatch&&dispatch({type:"setIncludesResource",payload:{...payload,withoutIncludes:!1}})}export async function addToCart(params){const{skuCode,bundleCode,quantity,config,dispatch,lineItem,state,errors=[],buyNowMode,checkoutUrl,lineItemOption,openMiniCart=!0}=params;try{if(config){const sdk=getSdk(config),id=await createOrder(params);if(id){const order=sdk.orders.relationship(id),name=lineItem?.name,imageUrl=lineItem?.imageUrl,metadata=lineItem?.metadata,frequency=lineItem?.frequency,externalPrice=lineItem?.externalPrice;if(buyNowMode)if(state?.order?.line_items)await Promise.all(state?.order?.line_items.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}));else{const{line_items:lineItems}=await sdk.orders.retrieve(id,{fields:["line_items"],include:["line_items"]});lineItems&&lineItems?.length>0&&await Promise.all(lineItems.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}))}const attrs={order,sku_code:skuCode,name,image_url:imageUrl,quantity:quantity??1,_update_quantity
|
|
2
|
+
import{setCustomerOrderParam}from"../utils/localStorage";import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import getSdk from"../utils/getSdk";import getErrors,{setErrors}from"../utils/getErrors";import{getOrganizationSlug}from"../utils/organization";import{publish}from"../utils/events";const actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"];export async function createOrder(params){if(params){const{persistKey,state,dispatch,config,orderMetadata:metadata,orderAttributes={},setLocalOrder}=params;if(state?.orderId)return state.orderId;const sdk=config!=null?getSdk(config):void 0;try{if(sdk==null)return"";const o=await sdk?.orders.create({metadata,...orderAttributes});return dispatch&&dispatch({type:"setOrderId",payload:{orderId:o?.id}}),persistKey&&setLocalOrder&&setLocalOrder(persistKey,o.id),o.id}catch(error){const errors=getErrors({error,resource:"orders"});console.error("Create order",errors),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors,dispatch})}}return""}export const getApiOrder=async params=>{const{id,dispatch,config,clearWhenPlaced,persistKey,deleteLocalOrder,state}=params,sdk=config!=null?getSdk(config):void 0;try{if(sdk==null)return;const options={};state?.include&&state.include.length>0&&(options.include=state.include);const order=await sdk.orders.retrieve(id??"",options);return clearWhenPlaced&&order.editable===!1?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=getErrors({error,resource:"orders"});console.error("Retrieve order",errors),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors,dispatch});return}};export async function updateOrder({id,attributes,dispatch,config,include,state}){const sdk=config!=null?getSdk(config):void 0;try{if(sdk==null)return{success:!1};const resource={...attributes,id};await sdk.orders.update(resource,{include});const order=await getApiOrder({id,config,dispatch,state});return dispatch&&order&&dispatch({type:"setOrder",payload:{order}}),{success:!0,order}}catch(error){const errors=getErrors({error,resource:"orders"});return dispatch&&(setOrderErrors({errors,dispatch}),dispatch({type:"setErrors",payload:{errors}})),{success:!1,error}}}export const setOrder=(order,dispatch)=>{dispatch&&dispatch({type:"setOrder",payload:{order}})};export function addResourceToInclude({resourcesIncluded=[],dispatch,newResource,newResourceLoaded,resourceIncludedLoaded}){const payload={include:void 0,includeLoaded:void 0};if(newResource){const resources=typeof newResource=="string"?[newResource]:newResource;payload.include=[...new Set([...resourcesIncluded,...resources])],resources.forEach(resource=>{const includeLoaded={...payload.includeLoaded,[resource]:!0};payload.includeLoaded=includeLoaded})}else delete payload.include;const payloadIncludeLoaded={...resourceIncludedLoaded,...newResourceLoaded,...payload.includeLoaded&&payload.includeLoaded};payload.includeLoaded=payloadIncludeLoaded,dispatch&&dispatch({type:"setIncludesResource",payload:{...payload,withoutIncludes:!1}})}export async function addToCart(params){const{skuCode,bundleCode,quantity,config,dispatch,lineItem,state,errors=[],buyNowMode,checkoutUrl,lineItemOption,openMiniCart=!0}=params;try{if(config){const sdk=getSdk(config),id=await createOrder(params);if(id){const order=sdk.orders.relationship(id),name=lineItem?.name,imageUrl=lineItem?.imageUrl,metadata=lineItem?.metadata,frequency=lineItem?.frequency,externalPrice=lineItem?.externalPrice;if(buyNowMode)if(state?.order?.line_items)await Promise.all(state?.order?.line_items.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}));else{const{line_items:lineItems}=await sdk.orders.retrieve(id,{fields:["line_items"],include:["line_items"]});lineItems&&lineItems?.length>0&&await Promise.all(lineItems.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}))}const attrs={order,sku_code:skuCode,name,image_url:imageUrl,quantity:quantity??1,_update_quantity:lineItem?._update_quantity??!0,bundle_code:bundleCode,metadata,frequency};externalPrice===!0&&(attrs._external_price=externalPrice);const newLineItem=await sdk.line_items.create(attrs);if(lineItemOption!=null){const{skuOptionId,options,quantity:quantity2}=lineItemOption,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:quantity2??1,options,sku_option:skuOption,line_item:lineItemRel};await sdk.line_item_options.create(lineItemOptionsAttributes),await getApiOrder({id,...params})}else await getApiOrder({id,...params,state});if(!isEmpty(errors)&&dispatch&&dispatch({type:"setErrors",payload:{errors:[]}}),buyNowMode){const{organization}=getOrganizationSlug(config.endpoint??""),params2=`${id}?accessToken=${config.accessToken??""}`,redirectUrl=checkoutUrl?`${checkoutUrl}/${params2}`:`https://${organization}.checkout.commercelayer.app/${params2}`;location.href=redirectUrl}else openMiniCart&&publish("open-cart");return{success:!0,orderId:id}}}return{success:!1}}catch(error){const errors2=getErrors({error,resource:"orders"});return console.error("Add to cart",errors2),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors2,dispatch}),{success:!1}}}export const unsetOrderState=dispatch=>{dispatch({type:"setOrderId",payload:{orderId:""}}),dispatch({type:"setOrder",payload:{order:void 0}})};export function setOrderErrors({dispatch,errors=[]}){return dispatch&&dispatch({type:"setErrors",payload:{errors}}),{success:!1}}export const saveAddressToCustomerAddressBook=({type,value,dispatch})=>{const k=`_save_${type}_to_customer_address_book`,v=`${value.toString()}`;setCustomerOrderParam(k,v),dispatch&&dispatch({type:"setSaveAddressToCustomerAddressBook",payload:{[k]:v}})};export async function setGiftCardOrCouponCode({code,codeType,dispatch,config,order,include,state}){try{if(config&&order&&code&&dispatch){const attributes={[codeType]:code},{success,order:currentOrder,error}=await updateOrder({id:order.id,attributes,config,include,dispatch,state});if(!success)throw error;return dispatch({type:"setErrors",payload:{errors:[]}}),{success,order:currentOrder}}return{success:!1}}catch(error){const errors=getErrors({error,resource:"orders",field:codeType});return dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}}export async function removeGiftCardOrCouponCode({codeType,dispatch,config,order,include,state}){try{if(config&&order&&dispatch){const attributes={[codeType]:""},orderUpdated=await updateOrder({id:order.id,attributes,config,include,dispatch,state});return dispatch({type:"setErrors",payload:{errors:[]}}),{success:!0,order:orderUpdated?.order}}return{success:!1}}catch(error){const errors=getErrors({error,resource:"orders",field:codeType});return console.error("Remove gift card o coupon code",errors),dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}}export const orderInitialState={loading:!0,orderId:"",order:void 0,errors:[],include:void 0,withoutIncludes:!0};const orderReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default orderReducer;
|
|
@@ -6,6 +6,7 @@ type ApplicationTypeProps<T extends ApplicationType = ApplicationType> = T exten
|
|
|
6
6
|
clientId?: string;
|
|
7
7
|
scope?: string;
|
|
8
8
|
returnUrl?: string;
|
|
9
|
+
resetPasswordUrl?: string;
|
|
9
10
|
} : T extends 'identity' ? {
|
|
10
11
|
applicationType: T;
|
|
11
12
|
orderId?: string;
|
|
@@ -13,6 +14,7 @@ type ApplicationTypeProps<T extends ApplicationType = ApplicationType> = T exten
|
|
|
13
14
|
clientId: string;
|
|
14
15
|
scope: string;
|
|
15
16
|
returnUrl: string;
|
|
17
|
+
resetPasswordUrl?: string;
|
|
16
18
|
} : {
|
|
17
19
|
applicationType: Omit<T, 'my-account' | 'identity'>;
|
|
18
20
|
orderId: string;
|
|
@@ -20,6 +22,7 @@ type ApplicationTypeProps<T extends ApplicationType = ApplicationType> = T exten
|
|
|
20
22
|
clientId?: string;
|
|
21
23
|
scope?: string;
|
|
22
24
|
returnUrl?: string;
|
|
25
|
+
resetPasswordUrl?: string;
|
|
23
26
|
};
|
|
24
27
|
interface TArgs {
|
|
25
28
|
accessToken: string;
|
|
@@ -28,5 +31,5 @@ interface TArgs {
|
|
|
28
31
|
customDomain?: string;
|
|
29
32
|
}
|
|
30
33
|
type Props = ApplicationTypeProps & TArgs;
|
|
31
|
-
export declare function getApplicationLink({ orderId, accessToken, slug, domain, applicationType, modeType, clientId, scope, returnUrl, customDomain }: Props): string;
|
|
34
|
+
export declare function getApplicationLink({ orderId, accessToken, slug, domain, applicationType, modeType, clientId, scope, returnUrl, resetPasswordUrl, customDomain }: Props): string;
|
|
32
35
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export function getApplicationLink({orderId,accessToken,slug,domain,applicationType,modeType,clientId,scope,returnUrl,customDomain}){const env=domain==="commercelayer.io"?"":"stg.",t=applicationType==="identity"?modeType==="login"?"":"signup":"",c=clientId?`&clientId=${clientId}`:"",s=scope?`&scope=${scope}`:"",r=returnUrl?`&returnUrl=${returnUrl}`:"",params=applicationType==="identity"?`${c}${s}${r}`:"",domainName=customDomain??`${slug}.${env}commercelayer.app`,application=customDomain?"":`/${applicationType.toString()}`;return`https://${domainName}${application}/${orderId??t??""}?accessToken=${accessToken}${params}`}
|
|
2
|
+
export function getApplicationLink({orderId,accessToken,slug,domain,applicationType,modeType,clientId,scope,returnUrl,resetPasswordUrl,customDomain}){const env=domain==="commercelayer.io"?"":"stg.",t=applicationType==="identity"?modeType==="login"?"":"signup":"",c=clientId?`&clientId=${clientId}`:"",s=scope?`&scope=${scope}`:"",r=returnUrl?`&returnUrl=${returnUrl}`:"",p=resetPasswordUrl?`&resetPasswordUrl=${resetPasswordUrl}`:"",params=applicationType==="identity"?`${c}${s}${r}${p}`:"",domainName=customDomain??`${slug}.${env}commercelayer.app`,application=customDomain?"":`/${applicationType.toString()}`;return`https://${domainName}${application}/${orderId??t??""}?accessToken=${accessToken}${params}`}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercelayer/react-components",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.14.0",
|
|
4
4
|
"description": "The Official Commerce Layer React Components",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -165,47 +165,47 @@
|
|
|
165
165
|
},
|
|
166
166
|
"homepage": "https://github.com/commercelayer/commercelayer-react-components#readme",
|
|
167
167
|
"dependencies": {
|
|
168
|
-
"@adyen/adyen-web": "^5.
|
|
169
|
-
"@commercelayer/organization-config": "^1.4.
|
|
170
|
-
"@commercelayer/sdk": "6.0
|
|
171
|
-
"@stripe/react-stripe-js": "^2.
|
|
172
|
-
"@stripe/stripe-js": "^
|
|
173
|
-
"@tanstack/react-table": "^8.
|
|
168
|
+
"@adyen/adyen-web": "^5.66.1",
|
|
169
|
+
"@commercelayer/organization-config": "^1.4.6",
|
|
170
|
+
"@commercelayer/sdk": "6.9.0",
|
|
171
|
+
"@stripe/react-stripe-js": "^2.7.1",
|
|
172
|
+
"@stripe/stripe-js": "^4.0.0",
|
|
173
|
+
"@tanstack/react-table": "^8.17.3",
|
|
174
174
|
"@types/iframe-resizer": "^3.5.13",
|
|
175
|
-
"axios": "^1.
|
|
176
|
-
"braintree-web": "^3.
|
|
177
|
-
"frames-react": "^1.1.
|
|
178
|
-
"iframe-resizer": "^4.
|
|
175
|
+
"axios": "^1.7.2",
|
|
176
|
+
"braintree-web": "^3.102.0",
|
|
177
|
+
"frames-react": "^1.1.1",
|
|
178
|
+
"iframe-resizer": "^4.4.2",
|
|
179
179
|
"jwt-decode": "^4.0.0",
|
|
180
180
|
"lodash": "^4.17.21",
|
|
181
181
|
"rapid-form": "^2.1.0"
|
|
182
182
|
},
|
|
183
183
|
"devDependencies": {
|
|
184
|
-
"@commercelayer/js-auth": "^6.2.
|
|
184
|
+
"@commercelayer/js-auth": "^6.2.2",
|
|
185
185
|
"@faker-js/faker": "^8.4.0",
|
|
186
|
-
"@playwright/test": "^1.
|
|
186
|
+
"@playwright/test": "^1.44.1",
|
|
187
187
|
"@testing-library/dom": "^10.1.0",
|
|
188
|
-
"@testing-library/react": "^
|
|
188
|
+
"@testing-library/react": "^16.0.0",
|
|
189
189
|
"@types/braintree-web": "^3.96.10",
|
|
190
|
-
"@types/lodash": "^4.17.
|
|
191
|
-
"@types/node": "^20.
|
|
190
|
+
"@types/lodash": "^4.17.5",
|
|
191
|
+
"@types/node": "^20.14.6",
|
|
192
192
|
"@types/prop-types": "^15.7.12",
|
|
193
|
-
"@types/react": "^18.
|
|
193
|
+
"@types/react": "^18.3.3",
|
|
194
194
|
"@types/react-test-renderer": "^18.0.7",
|
|
195
195
|
"@types/react-window": "^1.8.8",
|
|
196
|
-
"@vitejs/plugin-react": "^4.
|
|
196
|
+
"@vitejs/plugin-react": "^4.3.1",
|
|
197
197
|
"@vitest/coverage-v8": "^1.6.0",
|
|
198
|
-
"eslint": "
|
|
199
|
-
"jsdom": "^24.
|
|
198
|
+
"eslint": "~9.5.0",
|
|
199
|
+
"jsdom": "^24.1.0",
|
|
200
200
|
"minimize-js": "^1.4.0",
|
|
201
|
-
"msw": "^2.
|
|
201
|
+
"msw": "^2.3.1",
|
|
202
202
|
"react": "^18.2.0",
|
|
203
203
|
"react-dom": "^18.2.0",
|
|
204
204
|
"react-test-renderer": "^18.2.0",
|
|
205
205
|
"tsc-alias": "^1.8.8",
|
|
206
|
-
"tslib": "^2.6.
|
|
206
|
+
"tslib": "^2.6.3",
|
|
207
207
|
"typescript": "^5.4.4",
|
|
208
|
-
"vite": "^5.
|
|
208
|
+
"vite": "^5.3.1",
|
|
209
209
|
"vite-tsconfig-paths": "^4.3.2",
|
|
210
210
|
"vitest": "^1.4.0"
|
|
211
211
|
},
|