@cimplify/sdk 0.44.4 → 0.44.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cimplify/sdk",
3
- "version": "0.44.4",
3
+ "version": "0.44.6",
4
4
  "description": "Cimplify Commerce SDK for storefronts",
5
5
  "keywords": [
6
6
  "cimplify",
@@ -18,7 +18,7 @@ export function ProductModal() {
18
18
  const slug = searchParams?.get("product") ?? null;
19
19
 
20
20
  const { product } = useProduct(slug ?? "", { enabled: Boolean(slug) });
21
- const { addToCart } = useCart();
21
+ const { addItem } = useCart();
22
22
 
23
23
  useEffect(() => {
24
24
  if (!slug) return;
@@ -71,7 +71,7 @@ export function ProductModal() {
71
71
  product={product}
72
72
  onClose={close}
73
73
  onAddToCart={async (p, qty, options) => {
74
- await addToCart(p.id, qty, options);
74
+ await addItem(p, qty, options);
75
75
  close();
76
76
  router.push("/cart");
77
77
  }}
@@ -11,7 +11,7 @@
11
11
  "lint": "next lint"
12
12
  },
13
13
  "dependencies": {
14
- "@cimplify/sdk": "^0.39.1",
14
+ "@cimplify/sdk": "^0.44.4",
15
15
  "next": "^16.2.4",
16
16
  "react": "^19.0.0",
17
17
  "react-dom": "^19.0.0"
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { useRouter } from "next/navigation";
4
4
  import Image from "next/image";
5
- import { ProductPage as SdkProductPage } from "@cimplify/sdk/react";
5
+ import { ProductPage as SdkProductPage, useCart } from "@cimplify/sdk/react";
6
6
  import type { Product, ProductWithDetails } from "@cimplify/sdk";
7
7
  import { StoreProductCard } from "@/components/store-product-card";
8
8
 
@@ -24,13 +24,15 @@ export function ProductDetail({
24
24
  related: Product[];
25
25
  }) {
26
26
  const router = useRouter();
27
+ const { addItem } = useCart();
27
28
 
28
29
  return (
29
30
  <>
30
31
  <SdkProductPage
31
32
  product={product}
32
33
  showRelated={false}
33
- onAddToCart={() => {
34
+ onAddToCart={async (p, qty, options) => {
35
+ await addItem(p, qty, options);
34
36
  router.push("/cart");
35
37
  }}
36
38
  renderImage={({ src, alt, className }) => (
@@ -11,7 +11,7 @@
11
11
  "lint": "next lint"
12
12
  },
13
13
  "dependencies": {
14
- "@cimplify/sdk": "^0.43.0",
14
+ "@cimplify/sdk": "^0.44.4",
15
15
  "next": "^16.2.4",
16
16
  "react": "^19.0.0",
17
17
  "react-dom": "^19.0.0"
@@ -18,7 +18,7 @@ export function ProductModal() {
18
18
  const slug = searchParams?.get("product") ?? null;
19
19
 
20
20
  const { product } = useProduct(slug ?? "", { enabled: Boolean(slug) });
21
- const { addToCart } = useCart();
21
+ const { addItem } = useCart();
22
22
 
23
23
  useEffect(() => {
24
24
  if (!slug) return;
@@ -71,7 +71,7 @@ export function ProductModal() {
71
71
  product={product}
72
72
  onClose={close}
73
73
  onAddToCart={async (p, qty, options) => {
74
- await addToCart(p.id, qty, options);
74
+ await addItem(p, qty, options);
75
75
  close();
76
76
  router.push("/cart");
77
77
  }}
@@ -11,7 +11,7 @@
11
11
  "lint": "next lint"
12
12
  },
13
13
  "dependencies": {
14
- "@cimplify/sdk": "^0.40.1",
14
+ "@cimplify/sdk": "^0.44.4",
15
15
  "next": "^16.2.4",
16
16
  "react": "^19.0.0",
17
17
  "react-dom": "^19.0.0"
@@ -15,7 +15,7 @@ const PARTY_SIZES = [2, 3, 4, 5, 6, 8, 10, 12];
15
15
  */
16
16
  export function ReservationsClient({ options }: { options: Product[] }) {
17
17
  const router = useRouter();
18
- const { addToCart } = useCart();
18
+ const { addItem } = useCart();
19
19
  const [selectedOption, setSelectedOption] = useState<Product | undefined>(options[0]);
20
20
  const [selectedDate, setSelectedDate] = useState<Date>(() => new Date());
21
21
  const [selectedSlotKey, setSelectedSlotKey] = useState<string | null>(null);
@@ -59,7 +59,7 @@ export function ReservationsClient({ options }: { options: Product[] }) {
59
59
  try {
60
60
  const when = new Date(selectedSlotKey).toLocaleString();
61
61
  const note = `Party of ${partySize} · ${when}${notes ? ` · ${notes}` : ""}`;
62
- await addToCart(selectedOption.id, 1, { notes: note });
62
+ await addItem(selectedOption, 1, { notes: note });
63
63
  router.push("/checkout");
64
64
  } catch {
65
65
  setSubmitting(false);
@@ -18,7 +18,7 @@ export function ProductModal() {
18
18
  const slug = searchParams?.get("product") ?? null;
19
19
 
20
20
  const { product } = useProduct(slug ?? "", { enabled: Boolean(slug) });
21
- const { addToCart } = useCart();
21
+ const { addItem } = useCart();
22
22
 
23
23
  useEffect(() => {
24
24
  if (!slug) return;
@@ -71,7 +71,7 @@ export function ProductModal() {
71
71
  product={product}
72
72
  onClose={close}
73
73
  onAddToCart={async (p, qty, options) => {
74
- await addToCart(p.id, qty, options);
74
+ await addItem(p, qty, options);
75
75
  close();
76
76
  router.push("/cart");
77
77
  }}
@@ -11,7 +11,7 @@
11
11
  "lint": "next lint"
12
12
  },
13
13
  "dependencies": {
14
- "@cimplify/sdk": "^0.40.1",
14
+ "@cimplify/sdk": "^0.44.4",
15
15
  "next": "^16.2.4",
16
16
  "react": "^19.0.0",
17
17
  "react-dom": "^19.0.0"
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { useRouter } from "next/navigation";
4
4
  import Image from "next/image";
5
- import { ProductPage as SdkProductPage } from "@cimplify/sdk/react";
5
+ import { ProductPage as SdkProductPage, useCart } from "@cimplify/sdk/react";
6
6
  import type { Product, ProductWithDetails } from "@cimplify/sdk";
7
7
  import { StoreProductCard } from "@/components/store-product-card";
8
8
 
@@ -24,13 +24,15 @@ export function ProductDetail({
24
24
  related: Product[];
25
25
  }) {
26
26
  const router = useRouter();
27
+ const { addItem } = useCart();
27
28
 
28
29
  return (
29
30
  <>
30
31
  <SdkProductPage
31
32
  product={product}
32
33
  showRelated={false}
33
- onAddToCart={() => {
34
+ onAddToCart={async (p, qty, options) => {
35
+ await addItem(p, qty, options);
34
36
  router.push("/cart");
35
37
  }}
36
38
  renderImage={({ src, alt, className }) => (
@@ -11,7 +11,7 @@
11
11
  "lint": "next lint"
12
12
  },
13
13
  "dependencies": {
14
- "@cimplify/sdk": "^0.39.1",
14
+ "@cimplify/sdk": "^0.44.4",
15
15
  "next": "^16.2.4",
16
16
  "react": "^19.0.0",
17
17
  "react-dom": "^19.0.0"
@@ -24,7 +24,7 @@ interface Slot {
24
24
  */
25
25
  export function BookClient({ treatments }: { treatments: Product[] }) {
26
26
  const router = useRouter();
27
- const { addToCart } = useCart();
27
+ const { addItem } = useCart();
28
28
  const [selectedTreatment, setSelectedTreatment] = useState<Product | undefined>(
29
29
  treatments[0],
30
30
  );
@@ -61,7 +61,7 @@ export function BookClient({ treatments }: { treatments: Product[] }) {
61
61
  if (!selectedTreatment || !selectedSlotKey) return;
62
62
  setSubmitting(true);
63
63
  try {
64
- await addToCart(selectedTreatment.id, 1, {
64
+ await addItem(selectedTreatment, 1, {
65
65
  notes: `Booked for ${new Date(selectedSlotKey).toLocaleString()}`,
66
66
  });
67
67
  router.push("/checkout");
@@ -18,7 +18,7 @@ export function ProductModal() {
18
18
  const slug = searchParams?.get("product") ?? null;
19
19
 
20
20
  const { product } = useProduct(slug ?? "", { enabled: Boolean(slug) });
21
- const { addToCart } = useCart();
21
+ const { addItem } = useCart();
22
22
 
23
23
  useEffect(() => {
24
24
  if (!slug) return;
@@ -71,7 +71,7 @@ export function ProductModal() {
71
71
  product={product}
72
72
  onClose={close}
73
73
  onAddToCart={async (p, qty, options) => {
74
- await addToCart(p.id, qty, options);
74
+ await addItem(p, qty, options);
75
75
  close();
76
76
  router.push("/cart");
77
77
  }}
@@ -11,7 +11,7 @@
11
11
  "lint": "next lint"
12
12
  },
13
13
  "dependencies": {
14
- "@cimplify/sdk": "^0.40.1",
14
+ "@cimplify/sdk": "^0.44.4",
15
15
  "next": "^16.2.4",
16
16
  "react": "^19.0.0",
17
17
  "react-dom": "^19.0.0"