@eetech-commerce/cart-react 0.4.7 → 0.5.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/dist/index.d.ts CHANGED
@@ -533,6 +533,80 @@ type ShippingSelectionsResponseDto = {
533
533
  [key: string]: ShippingSelection;
534
534
  };
535
535
  };
536
+ type PartialCustomerContactDto = {
537
+ /**
538
+ * Customer email address
539
+ */
540
+ email?: string;
541
+ /**
542
+ * Customer first name
543
+ */
544
+ firstName?: string;
545
+ /**
546
+ * Customer last name
547
+ */
548
+ lastName?: string;
549
+ /**
550
+ * Primary phone number (minimum 10 characters)
551
+ */
552
+ phone?: string;
553
+ /**
554
+ * Alternative phone number (minimum 10 characters)
555
+ */
556
+ alterPhone?: string;
557
+ };
558
+ type PartialAddressDto = {
559
+ /**
560
+ * Name of the recipient
561
+ */
562
+ recipientName?: string;
563
+ /**
564
+ * Company name
565
+ */
566
+ company?: string;
567
+ /**
568
+ * First line of the address
569
+ */
570
+ line1?: string;
571
+ /**
572
+ * Second line of the address (apartment, suite, etc.)
573
+ */
574
+ line2?: string;
575
+ /**
576
+ * City name
577
+ */
578
+ city?: string;
579
+ /**
580
+ * State or province
581
+ */
582
+ state?: string;
583
+ /**
584
+ * Postal/ZIP code
585
+ */
586
+ zipcode?: string;
587
+ /**
588
+ * Three-letter country code (ISO 3166-1 alpha-3)
589
+ */
590
+ country?: string;
591
+ };
592
+ type UpdateCheckoutDto = {
593
+ /**
594
+ * Partial customer contact updates
595
+ */
596
+ customerContact?: PartialCustomerContactDto;
597
+ /**
598
+ * Partial shipping address updates (clears shipping selections)
599
+ */
600
+ shippingAddress?: PartialAddressDto;
601
+ /**
602
+ * Partial billing address updates
603
+ */
604
+ billingAddress?: PartialAddressDto;
605
+ /**
606
+ * Purchase order number (optional)
607
+ */
608
+ poNumber?: string;
609
+ };
536
610
  type PaymentSessionResponseDto = {
537
611
  /**
538
612
  * Unique payment session identifier
@@ -653,6 +727,13 @@ declare function useCreateCheckoutSession(): {
653
727
  isPending: boolean;
654
728
  error: Error | null;
655
729
  };
730
+ declare function useUpdateCheckoutSession(): {
731
+ updateCheckoutSession: (params: UpdateCheckoutDto & {
732
+ cartSessionId?: string;
733
+ }, callbacks?: MutationCallbacks<CartResponseDto>) => void;
734
+ isPending: boolean;
735
+ error: Error | null;
736
+ };
656
737
  declare function useShippingOptions(cartSessionId: string | null): _tanstack_react_query.UseQueryResult<ShippingOptionsResponse, Error>;
657
738
  interface UpdateShippingSelectionsParams {
658
739
  selections: ShippingSelectionDto[];
@@ -708,4 +789,4 @@ interface CartProviderProps {
708
789
  }
709
790
  declare function CartProvider({ children, tenantSlug, cartApiUrl, storageAdapter, autoInitialize, queryClient, }: CartProviderProps): react_jsx_runtime.JSX.Element;
710
791
 
711
- export { type CartContextValue, CartProvider, type CartProviderProps, type CartResponseDto, type CreateCheckoutDto, type CreateEmbeddedPaymentSessionDto, type EmbeddedPaymentSessionResponseDto, type LineItemResponseDto, type LoadStripeFn, type MutationCallbacks, type ShippingOptionDto, type ShippingSelectionDto, type StorageAdapter, type VerificationResultDto, cartKeys, localStorageAdapter, paymentKeys, shippingKeys, useAddToCart, useCart, useCartContext, useClearCart, useCreateCart, useCreateCheckoutSession, useCreateEmbeddedCheckoutSession, useInitializeCart, usePaymentSession, useRemoveItem, useShippingOptions, useStripePromise, useUpdateItemQty, useUpdateShippingSelections, useVerifyCart };
792
+ export { type CartContextValue, CartProvider, type CartProviderProps, type CartResponseDto, type CreateCheckoutDto, type CreateEmbeddedPaymentSessionDto, type EmbeddedPaymentSessionResponseDto, type LineItemResponseDto, type LoadStripeFn, type MutationCallbacks, type ShippingOptionDto, type ShippingSelectionDto, type StorageAdapter, type UpdateCheckoutDto, type VerificationResultDto, cartKeys, localStorageAdapter, paymentKeys, shippingKeys, useAddToCart, useCart, useCartContext, useClearCart, useCreateCart, useCreateCheckoutSession, useCreateEmbeddedCheckoutSession, useInitializeCart, usePaymentSession, useRemoveItem, useShippingOptions, useStripePromise, useUpdateCheckoutSession, useUpdateItemQty, useUpdateShippingSelections, useVerifyCart };
package/dist/index.js CHANGED
@@ -917,6 +917,16 @@ var checkoutControllerVerifyCartV1 = (options) => {
917
917
  }
918
918
  });
919
919
  };
920
+ var checkoutControllerUpdateCheckoutSessionV1 = (options) => {
921
+ return (options.client ?? client).patch({
922
+ url: "/v1/t/{tenantSlug}/checkout/{cartSessionId}",
923
+ ...options,
924
+ headers: {
925
+ "Content-Type": "application/json",
926
+ ...options.headers
927
+ }
928
+ });
929
+ };
920
930
  var checkoutControllerCreateCheckoutSessionV1 = (options) => {
921
931
  return (options.client ?? client).post({
922
932
  url: "/v1/t/{tenantSlug}/checkout/{cartSessionId}",
@@ -1082,6 +1092,19 @@ var checkoutControllerVerifyCartV1Mutation = (options) => {
1082
1092
  };
1083
1093
  return mutationOptions;
1084
1094
  };
1095
+ var checkoutControllerUpdateCheckoutSessionV1Mutation = (options) => {
1096
+ const mutationOptions = {
1097
+ mutationFn: async (fnOptions) => {
1098
+ const { data } = await checkoutControllerUpdateCheckoutSessionV1({
1099
+ ...options,
1100
+ ...fnOptions,
1101
+ throwOnError: true
1102
+ });
1103
+ return data;
1104
+ }
1105
+ };
1106
+ return mutationOptions;
1107
+ };
1085
1108
  var checkoutControllerCreateCheckoutSessionV1Mutation = (options) => {
1086
1109
  const mutationOptions = {
1087
1110
  mutationFn: async (fnOptions) => {
@@ -1468,6 +1491,35 @@ function useCreateCheckoutSession() {
1468
1491
  error: mutation.error
1469
1492
  };
1470
1493
  }
1494
+ function useUpdateCheckoutSession() {
1495
+ const { tenantSlug, cartApiUrl, cartSessionId } = useCartContext();
1496
+ const queryClient = useQueryClient2();
1497
+ const mutation = useMutation2({
1498
+ ...checkoutControllerUpdateCheckoutSessionV1Mutation(),
1499
+ onSuccess: () => {
1500
+ queryClient.invalidateQueries({ queryKey: cartKeys.all() });
1501
+ }
1502
+ });
1503
+ const updateCheckoutSession = useCallback2(
1504
+ (params, callbacks) => {
1505
+ const { cartSessionId: paramSessionId, ...body } = params;
1506
+ mutation.mutate(
1507
+ {
1508
+ path: { tenantSlug, cartSessionId: paramSessionId ?? cartSessionId },
1509
+ body,
1510
+ baseUrl: cartApiUrl
1511
+ },
1512
+ callbacks
1513
+ );
1514
+ },
1515
+ [mutation, tenantSlug, cartSessionId, cartApiUrl]
1516
+ );
1517
+ return {
1518
+ updateCheckoutSession,
1519
+ isPending: mutation.isPending,
1520
+ error: mutation.error
1521
+ };
1522
+ }
1471
1523
  function useShippingOptions(cartSessionId) {
1472
1524
  const { tenantSlug, cartApiUrl } = useCartContext();
1473
1525
  return useQuery2({
@@ -1681,6 +1733,7 @@ export {
1681
1733
  useRemoveItem,
1682
1734
  useShippingOptions,
1683
1735
  useStripePromise,
1736
+ useUpdateCheckoutSession,
1684
1737
  useUpdateItemQty,
1685
1738
  useUpdateShippingSelections,
1686
1739
  useVerifyCart
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eetech-commerce/cart-react",
3
- "version": "0.4.7",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"