@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 +1 -1
- package/templates/storefront-bakery/components/product-modal.tsx +2 -2
- package/templates/storefront-bakery/package.json +1 -1
- package/templates/storefront-fashion/app/products/[slug]/product-detail.tsx +4 -2
- package/templates/storefront-fashion/package.json +1 -1
- package/templates/storefront-grocery/components/product-modal.tsx +2 -2
- package/templates/storefront-grocery/package.json +1 -1
- package/templates/storefront-restaurant/app/reservations/reservations-client.tsx +2 -2
- package/templates/storefront-restaurant/components/product-modal.tsx +2 -2
- package/templates/storefront-restaurant/package.json +1 -1
- package/templates/storefront-retail/app/products/[slug]/product-detail.tsx +4 -2
- package/templates/storefront-retail/package.json +1 -1
- package/templates/storefront-services/app/book/book-client.tsx +2 -2
- package/templates/storefront-services/components/product-modal.tsx +2 -2
- package/templates/storefront-services/package.json +1 -1
package/package.json
CHANGED
|
@@ -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 {
|
|
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
|
|
74
|
+
await addItem(p, qty, options);
|
|
75
75
|
close();
|
|
76
76
|
router.push("/cart");
|
|
77
77
|
}}
|
|
@@ -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 }) => (
|
|
@@ -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 {
|
|
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
|
|
74
|
+
await addItem(p, qty, options);
|
|
75
75
|
close();
|
|
76
76
|
router.push("/cart");
|
|
77
77
|
}}
|
|
@@ -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 {
|
|
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
|
|
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 {
|
|
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
|
|
74
|
+
await addItem(p, qty, options);
|
|
75
75
|
close();
|
|
76
76
|
router.push("/cart");
|
|
77
77
|
}}
|
|
@@ -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 }) => (
|
|
@@ -24,7 +24,7 @@ interface Slot {
|
|
|
24
24
|
*/
|
|
25
25
|
export function BookClient({ treatments }: { treatments: Product[] }) {
|
|
26
26
|
const router = useRouter();
|
|
27
|
-
const {
|
|
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
|
|
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 {
|
|
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
|
|
74
|
+
await addItem(p, qty, options);
|
|
75
75
|
close();
|
|
76
76
|
router.push("/cart");
|
|
77
77
|
}}
|