1import { j as jsxRuntimeExports, r as reactExports, D as DASHBOARD, S as SETTINGS, dt as MY_BUSINESS_GENERAL_ADJUSTMENTS, n as navigate, cV as ORDERS, gx as DETAIL, i as import_0 } from "../chunks/chunk-BU8s67O7.js"; 2import { ae as useConnections, ck as support, u as useEntitlements, i as import_1 } from "../chunks/chunk-BclX8tFC.js"; 3import { S as SvgTrash } from "../chunks/chunk-B2bahb0m.js"; 4import "../chunks/chunk-gQZ1vf8Q.js"; 5import { g as getParameter, F as Formik } from "../chunks/chunk-BeXifZsx.js"; 6import { C as CreateOrderContext, P as ProductsSearchGlobal } from "../chunks/chunk-DMeoa8X5.js"; 7import { u as useFormikOrderProps, a as useShippingCarrier, C as CountryDivisions, L as Location, b as useShippingInfo, c as useShippingCarrierMethods, D as DeliveryDates, d as useCart, e as CartProduct, f as useCreateOrder, g as ClientInfo, B as BillingInfo, h as useOrderInfo, O as OrderInfo } from "../chunks/chunk-D6OMfagz.js"; 8import { D as Divider } from "../chunks/chunk-DGoQ4NCQ.js"; 9import { R as RadioList } from "../chunks/chunk-DbKauEgP.js"; 10import { T as Text, L as Loader } from "../chunks/chunk-BK1F59BV.js"; 11import { T as TextField } from "../chunks/chunk-u9YFYmBR.js"; 12import { S as ShippingMethods } from "../chunks/chunk-TTkVMuqe.js"; 13import { b as SHIPPING_OPTIONS } from "../chunks/chunk-BLXbwISE.js"; 14import { B as BackButton } from "../chunks/chunk-BypPhVX6.js"; 15import { c as cn, T as Typography } from "../chunks/chunk-BXp0u1a1.js"; 16import { I as IconLinkButton, B as Button$1, M as Modal } from "../chunks/chunk-BiNlXSaw.js"; 17import { C as ConfirmModal } from "../chunks/chunk-BYqiuukc.js"; 18import { C as Container } from "../chunks/chunk-6fRj4JDu.js"; 19import { O as OrderCreatedModal }
19 from "../chunks/chunk-ubW5JZF3.js"; 20import { W as WhatsAppApiTemplateVariable, C as CREATE_ORDER_SUMMARY_TEMPLATE_ACTION } from "../chunks/chunk-CWLPh4_9.js"; 21import { u as useTranslateText } from "../chunks/chunk-G84nenOf.js"; 22import { L as Link } from "../chunks/chunk-gxbpKysT.js"; 23import { M as MessageCard } from "../chunks/chunk-BRfk-JoE.js"; 24import { a as useTemplates } from "../chunks/chunk-Ca_U7mf7.js"; 25import { s as selectProductsState } from "../chunks/chunk-CNbK7DXX.js"; 26import { B as Button } from "../chunks/chunk-Bc6F7CMI.js"; 27import { P as ProgressBar } from "../chunks/chunk-CFi9TIK3.js"; 28import { C as CapLimitBanner } from "../chunks/chunk-CFQiMUxI.js"; 29import { c as cartSession } from "../chunks/chunk-OIFe0PkW.js"; 30import { s as schema } from "../chunks/chunk-tWhP0hv9.js"; 31import "../chunks/chunk-BeNMa6z1.js"; 32import "../chunks/chunk-CFfcpioo.js"; 33import "../chunks/chunk-Br0OYO65.js"; 34import "../chunks/chunk-40h3_QsV.js"; 35import "../chunks/chunk-WvD1X1hJ.js"; 36import "../chunks/chunk-ByxHLklS.js"; 37import "../chunks/chunk-FVq5LI_2.js"; 38import "../chunks/chunk-Cd0w7IDt.js"; 39import "../chunks/chunk-BbSNid0O.js"; 40import "../chunks/chunk-CmrIWoG2.js"; 41import "../chunks/chunk-Cwsa3Djq.js"; 42import "../chunks/chunk-itWYynQu.js"; 43import "../chunks/chunk-BY3GQqIW.js"; 44import "../chunks/chunk-D1F5Kype.js"; 45import "../chunks/chunk-BHhu2WC9.js"; 46import "../chunks/chunk-BNtNNiZK.js"; 47import "../chunks/chunk-xIqP9ABf.js"; 48import "../chunks/chunk-Cc5QNoPq.js"; 49import "../chunks/chunk-BdEK7S0b.js"; 50import "../chunks/chunk-4P-EDRUn.js"; 51import "../chunks/chunk-whk3Mucl.js"; 52import "../chunks/chunk-UBONcc_W.js"; 53import "../chunks/chunk-C20tm2F-.js"; 54import "../chunks/chunk-CQse1MX2.js"; 55import "../chunks/chunk-DgF9ljJe.js"; 56import "../chunks/chunk-tnN5WP_f.js"; 57import "../chunks/chunk-wbyL8S0e.js"; 58import "../chunks/chunk-BBEiIWk6.js"; 59import "../chunks/chunk-DX-vy8Jg.js"; 60import "../chunks/chunk-caJV7h4b.js"; 61import "../chunks/chunk-DlfIhAf4.js"; 62import "../chunks/chunk-CQFpnmCa.js"; 63import "../chunks/chunk-zjhijl50.js"; 64import "../chunks/chunk-Cw7EY5GC.js"; 65import "../chunks/chunk-CRQDyD24.js"; 66import "../chunks/chunk-deTzDaMf.js"; 67import "../chunks/chunk-kkQLXJ9B.js"; 68import "../chunks/chunk-Cmh8kLeq.js"; 69import "../chunks/chunk-CdltwyED.js"; 70import "../chunks/chunk-DUsIla1w.js"; 71import "../chunks/chunk-2A5etDWp.js"; 72import "../chunks/chunk-D4ia3RZ6.js"; 73import "../chunks/chunk-Bmhuqdlm.js"; 74import "../chunks/chunk-71A3WRkl.js"; 75import "../chunks/chunk-D8TGQ-dC.js"; 76import "../chunks/chunk-CqZEl7uG.js"; 77import "../chunks/chunk-Daix9q5I.js"; 78import "../chunks/chunk-Der_VSzP.js"; 79import "../chunks/chunk-CE_hqxtD.js"; 80import "../chunks/chunk-DxulEiAS.js"; 81import "../chunks/chunk-dfrVe1bI.js"; 82import "../chunks/chunk-kCW9-vLX.js"; 83import "../chunks/chunk-zpmVEtgw.js"; 84import "../chunks/chunk-D36Jf0W1.js"; 85import "../chunks/chunk-DvIl_EEk.js"; 86import "../chunks/chunk-B7XVLA34.js"; 87import "../chunks/chunk-CEVPdIrZ.js"; 88import "../chunks/chunk-DjQUrUtw.js"; 89import "../chunks/chunk-kMRqW9aM.js"; 90import "../chunks/chunk-f8nkNEV_.js"; 91import "../chunks/chunk-haeFET9V.js"; 92import "../chunks/chunk-CriVLNre.js"; 93import "../chunks/chunk-BgeDWXlS.js"; 94import "../chunks/chunk-CF86puuG.js"; 95import "../chunks/chunk-Cenp-ogH.js"; 96import "../chunks/chunk--Zn-7eje.js"; 97import "../chunks/chunk-DrRAm4uK.js"; 98import "../chunks/chunk-CTXIOGdT.js"; 99import "../chunks/chunk-DYWRFLgq.js"; 100import "../chunks/chunk-J8GpOn5O.js"; 101import "../chunks/chunk-DGiR5Ht0.js"; 102import "../chunks/chunk-C5Kp0Dd0.js"; 103import "../chunks/chunk-BmXoluaY.js"; 104import "../chunks/chunk-C6eGovBW.js"; 105import "../chunks/chunk-DoBs-T9N.js"; 106import "../chunks/chunk-Cz4yqtla.js"; 107import "../chunks/chunk-9e1_Cz6L.js"; 108import "../chunks/chunk-4k_EJmJx.js"; 109import "../chunks/chunk-Cd0699Do.js"; 110import "../chunks/chunk-yTyiCS2J.js"; 111import "../chunks/chunk-0qrKn-RG.js"; 112import "../chunks/chunk-DZTJuHaI.js"; 113import "../chunks/chunk-2OLkvmOM.js"; 114import "../chunks/chunk-ANdAYO7q.js"; 115import "../chunks/chunk-BTKSDgWR.js"; 116import "../chunks/chunk-C-FHjCl0.js"; 117import "../chunks/chunk-DbfGrJGi.js"; 118import "../chunks/chunk-0C0zLmeX.js"; 119import "../chunks/chunk-CtIYZV4B.js"; 120import "../chunks/chunk-TqazsvGq.js"; 121import "../chunks/chunk-7sqNaOVB.js"; 122import "../chunks/chunk-BfUJOjyb.js"; 123import "../chunks/chunk-CCxO4WuQ.js"; 124import "../chunks/chunk-kJ10tzea.js"; 125import "../chunks/chunk-WULD8644.js"; 126import "../chunks/chunk-BNtj8h6O.js"; 127import "../chunks/chunk-CVi6_MuY.js"; 128import "../chunks/chunk-xmAzWwTE.js"; 129import "../chunks/chunk-NCaACXxQ.js"; 130import "../chunks/chunk-CQ-WGroR.js"; 131import "../chunks/chunk-CPuySedH.js"; 132import "../chunks/chunk-mIw9ahkp.js"; 133import "../chunks/chunk-DupBIzJW.js"; 134import "../chunks/chunk-DVtxdTn5.js"; 135import "../chunks/chunk-eDDePP7r.js"; 136import "../chunks/chunk-DW2cAi0y.js"; 137import "../chunks/chunk-C1Xxqhnb.js"; 138import "../chunks/chunk-CXFxmapd.js"; 139import "../chunks/chunk-S4arhhbh.js"; 140import "../chunks/chunk-BaxlGo-e.js"; 141import "../chunks/chunk-CcmMUp-0.js"; 142import "../chunks/chunk-D_Sp_WRR.js"; 143import "../chunks/chunk-COW1DJdI.js"; 144import "../chunks/chunk-DNooX5U2.js"; 145const Address = ({ 146 isEstimatingShipping, 147 isLocationRequired, 148 shippingCarriersList, 149 setIsLocationRequired, 150 setShippingCarriersList 151}) => { 152 var _a, _b, _c, _d; 153 const orderProps = useFormikOrderProps(); 154 const orderForm = orderProps.values; 155 const { handleSelectShippingCarrier } = useShippingCarrier({ 156 shippingCarriersList, 157 setIsLocationRequired 158 }); 159 return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
160 /* @__PURE__ */ jsxRuntimeExports.jsx(CountryDivisions, { setShippingCarriersList }), 161 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-row justify-start items-baseline flex-wrap gap-2.5 mb-2.5", children: /* @__PURE__ */ jsxRuntimeExports.jsx( 162 TextField, 163 { 164 className: "", 165 label: "Exactaddress.label", 166 placeholder: "Exactaddress.placeholder", 167 value: orderForm.shipping.address, 168 onChange: orderProps.handleChange("shipping.address"), 169 onBlur: orderProps.handleBlur("shipping.address"), 170 hasError: Boolean( 171 ((_a = orderProps.touched.shipping) == null ? void 0 : _a.address) && ((_b = orderProps.errors.shipping) == null ? void 0 : _b.address) 172 ), 173 required: true 174 } 175 ) }), 176 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "orders-create__inputs-rows", children: [ 177 /* @__PURE__ */ jsxRuntimeExports.jsx( 178 Text, 179 { 180 className: "mb-2.5 [&:not(:first-child)]:mt-2.5 text-dark-gray", 181 idIntl: "Orders.create.clientinfo.shippingservice.subtitle", 182 typography: "typography--variant-b2" 183 } 184 ),
185 isEstimatingShipping ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-row justify-center items-center flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, { height: 30, width: 30, type: "round-gradient", isLoading: true }) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ 186 !shippingCarriersList.length && /* @__PURE__ */ jsxRuntimeExports.jsx( 187 Text, 188 { 189 color: "gray", 190 idIntl: "Orders.create.clientinfo.shippingservice.fill", 191 typography: "typography--variant-body3" 192 } 193 ), 194 /* @__PURE__ */ jsxRuntimeExports.jsx( 195 RadioList, 196 { 197 className: "justify-start items-start gap-y-2.5", 198 inlineStyle: false, 199 list: shippingCarriersList, 200 value: orderForm.shipping.shippingCarrier, 201 onChange: handleSelectShippingCarrier, 202 hasError: Boolean( 203 ((_c = orderProps.touched.shipping) == null ? void 0 : _c.shippingCarrier) && ((_d = orderProps.errors.shipping) == null ? void 0 : _d.shippingCarrier) 204 ), 205 typography: "typography--variant-body3" 206 } 207 ) 208 ] }) 209 ] }),
210 isLocationRequired && /* @__PURE__ */ jsxRuntimeExports.jsx(Location, {}) 211 ] }); 212}; 213const ShippingInfo = (props) => { 214 var _a, _b; 215 const { isEstimatingShipping } = props; 216 const { data, actions } = useShippingInfo(props); 217 const { handleSelectMethod } = useShippingCarrierMethods({ 218 shippingCarrier: data.shippingCarrier 219 }); 220 return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ 221 /* @__PURE__ */ jsxRuntimeExports.jsx( 222 Text, 223 { 224 className: "mb-2.5 [&:not(:first-child)]:mt-2.5 text-dark-gray", 225 idIntl: "Orders.create.shippinginfo.title", 226 typography: "typography--variant-h4" 227 } 228 ), 229 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "!flex-row !items-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx( 230 RadioList, 231 { 232 className: "justify-start items-start gap-y-2.5", 233 inlineStyle: true, 234 list: SHIPPING_OPTIONS, 235 value: data.orderForm.shipping.orderDeliveryStrategy, 236 onChange: (option) => actions.handleOrderDeliveryStrategyChange(option), 237 hasError: Boolean( 238 ((_a = data.orderProps.touched.shipping) == null ? void 0 : _a.orderDeliveryStrategy) && ((_b = data.orderProps.errors.shipping) == null ? void 0 : _b.orderDeliveryStrategy) 239 ), 240 typography: "typography--variant-body3" 241 } 242 ) }),
243 data.isShippingEnabled && /* @__PURE__ */ jsxRuntimeExports.jsx( 244 Address, 245 { 246 isEstimatingShipping, 247 isLocationRequired: data.isLocationRequired, 248 shippingCarriersList: data.shippingCarriersList, 249 setIsLocationRequired: actions.setIsLocationRequired, 250 setShippingCarriersList: actions.setShippingCarriersList 251 } 252 ), 253 data.isShippingEnabled && !data.isLoadingAction && /* @__PURE__ */ jsxRuntimeExports.jsx( 254 ShippingMethods, 255 { 256 isLocationRequired: data.isLocationRequired, 257 currentCarrier: data.shippingCarrier, 258 shippingCarrierMethods: data.shippingCarrierMethods, 259 onChange: handleSelectMethod 260 } 261 ), 262 /* @__PURE__ */ jsxRuntimeExports.jsx(Divider, {}), 263 /* @__PURE__ */ jsxRuntimeExports.jsx(DeliveryDates, {}) 264 ] }); 265}; 266const Cart = ({ className = "", handleEstimateShipping }) => { 267 const { cartItems, canRenderCart } = useCart(); 268 if (!canRenderCart) return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}); 269 return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: cn("grid grid-cols-1 gap-2 desktop:grid-cols-2", className), children: reactExports.Children.toArray( 270 cartItems == null ? void 0 : cartItems.map((product, index) => /* @__PURE__ */ jsxRuntimeExports.jsx( 271 CartProduct, 272 { 273 index, 274 product, 275 handleEstimateShipping 276 } 277 )) 278 ) }); 279}; 280const API_CONNECTIONS = ["whatsapp", "whatsapp_coexistence"]; 281const useSummaryTemplateSuggestion = () => { 282 const { defaultConnection, isFetching: fetchingConnections } = useConnections(); 283 const connectionId = (defaultConnection == null ? void 0 : defaultConnection.id) || ""; 284 const { data: templates, isFetching: fetchingTemplates } = useTemplates({ 285 connectionId, 286 name: WhatsAppApiTemplateVariable.orderResume, 287 options: { enabled: !!connectionId } 288 }); 289 const isAPIConnection = defaultConnection && API_CONNECTIONS.includes(defaultConnection.type); 290 const isFetchingData = fetchingConnections || fetchingTemplates; 291 const orderResumeTemplate = templates.find( 292 ({ name }) => name === WhatsAppApiTemplateVariable.orderResume 293 ); 294 const missingSummaryTemplate = !orderResumeTemplate || orderResumeTemplate.status !== "APPROVED"; 295 const missingConnection = !defaultConnection; 296 const showSuggestion = !isFetchingData && (missingConnection || !isAPIConnection || missingSummaryTemplate); 297 return { connectionId, showSuggestion, missingConnection }; 298}; 299const baseIdIntl = "Orders.create.summaryTemplateSuggestion.description"; 300const SummaryTemplateSuggestion = ({ className }) => { 301 const { connectionId, showSuggestion } = useSummaryTemplateSuggestion(); 302 const createTemplateRoute = `${DASHBOARD}/${SETTINGS}/${MY_BUSINESS_GENERAL_ADJUSTMENTS}?tab=crm${connectionId ? `&connectionId=${connectionId}` : ""}&action=${CREATE_ORDER_SUMMARY_TEMPLATE_ACTION}`; 303 const getTranslation = useTranslateText(); 304 if (!showSuggestion) return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}); 305 return /* @__PURE__ */ jsxRuntimeExports.jsx( 306 MessageCard, 307 { 308 className: cn("px-4 py-5 bg-primary-50 rounded-m", className), 309 iconClassName: "mt-0.5", 310 children: /* @__PURE__ */ jsxRuntimeExports.jsxs( 311 Typography, 312 { 313 as: "p", 314 className: "text-smokey-black-500 font-semibold leading-5", 315 variant: "smallText", 316 children: [ 317 getTranslation(`${baseIdIntl}.part1`), 318 " ",
319 /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { href: createTemplateRoute, children: getTranslation(`${baseIdIntl}.part2`) }), 320 " ", 321 getTranslation(`${baseIdIntl}.part3`), 322 " ", 323 /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { href: support.href, target: "_blank", rel: "noopener noreferrer", children: getTranslation(`${baseIdIntl}.part4`) }) 324 ] 325 } 326 ) 327 } 328 ); 329}; 330const EditItems = ({ onContinue, onCancel }) => { 331 const editOrderItems = selectProductsState((state) => state.editOrderItems); 332 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-5", children: [ 333 /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { className: "mb-1 text-dark-gray", idIntl: "Products", variant: "h4" }), 334 /* @__PURE__ */ jsxRuntimeExports.jsx( 335 Typography, 336 { 337 className: "mb-5 text-dark-gray", 338 idIntl: "Orders.edit.order.step1", 339 variant: "xSmallText", 340 as: "p" 341 } 342 ), 343 !(editOrderItems == null ? void 0 : editOrderItems.length) && /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, { height: 30, width: 30, type: "round-gradient", isLoading: true }), 344 editOrderItems && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
345 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 gap-2 desktop:grid-cols-2 min-w-[18.75rem] max-h-[40vh] overflow-y-auto", children: reactExports.Children.toArray( 346 editOrderItems.map((product, index) => /* @__PURE__ */ jsxRuntimeExports.jsx(CartProduct, { index, product, isEditOrder: true })) 347 ) }), 348 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex mt-5 gap-2 justify-end", children: [ 349 /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { idIntl: "Cancel", variant: "outline", onClick: onCancel }), 350 /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { idIntl: "Continue", onClick: onContinue }) 351 ] }) 352 ] }) 353 ] }); 354}; 355const FIELD_ENTRIES = { 356 // Customer 357 "customer.name": { section: "OrderForm.errorSection.customer", fieldKey: "Name" }, 358 "customer.email": { section: "OrderForm.errorSection.customer", fieldKey: "Email" }, 359 "customer.phone": { section: "OrderForm.errorSection.customer", fieldKey: "Phone" }, 360 // Shipping 361 "shipping.country": { section: "OrderForm.errorSection.shipping", fieldKey: "Country" }, 362 "shipping.province": { section: "OrderForm.errorSection.shipping", fieldKey: "Province" }, 363 "shipping.canton": { section: "OrderForm.errorSection.shipping", fieldKey: "Canton" }, 364 "shipping.district": { section: "OrderForm.errorSection.shipping", fieldKey: "District" }, 365 "shipping.postalCode": { 366 section: "OrderForm.errorSection.shipping", 367 fieldKey: "OrderForm.errorField.postalCode" 368 }, 369 "shipping.address": { section: "OrderForm.errorSection.shipping", fieldKey: "Address" }, 370 // Billing 371 "billing.email": { section: "OrderForm.errorSection.billing", fieldKey: "Email" }, 372 "billing.identification": { 373 section: "OrderForm.errorSection.billing", 374 fieldKey: "OrderForm.errorField.identification" 375 }, 376 "billing.name": { section: "OrderForm.errorSection.billing", fieldKey: "Name" }, 377 "billing.phone": { section: "OrderForm.errorSection.billing", fieldKey: "Phone" }, 378 "billing.country": { section: "OrderForm.errorSection.billing", fieldKey: "Country" }, 379 "billing.province": { section: "OrderForm.errorSection.billing", fieldKey: "Province" }, 380 "billing.canton": { section: "OrderForm.errorSection.billing", fieldKey: "Canton" }, 381 "billing.district": { section: "OrderForm.errorSection.billing", fieldKey: "District" }, 382 "billing.postalCode": { 383 section: "OrderForm.errorSection.billing", 384 fieldKey: "OrderForm.errorField.postalCode" 385 }, 386 "billing.address": { section: "OrderForm.errorSection.billing", fieldKey: "Address" }, 387 // OrderInfo 388 "orderInfo.paymentMethod": { 389 section: "OrderForm.errorSection.orderInfo", 390 fieldKey: "OrderForm.errorField.paymentMethod" 391 }, 392 "orderInfo.salesChannel": { 393 section: "OrderForm.errorSection.orderInfo", 394 fieldKey: "OrderForm.errorField.salesChannel" 395 }, 396 "orderInfo.placeOfDispatch": { 397 section: "OrderForm.errorSection.orderInfo", 398 fieldKey: "OrderForm.errorField.placeOfDispatch" 399 } 400}; 401const buildOrderErrorFieldLabels = (translate) => Object.fromEntries( 402 Object.entries(FIELD_ENTRIES).map(([path, { section, fieldKey }]) => [ 403 path, 404 `${translate(section)} â ${translate(fieldKey)}` 405 ]) 406); 407const OrderInfoAdapter = ({ error, setIsPaymentMethodSupported, onCurrencyChanged }) => { 408 const orderProps = useFormikOrderProps(); 409 const orderInfoProps = useOrderInfo({ 410 orderProps, 411 selectedShippingCarrier: orderProps.values.shipping.shippingCarrier, 412 setIsPaymentMethodSupported, 413 availableSalesChannels: [], 414 onCurrencyChanged 415 }); 416 return /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { className: "flex flex-col py-[1.375rem] px-2.5 tablet-lg:px-5 mb-3 tablet-lg:py-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(OrderInfo, { errorMessage: error, ...orderInfoProps }) }); 417}; 418const CreateOrder = () => { 419 var _a; 420 const { actions, data } = useCreateOrder({ initialSalesChannel: "", orderType: "ORDER" }); 421 const cartBatchProgress = selectProductsState((state) => state.cartBatchProgress ?? 0); 422 const getTranslation = useTranslateText(); 423 const errorFieldLabels = reactExports.useMemo( 424 () => buildOrderErrorFieldLabels(getTranslation), 425 [getTranslation] 426 ); 427 const editOrderId = getParameter("edit"); 428 const cloneOrderId = getParameter("clone"); 429 let orderMode = "create"; 430 if (editOrderId) orderMode = "edit"; 431 else if (cloneOrderId) orderMode = "clone"; 432 const { capReached } = useEntitlements(); 433 const countsAgainstCap = orderMode !== "edit"; 434 const capBlocked = countsAgainstCap && capReached("orders"); 435 const channel = ((_a = data.editOrder) == null ? void 0 : _a.channel) ?? "avify"; 436 const channelUpper = channel.charAt(0).toUpperCase() + channel.slice(1); 437 const [subtotal, setSubtotal] = reactExports.useState(0); 438 const [dynamicDiscount, setDynamicDiscount] = reactExports.useState(0); 439 const [tax, setTax] = reactExports.useState(0); 440 const [total, setTotal] = reactExports.useState(0); 441 const [selectedClient, setSelectedClient] = reactExports.useState(void 0); 442 const cartIdSession = cartSession((state) => state.cartIdSession); 443 const cartItems = selectProductsState((state) => state.cartItems); 444 return /* @__PURE__ */ jsxRuntimeExports.jsx("section", { className: "p-2.5 max-w-[106.5rem] mx-auto tablet:max-w-[72.25rem] tablet:px-[1.625rem] tablet:py-5 [&_.back-button]:mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx( 445 Formik, 446 { 447 validationSchema: schema, 448 initialValues: data.initialValues, 449 enableReinitialize: true, 450 onSubmit: actions.onSubmit, 451 children: (props) => { 452 var _a2, _b, _c, _d, _e, _f; 453 return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
454 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center flex-wrap mb-4", children: [ 455 /* @__PURE__ */ jsxRuntimeExports.jsx( 456 BackButton, 457 { 458 className: "!mb-0", 459 onClick: () => { 460 if (editOrderId) { 461 navigate(`${DASHBOARD}/${ORDERS}/${DETAIL}/${editOrderId}?page=1`); 462 } else if (cloneOrderId) { 463 navigate(`${DASHBOARD}/${ORDERS}/${DETAIL}/${cloneOrderId}?page=1`); 464 } else if (props.dirty || (cartItems ?? []).length > 0) { 465 actions.showCreateDraftModal(); 466 } else { 467 navigate(`${DASHBOARD}/${ORDERS}?page=${data.page}&back=true`); 468 } 469 }, 470 idIntl: `Orders.${orderMode}.title`, 471 idIntlValues: editOrderId || cloneOrderId ? { 472 orderId: `${((_a2 = data.editOrder) == null ? void 0 : _a2.channelPublicId) ?? ""}` 473 } : void 0 474 } 475 ), 476 !!data.currentDraftUUID && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
477 /* @__PURE__ */ jsxRuntimeExports.jsx( 478 IconLinkButton, 479 { 480 idIntl: "Orders.create.deleteDraftBtn", 481 className: "bg-red-100 px-[1.125rem] py-2.5", 482 typography: "typography--variant-subtitle3", 483 onClick: actions.showDeleteLoadedDraftModal, 484 color: "error-red", 485 children: /* @__PURE__ */ jsxRuntimeExports.jsx(SvgTrash, { className: "text-red-500" }) 486 } 487 ), 488 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[8px] text-right text-gray-400", children: cartIdSession }) 489 ] }) 490 ] }), 491 /* @__PURE__ */ jsxRuntimeExports.jsx(SummaryTemplateSuggestion, { className: "mb-4" }), 492 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col tablet-lg:flex-row tablet-lg:justify-between", children: [ 493 /* @__PURE__ */ jsxRuntimeExports.jsxs( 494 CreateOrderContext.Provider, 495 { 496 value: { 497 type: "order", 498 isLoadingAction: data.isLoadingAction, 499 activeUpdateProductRequestsCount: data.activeUpdateProductRequestsCount, 500 placeOfDispatch: props.values.orderInfo.placeOfDispatch, 501 requiresMap: data.requiresMap, 502 setIsLoadingAction: actions.setIsLoadingAction, 503 incrementActiveUpdateProductRequests: actions.incrementActiveUpdateProductRequests, 504 decrementActiveUpdateProductRequests: actions.decrementActiveUpdateProductRequests, 505 setRequiresMap: actions.setRequiresMap, 506 handleSaveDraft: actions.handleSaveDraft, 507 handleEstimateShipping: actions.handleEstimateShipping, 508 totals: { 509 subtotal, 510 setSubtotal, 511 // 512 dynamicDiscount, 513 setDynamicDiscount, 514 // 515 tax, 516 setTax, 517 // 518 total, 519 setTotal 520 }, 521 client: { 522 get: selectedClient, 523 set: setSelectedClient 524 } 525 }, 526 children: [
527 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-[2] max-w-[44.625rem]", children: [ 528 /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { className: "flex flex-col py-[1.375rem] px-2.5 tablet-lg:px-5 mb-5 tablet-lg:mr-[1.875rem]", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ClientInfo, {}) }), 529 /* @__PURE__ */ jsxRuntimeExports.jsxs(Container, { className: "flex flex-col py-[1.375rem] px-2.5 tablet-lg:px-5 mb-5 tablet-lg:mr-[1.875rem]", children: [ 530 /* @__PURE__ */ jsxRuntimeExports.jsx( 531 ProductsSearchGlobal, 532 { 533 footerIsSticky: false, 534 handleEstimateShipping: () => actions.handleEstimateShipping(props), 535 priceListId: props.values.priceListId 536 } 537 ), 538 !!(cartItems == null ? void 0 : cartItems.length) && /* @__PURE__ */ jsxRuntimeExports.jsx( 539 Typography, 540 { 541 className: "mt-5 mb-2", 542 idIntl: "Orders.create.products.cart.title", 543 variant: "smallText" 544 } 545 ),
546 /* @__PURE__ */ jsxRuntimeExports.jsx(Cart, { handleEstimateShipping: () => actions.handleEstimateShipping(props) }) 547 ] }), 548 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "orders-create__form", children: [ 549 /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { className: "flex flex-col py-[1.375rem] px-2.5 tablet-lg:px-5 mb-5 tablet-lg:mr-[1.875rem]", children: /* @__PURE__ */ jsxRuntimeExports.jsx( 550 ShippingInfo, 551 { 552 isEstimatingShipping: data.estimateShippingLoading, 553 shippingData: data.currentShippingEstimates || [], 554 handleEstimateShipping: () => actions.handleEstimateShipping(props) 555 } 556 ) }), 557 data.hasIntegrationForInvoice && /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { className: "flex flex-col py-[1.375rem] px-2.5 tablet-lg:px-5 mb-5 tablet-lg:mr-[1.875rem]", children: /* @__PURE__ */ jsxRuntimeExports.jsx(BillingInfo, {}) }) 558 ] }) 559 ] }),
560 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 h-full", children: [ 561 /* @__PURE__ */ jsxRuntimeExports.jsx( 562 OrderInfoAdapter, 563 { 564 error: data.createOrderError || data.mainErrorMessage, 565 setIsPaymentMethodSupported: actions.setIsPaymentMethodSupported, 566 onCurrencyChanged: () => actions.handleEstimateShipping(null) 567 } 568 ), 569 countsAgainstCap && /* @__PURE__ */ jsxRuntimeExports.jsx(CapLimitBanner, { cap: "orders", action: "crear más", className: "mb-4" }), 570 /* @__PURE__ */ jsxRuntimeExports.jsx( 571 Button$1, 572 { 573 formikErrors: props.errors, 574 formikErrorFieldLabels: errorFieldLabels, 575 id: "create-order-btn", 576 className: "save-btn", 577 border: "square", 578 idIntl: `Orders.${orderMode}.order.button`, 579 type: "secondary", 580 isLoading: data.createOrderLoading, 581 onClick: () => actions.handleClickCreateOrder(props), 582 disabled: !props.isValid || capBlocked || (cartItems ?? []).length === 0 || data.estimateShippingLoading || data.isLoadingAction || !data.isPaymentMethodSupported || ((_b = props.values.shipping.shippingCarrier.extra) == null ? void 0 : _b.errorMessage) 583 } 584 ),
585 /* @__PURE__ */ jsxRuntimeExports.jsx( 586 ConfirmModal, 587 { 588 idIntl: `Orders.${orderMode}.modal.description`, 589 type: "warning", 590 isOpen: data.isConfirmModalOpened, 591 onClose: () => actions.setIsConfirmModalOpened(false), 592 onSuccess: () => actions.handleOnSuccessModal(props), 593 children: editOrderId ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ 594 /* @__PURE__ */ jsxRuntimeExports.jsx( 595 Typography, 596 { 597 className: "text-center text-yellow-600 font-bold max-w-[300px]", 598 idIntl: "Orders.edit.modal.warning", 599 variant: "smallText", 600 as: "p" 601 } 602 ), 603 ((_c = data.editOrder) == null ? void 0 : _c.channelId) && /* @__PURE__ */ jsxRuntimeExports.jsx( 604 Typography, 605 { 606 className: "mt-3 text-center text-red-500 font-bold max-w-[300px]", 607 idIntl: "Orders.edit.modal.channelWarning", 608 idIntlValues: { 609 channel: `${channelUpper}` 610 }, 611 variant: "smallText", 612 as: "p" 613 } 614 ) 615 ] }) : "" 616 } 617 ),
618 data.isSuccessModalOpened && /* @__PURE__ */ jsxRuntimeExports.jsx( 619 OrderCreatedModal, 620 { 621 paylink: data.newPaylink, 622 newOrderId: data.newOrderId, 623 newOrder: data.newOrder, 624 selectedPaymentMethod: data.paymentMethod, 625 onCloseOrContinue: () => actions.handleResetData(props), 626 onCreateNewOrder: () => actions.handleResetData(props), 627 onViewOrderDetails: () => actions.handleRedirectToNewOrderDetails() 628 } 629 ), 630 actions.renderSaveDraftModal({ 631 orderForm: props.values 632 }) 633 ] }) 634 ] 635 } 636 ), 637 (editOrderId || cloneOrderId) && /* @__PURE__ */ jsxRuntimeExports.jsxs(Modal, { isOpen: !((_d = data.editOrder) == null ? void 0 : _d.step1Ready), children: [ 638 ((_e = data.editOrder) == null ? void 0 : _e.step1Init) && /* @__P
638URE__ */ jsxRuntimeExports.jsx("div", { className: "py-2 min-w-[18.75rem]", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ProgressBar, { percentage: cartBatchProgress }) }), 639 !((_f = data.editOrder) == null ? void 0 : _f.step1Init) && /* @__PURE__ */ jsxRuntimeExports.jsx( 640 EditItems, 641 { 642 onContinue: () => data.editOrder.setStep1Init(true), 643 onCancel: () => navigate( 644 `${DASHBOARD}/${ORDERS}/${DETAIL}/${editOrderId || cloneOrderId}?page=1` 645 ) 646 } 647 ) 648 ] }) 649 ] }) 650 ] }); 651 } 652 } 653 ) }); 654}; 655const import_2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ 656 __proto__: null, 657 default: CreateOrder 658}, Symbol.toStringTag, { value: "Module" })); 659const configValuesImported = [ 660 { 661 configName: "onRenderClient", 662 importPath: "/src/renderer/+onRenderClient.tsx", 663 isValueFile: true, 664 exportValues: import_0 665 }, 666 { 667 configName: "Layout", 668 importPath: "/src/pages/dashboard/+Layout.tsx", 669 isValueFile: true, 670 exportValues: import_1 671 }, 672 { 673 configName: "Page", 674 importPath: "/src/pages/dashboard/orders/create/+Page.tsx", 675 isValueFile: true, 676 exportValues: import_2 677 } 678]; 679const configValuesSerialized = { 680 ["onBeforeRenderEnv"]: { 681 valueSerialized: "null", 682 type: "computed", 683 definedAtData: null 684 }, 685 ["dataEnv"]: { 686 valueSerialized: "null", 687 type: "computed", 688 definedAtData: null 689 }, 690 ["hydrationCanBeAborted"]: { 691 valueSerialized: "true", 692 type: "classic", 693 definedAtData: { "filePathToShowToUser": "/src/pages/dashboard/+config.h.ts", "fileExportPathToShowToUser": ["default", "hydrationCanBeAborted"] } 694 } 695}; 696export { 697 configValuesImported, 698 configValuesSerialized 699};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.