@commercelayer/react-components 4.6.0 → 4.7.1-beta.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/line_items/LineItemQuantity.d.ts +2 -0
- package/lib/cjs/components/line_items/LineItemQuantity.js +1 -1
- package/lib/cjs/components/line_items/LineItemRemoveLink.d.ts +2 -0
- package/lib/cjs/components/line_items/LineItemRemoveLink.js +1 -1
- package/lib/cjs/components/orders/OrderListRow.js +1 -1
- package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.js +1 -1
- package/lib/cjs/utils/getApplicationLink.js +1 -1
- package/lib/esm/components/line_items/LineItemQuantity.d.ts +2 -0
- package/lib/esm/components/line_items/LineItemQuantity.js +1 -1
- package/lib/esm/components/line_items/LineItemRemoveLink.d.ts +2 -0
- package/lib/esm/components/line_items/LineItemRemoveLink.js +1 -1
- package/lib/esm/components/orders/OrderListRow.js +1 -1
- package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.js +1 -1
- package/lib/esm/utils/getApplicationLink.js +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { type ChildrenFunction } from '../../typings/index';
|
|
3
|
+
import { type LineItem } from '@commercelayer/sdk';
|
|
3
4
|
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
4
5
|
quantity: number;
|
|
5
6
|
handleChange: (event: React.MouseEvent<HTMLSelectElement>) => void;
|
|
7
|
+
lineItem?: LineItem;
|
|
6
8
|
}
|
|
7
9
|
type Props = {
|
|
8
10
|
children?: ChildrenFunction<ChildrenProps>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LineItemQuantity=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),LineItemChildrenContext_1=tslib_1.__importDefault(require("../../context/LineItemChildrenContext")),LineItemContext_1=tslib_1.__importDefault(require("../../context/LineItemContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent"));function LineItemQuantity(props){var _a;const{max=50,readonly=!1}=props,p=tslib_1.__rest(props,["max","readonly"]),{lineItem}=(0,react_1.useContext)(LineItemChildrenContext_1.default),{updateLineItem}=(0,react_1.useContext)(LineItemContext_1.default),options=[];for(let i=1;i<=max;i++)options.push((0,jsx_runtime_1.jsx)("option",{value:`${i}`,children:i},i));const handleChange=e=>{const quantity2=Number(e.target.value);updateLineItem&&lineItem&&updateLineItem(lineItem.id,quantity2)},quantity=lineItem?.quantity,parentProps=Object.assign({handleChange,quantity},props);return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children:props.children})):readonly?(0,jsx_runtime_1.jsx)("span",Object.assign({},p,{children:quantity})):(0,jsx_runtime_1.jsx)("select",Object.assign({"data-testid":lineItem?.sku_code,title:(_a=lineItem?.name)!==null&&_a!==void 0?_a:"",value:quantity,onChange:handleChange},p,{children:options}))}exports.LineItemQuantity=LineItemQuantity,exports.default=LineItemQuantity;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LineItemQuantity=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),LineItemChildrenContext_1=tslib_1.__importDefault(require("../../context/LineItemChildrenContext")),LineItemContext_1=tslib_1.__importDefault(require("../../context/LineItemContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent"));function LineItemQuantity(props){var _a;const{max=50,readonly=!1}=props,p=tslib_1.__rest(props,["max","readonly"]),{lineItem}=(0,react_1.useContext)(LineItemChildrenContext_1.default),{updateLineItem}=(0,react_1.useContext)(LineItemContext_1.default),options=[];for(let i=1;i<=max;i++)options.push((0,jsx_runtime_1.jsx)("option",{value:`${i}`,children:i},i));const handleChange=e=>{const quantity2=Number(e.target.value);updateLineItem&&lineItem&&updateLineItem(lineItem.id,quantity2)},quantity=lineItem?.quantity,parentProps=Object.assign({handleChange,quantity,lineItem},props);return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children:props.children})):readonly?(0,jsx_runtime_1.jsx)("span",Object.assign({},p,{children:quantity})):(0,jsx_runtime_1.jsx)("select",Object.assign({"data-testid":lineItem?.sku_code,title:(_a=lineItem?.name)!==null&&_a!==void 0?_a:"",value:quantity,onChange:handleChange},p,{children:options}))}exports.LineItemQuantity=LineItemQuantity,exports.default=LineItemQuantity;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type PropsWithoutRef } from 'react';
|
|
2
2
|
import { type ChildrenFunction } from '../../typings/index';
|
|
3
|
+
import { type LineItem } from '@commercelayer/sdk';
|
|
3
4
|
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
4
5
|
handleRemove: (event: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
5
6
|
label?: string;
|
|
7
|
+
lineItem?: LineItem;
|
|
6
8
|
}
|
|
7
9
|
interface Props extends PropsWithoutRef<Omit<JSX.IntrinsicElements['a'], 'children'>> {
|
|
8
10
|
children?: ChildrenFunction<ChildrenProps>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LineItemRemoveLink=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),LineItemChildrenContext_1=tslib_1.__importDefault(require("../../context/LineItemChildrenContext")),LineItemContext_1=tslib_1.__importDefault(require("../../context/LineItemContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext"));function LineItemRemoveLink(props){var _a;const{label="Remove",onClick}=props,{lineItem}=(0,useCustomContext_1.default)({context:LineItemChildrenContext_1.default,contextComponentName:"LineItem",currentComponentName:"LineItemRemoveLink",key:"lineItem"}),{deleteLineItem}=(0,react_1.useContext)(LineItemContext_1.default),handleRemove=e=>{e.preventDefault(),deleteLineItem!=null&&lineItem!=null&&deleteLineItem(lineItem.id),onClick?.(e)},parentProps=Object.assign({handleRemove},props);return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children:props.children})):(0,jsx_runtime_1.jsx)("a",Object.assign({"data-testid":`line-item-remove-link-${(_a=lineItem?.sku_code)!==null&&_a!==void 0?_a:""}`},props,{href:"#",onClick:handleRemove,children:label}))}exports.LineItemRemoveLink=LineItemRemoveLink,exports.default=LineItemRemoveLink;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LineItemRemoveLink=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),LineItemChildrenContext_1=tslib_1.__importDefault(require("../../context/LineItemChildrenContext")),LineItemContext_1=tslib_1.__importDefault(require("../../context/LineItemContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext"));function LineItemRemoveLink(props){var _a;const{label="Remove",onClick}=props,{lineItem}=(0,useCustomContext_1.default)({context:LineItemChildrenContext_1.default,contextComponentName:"LineItem",currentComponentName:"LineItemRemoveLink",key:"lineItem"}),{deleteLineItem}=(0,react_1.useContext)(LineItemContext_1.default),handleRemove=e=>{e.preventDefault(),deleteLineItem!=null&&lineItem!=null&&deleteLineItem(lineItem.id),onClick?.(e)},parentProps=Object.assign({handleRemove,lineItem},props);return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children:props.children})):(0,jsx_runtime_1.jsx)("a",Object.assign({"data-testid":`line-item-remove-link-${(_a=lineItem?.sku_code)!==null&&_a!==void 0?_a:""}`},props,{href:"#",onClick:handleRemove,children:label}))}exports.LineItemRemoveLink=LineItemRemoveLink,exports.default=LineItemRemoveLink;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OrderListRow=void 0;const tslib_1=require("tslib"),react_1=require("react"),jsx_runtime_1=require("react/jsx-runtime"),react_2=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),OrderListChildrenContext_1=tslib_1.__importDefault(require("../../context/OrderListChildrenContext")),isDate_1=tslib_1.__importDefault(require("../../utils/isDate")),last_1=tslib_1.__importDefault(require("lodash/last")),react_table_1=require("@tanstack/react-table");function OrderListRow(_a){var _b,{field,children}=_a,p=tslib_1.__rest(_a,["field","children"]);const{order,row,showActions,actionsComponent,actionsContainerClassName}=(0,react_2.useContext)(OrderListChildrenContext_1.default),cell=row?.getVisibleCells().filter(cell2=>cell2.column.id===field),isLastRow=((_b=(0,last_1.default)(row?.getVisibleCells()))===null||_b===void 0?void 0:_b.column.id)===field,As="td",ActionRow=()=>showActions&&isLastRow&&actionsComponent&&(0,jsx_runtime_1.jsx)(As,Object.assign({"data-testid":"action-cell"},p,{className:actionsContainerClassName,children:(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children:actionsComponent}))}))||null,parentProps=Object.assign(Object.assign({},p),{field,order,row,cell});return children?(0,jsx_runtime_1.jsxs)(
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OrderListRow=void 0;const tslib_1=require("tslib"),react_1=require("react"),jsx_runtime_1=require("react/jsx-runtime"),react_2=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),OrderListChildrenContext_1=tslib_1.__importDefault(require("../../context/OrderListChildrenContext")),isDate_1=tslib_1.__importDefault(require("../../utils/isDate")),last_1=tslib_1.__importDefault(require("lodash/last")),react_table_1=require("@tanstack/react-table");function OrderListRow(_a){var _b,{field,children}=_a,p=tslib_1.__rest(_a,["field","children"]);const{order,row,showActions,actionsComponent,actionsContainerClassName}=(0,react_2.useContext)(OrderListChildrenContext_1.default),cell=row?.getVisibleCells().filter(cell2=>cell2.column.id===field),isLastRow=((_b=(0,last_1.default)(row?.getVisibleCells()))===null||_b===void 0?void 0:_b.column.id)===field,As="td",ActionRow=()=>showActions&&isLastRow&&actionsComponent&&(0,jsx_runtime_1.jsx)(As,Object.assign({"data-testid":"action-cell"},p,{className:actionsContainerClassName,children:(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children:actionsComponent}))}))||null,parentProps=Object.assign(Object.assign({},p),{field,order,row,cell});return children?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(As,{children:(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children}))}),(0,jsx_runtime_1.jsx)(ActionRow,{})]}):(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[cell?.map((cell2,k)=>{const cellValue=cell2.getValue(),value=(0,isDate_1.default)(cellValue)?new Date(Date.parse(cellValue)).toLocaleString():(0,react_table_1.flexRender)(cell2.column.columnDef.cell,cell2.getContext());return(0,react_1.createElement)(As,Object.assign({"data-testid":`cell-${k}`},p,{key:cell2.id}),value)}),(0,jsx_runtime_1.jsx)(ActionRow,{})]})}exports.OrderListRow=OrderListRow,OrderListRow.displayName="OrderListRow",exports.default=OrderListRow;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ShippingMethodRadioButton=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),ShippingMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/ShippingMethodChildrenContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),ShipmentContext_1=tslib_1.__importDefault(require("../../context/ShipmentContext"));function ShippingMethodRadioButton(props){const{onChange}=props,p=tslib_1.__rest(props,["onChange"]),[checked,setChecked]=(0,react_1.useState)(!1),{shippingMethod,currentShippingMethodId,shipmentId}=(0,react_1.useContext)(ShippingMethodChildrenContext_1.default),{setShippingMethod}=(0,react_1.useContext)(ShipmentContext_1.default),shippingMethodId=shippingMethod?.id,name=`shipment-${shipmentId??""}`,id=`${name}-${shippingMethodId??""}`;(0,react_1.useEffect)(()=>(setChecked(shippingMethodId===currentShippingMethodId),()=>{setChecked(!1)}),[currentShippingMethodId,shippingMethodId]);const handleOnChange=()=>tslib_1.__awaiter(this,void 0,void 0,function*(){if(shipmentId&&shippingMethodId&&setShippingMethod!=null){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ShippingMethodRadioButton=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),ShippingMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/ShippingMethodChildrenContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),ShipmentContext_1=tslib_1.__importDefault(require("../../context/ShipmentContext"));function ShippingMethodRadioButton(props){const{onChange}=props,p=tslib_1.__rest(props,["onChange"]),[checked,setChecked]=(0,react_1.useState)(!1),{shippingMethod,currentShippingMethodId,shipmentId}=(0,react_1.useContext)(ShippingMethodChildrenContext_1.default),{setShippingMethod}=(0,react_1.useContext)(ShipmentContext_1.default),shippingMethodId=shippingMethod?.id,name=`shipment-${shipmentId??""}`,id=`${name}-${shippingMethodId??""}`;(0,react_1.useEffect)(()=>(setChecked(shippingMethodId===currentShippingMethodId),()=>{setChecked(!1)}),[currentShippingMethodId,shippingMethodId]);const handleOnChange=()=>tslib_1.__awaiter(this,void 0,void 0,function*(){if(shipmentId&&shippingMethodId&&setShippingMethod!=null){const{order}=yield setShippingMethod(shipmentId,shippingMethodId);shippingMethod&&onChange!=null&&onChange({shippingMethod,shipmentId,order})}}),parentProps=Object.assign({shippingMethod,shipmentId,handleOnChange,name,id},props);return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children:props.children})):(0,jsx_runtime_1.jsx)("input",Object.assign({type:"radio",name,id,onChange:e=>{e.stopPropagation(),handleOnChange()},checked},p))}exports.ShippingMethodRadioButton=ShippingMethodRadioButton,exports.default=ShippingMethodRadioButton;
|
|
@@ -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}`:""
|
|
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;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { type ChildrenFunction } from '../../typings/index';
|
|
3
|
+
import { type LineItem } from '@commercelayer/sdk';
|
|
3
4
|
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
4
5
|
quantity: number;
|
|
5
6
|
handleChange: (event: React.MouseEvent<HTMLSelectElement>) => void;
|
|
7
|
+
lineItem?: LineItem;
|
|
6
8
|
}
|
|
7
9
|
type Props = {
|
|
8
10
|
children?: ChildrenFunction<ChildrenProps>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import LineItemContext from"../../context/LineItemContext";import Parent from"../utils/Parent";export function LineItemQuantity(props){const{max=50,readonly=!1,...p}=props,{lineItem}=useContext(LineItemChildrenContext),{updateLineItem}=useContext(LineItemContext),options=[];for(let i=1;i<=max;i++)options.push(_jsx("option",{value:`${i}`,children:i},i));const handleChange=e=>{const quantity2=Number(e.target.value);updateLineItem&&lineItem&&updateLineItem(lineItem.id,quantity2)},quantity=lineItem?.quantity,parentProps={handleChange,quantity,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):readonly?_jsx("span",{...p,children:quantity}):_jsx("select",{"data-testid":lineItem?.sku_code,title:lineItem?.name??"",value:quantity,onChange:handleChange,...p,children:options})}export default LineItemQuantity;
|
|
2
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import LineItemContext from"../../context/LineItemContext";import Parent from"../utils/Parent";export function LineItemQuantity(props){const{max=50,readonly=!1,...p}=props,{lineItem}=useContext(LineItemChildrenContext),{updateLineItem}=useContext(LineItemContext),options=[];for(let i=1;i<=max;i++)options.push(_jsx("option",{value:`${i}`,children:i},i));const handleChange=e=>{const quantity2=Number(e.target.value);updateLineItem&&lineItem&&updateLineItem(lineItem.id,quantity2)},quantity=lineItem?.quantity,parentProps={handleChange,quantity,lineItem,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):readonly?_jsx("span",{...p,children:quantity}):_jsx("select",{"data-testid":lineItem?.sku_code,title:lineItem?.name??"",value:quantity,onChange:handleChange,...p,children:options})}export default LineItemQuantity;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type PropsWithoutRef } from 'react';
|
|
2
2
|
import { type ChildrenFunction } from '../../typings/index';
|
|
3
|
+
import { type LineItem } from '@commercelayer/sdk';
|
|
3
4
|
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
4
5
|
handleRemove: (event: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
5
6
|
label?: string;
|
|
7
|
+
lineItem?: LineItem;
|
|
6
8
|
}
|
|
7
9
|
interface Props extends PropsWithoutRef<Omit<JSX.IntrinsicElements['a'], 'children'>> {
|
|
8
10
|
children?: ChildrenFunction<ChildrenProps>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import LineItemContext from"../../context/LineItemContext";import Parent from"../utils/Parent";import useCustomContext from"../../utils/hooks/useCustomContext";export function LineItemRemoveLink(props){const{label="Remove",onClick}=props,{lineItem}=useCustomContext({context:LineItemChildrenContext,contextComponentName:"LineItem",currentComponentName:"LineItemRemoveLink",key:"lineItem"}),{deleteLineItem}=useContext(LineItemContext),handleRemove=e=>{e.preventDefault(),deleteLineItem!=null&&lineItem!=null&&deleteLineItem(lineItem.id),onClick?.(e)},parentProps={handleRemove,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("a",{"data-testid":`line-item-remove-link-${lineItem?.sku_code??""}`,...props,href:"#",onClick:handleRemove,children:label})}export default LineItemRemoveLink;
|
|
2
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import LineItemContext from"../../context/LineItemContext";import Parent from"../utils/Parent";import useCustomContext from"../../utils/hooks/useCustomContext";export function LineItemRemoveLink(props){const{label="Remove",onClick}=props,{lineItem}=useCustomContext({context:LineItemChildrenContext,contextComponentName:"LineItem",currentComponentName:"LineItemRemoveLink",key:"lineItem"}),{deleteLineItem}=useContext(LineItemContext),handleRemove=e=>{e.preventDefault(),deleteLineItem!=null&&lineItem!=null&&deleteLineItem(lineItem.id),onClick?.(e)},parentProps={handleRemove,lineItem,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("a",{"data-testid":`line-item-remove-link-${lineItem?.sku_code??""}`,...props,href:"#",onClick:handleRemove,children:label})}export default LineItemRemoveLink;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{createElement as _createElement}from"react";import{jsx as _jsx,
|
|
2
|
+
import{createElement as _createElement}from"react";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import OrderListChildrenContext from"../../context/OrderListChildrenContext";import isDate from"../../utils/isDate";import last from"lodash/last";import{flexRender}from"@tanstack/react-table";export function OrderListRow({field,children,...p}){const{order,row,showActions,actionsComponent,actionsContainerClassName}=useContext(OrderListChildrenContext),cell=row?.getVisibleCells().filter(cell2=>cell2.column.id===field),isLastRow=last(row?.getVisibleCells())?.column.id===field,As="td",ActionRow=()=>showActions&&isLastRow&&actionsComponent&&_jsx(As,{"data-testid":"action-cell",...p,className:actionsContainerClassName,children:_jsx(Parent,{...parentProps,children:actionsComponent})})||null,parentProps={...p,field,order,row,cell};return children?_jsxs(_Fragment,{children:[_jsx(As,{children:_jsx(Parent,{...parentProps,children})}),_jsx(ActionRow,{})]}):_jsxs(_Fragment,{children:[cell?.map((cell2,k)=>{const cellValue=cell2.getValue(),value=isDate(cellValue)?new Date(Date.parse(cellValue)).toLocaleString():flexRender(cell2.column.columnDef.cell,cell2.getContext());return _createElement(As,{"data-testid":`cell-${k}`,...p,key:cell2.id},value)}),_jsx(ActionRow,{})]})}OrderListRow.displayName="OrderListRow";export default OrderListRow;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import ShippingMethodChildrenContext from"../../context/ShippingMethodChildrenContext";import Parent from"../utils/Parent";import ShipmentContext from"../../context/ShipmentContext";export function ShippingMethodRadioButton(props){const{onChange,...p}=props,[checked,setChecked]=useState(!1),{shippingMethod,currentShippingMethodId,shipmentId}=useContext(ShippingMethodChildrenContext),{setShippingMethod}=useContext(ShipmentContext),shippingMethodId=shippingMethod?.id,name=`shipment-${shipmentId??""}`,id=`${name}-${shippingMethodId??""}`;useEffect(()=>(setChecked(shippingMethodId===currentShippingMethodId),()=>{setChecked(!1)}),[currentShippingMethodId,shippingMethodId]);const handleOnChange=async()=>{if(shipmentId&&shippingMethodId&&setShippingMethod!=null){
|
|
2
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import ShippingMethodChildrenContext from"../../context/ShippingMethodChildrenContext";import Parent from"../utils/Parent";import ShipmentContext from"../../context/ShipmentContext";export function ShippingMethodRadioButton(props){const{onChange,...p}=props,[checked,setChecked]=useState(!1),{shippingMethod,currentShippingMethodId,shipmentId}=useContext(ShippingMethodChildrenContext),{setShippingMethod}=useContext(ShipmentContext),shippingMethodId=shippingMethod?.id,name=`shipment-${shipmentId??""}`,id=`${name}-${shippingMethodId??""}`;useEffect(()=>(setChecked(shippingMethodId===currentShippingMethodId),()=>{setChecked(!1)}),[currentShippingMethodId,shippingMethodId]);const handleOnChange=async()=>{if(shipmentId&&shippingMethodId&&setShippingMethod!=null){const{order}=await setShippingMethod(shipmentId,shippingMethodId);shippingMethod&&onChange!=null&&onChange({shippingMethod,shipmentId,order})}},parentProps={shippingMethod,shipmentId,handleOnChange,name,id,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("input",{type:"radio",name,id,onChange:e=>{e.stopPropagation(),handleOnChange()},checked,...p})}export default ShippingMethodRadioButton;
|
|
@@ -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}`:""
|
|
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}`}
|