@cohostvip/cohost-react 0.2.0 → 0.2.2
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.
|
@@ -7,7 +7,13 @@ export type CohostCheckoutProviderProps = {
|
|
|
7
7
|
export type CohostCheckoutContextType = {
|
|
8
8
|
cartSessionId: string;
|
|
9
9
|
cartSession: CartSession | null;
|
|
10
|
-
joinGroup: (groupId: string) => Promise<
|
|
10
|
+
joinGroup: (groupId: string) => Promise<{
|
|
11
|
+
itemId: string | null;
|
|
12
|
+
error?: {
|
|
13
|
+
message: string;
|
|
14
|
+
status?: number;
|
|
15
|
+
};
|
|
16
|
+
}>;
|
|
11
17
|
updateItem: (offeringId: string, quantity: number, options?: any) => Promise<void>;
|
|
12
18
|
incrementItem: (offeringId: string, options?: any) => Promise<void>;
|
|
13
19
|
decrementItem: (offeringId: string) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CohostCheckoutContext.d.ts","sourceRoot":"","sources":["../../src/context/CohostCheckoutContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEzG,MAAM,MAAM,2BAA2B,GAAG;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"CohostCheckoutContext.d.ts","sourceRoot":"","sources":["../../src/context/CohostCheckoutContext.tsx"],"names":[],"m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CAAC;IAC7C,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,iBAAiB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACzE,CAAC;AAGF,eAAO,MAAM,qBAAqB,iDAAwD,CAAC;AAE3F,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CA4OxE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,QAAO,yBAIpC,CAAC"}
|
|
@@ -39,13 +39,20 @@ export const CohostCheckoutProvider = ({ cartSessionId, children, }) => {
|
|
|
39
39
|
try {
|
|
40
40
|
const updatedCart = await client.cart.joinTableCommitment(cartSessionId, groupId);
|
|
41
41
|
setCartSession(updatedCart);
|
|
42
|
-
|
|
42
|
+
const itemId = updatedCart
|
|
43
43
|
.items
|
|
44
44
|
.find((item) => item.tableCommitmentId === groupId)?.id || null;
|
|
45
|
+
return { itemId };
|
|
45
46
|
}
|
|
46
47
|
catch (error) {
|
|
47
48
|
console.error("Error joining group:", error);
|
|
48
|
-
return
|
|
49
|
+
return {
|
|
50
|
+
itemId: null,
|
|
51
|
+
error: {
|
|
52
|
+
message: error?.message || 'Failed to join group',
|
|
53
|
+
status: error?.status || error?.response?.status,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
49
56
|
}
|
|
50
57
|
};
|
|
51
58
|
const updateItem = async (itemId, quantity, options) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cohostvip/cohost-react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "React bindings for the Cohost API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -40,12 +40,13 @@
|
|
|
40
40
|
},
|
|
41
41
|
"repository": {
|
|
42
42
|
"type": "git",
|
|
43
|
-
"url": "https://github.com/cohostvip/cohost-
|
|
43
|
+
"url": "https://github.com/cohostvip/cohost-js.git",
|
|
44
|
+
"directory": "packages/react"
|
|
44
45
|
},
|
|
45
46
|
"bugs": {
|
|
46
|
-
"url": "https://github.com/cohostvip/cohost-
|
|
47
|
+
"url": "https://github.com/cohostvip/cohost-js/issues"
|
|
47
48
|
},
|
|
48
|
-
"homepage": "https://github.com/cohostvip/cohost-react",
|
|
49
|
+
"homepage": "https://github.com/cohostvip/cohost-js/tree/main/packages/react",
|
|
49
50
|
"author": "Cohost <support@cohost.vip> (https://cohost.vip)",
|
|
50
51
|
"license": "MIT",
|
|
51
52
|
"publishConfig": {
|