@plentymarkets/shop-core 1.7.4 → 1.8.1
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/README.md
CHANGED
|
@@ -20,26 +20,23 @@ npx nuxi module add @plentymarkets/shop-core
|
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
# Install dependencies
|
|
23
|
-
|
|
23
|
+
npm install
|
|
24
24
|
|
|
25
25
|
# Generate type stubs
|
|
26
|
-
|
|
26
|
+
npm run dev:prepare
|
|
27
27
|
|
|
28
28
|
# Develop with the playground
|
|
29
|
-
|
|
29
|
+
npm run dev
|
|
30
30
|
|
|
31
31
|
# Build the playground
|
|
32
|
-
|
|
32
|
+
npm run dev:build
|
|
33
33
|
|
|
34
34
|
# Run ESLint
|
|
35
|
-
|
|
35
|
+
npm run lint
|
|
36
36
|
|
|
37
37
|
# Run Vitest
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
# Release new version
|
|
42
|
-
bun run release
|
|
38
|
+
npm run test
|
|
39
|
+
npm run test:watch
|
|
43
40
|
```
|
|
44
41
|
|
|
45
42
|
<!-- Badges -->
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -50,6 +50,11 @@ const module = defineNuxtModule({
|
|
|
50
50
|
as: "useDynamicPaymentButtons",
|
|
51
51
|
from: resolver.resolve("./runtime/composables/useDynamicPaymentButtons")
|
|
52
52
|
});
|
|
53
|
+
addImports({
|
|
54
|
+
name: "useCartStockReservation",
|
|
55
|
+
as: "useCartStockReservation",
|
|
56
|
+
from: resolver.resolve("./runtime/composables/useCartStockReservation")
|
|
57
|
+
});
|
|
53
58
|
}
|
|
54
59
|
});
|
|
55
60
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useState } from "nuxt/app";
|
|
2
|
+
import { toRefs } from "vue";
|
|
3
|
+
import { useSdk } from "./useSdk.js";
|
|
4
|
+
import { useHandleError } from "./useHandleError.js";
|
|
5
|
+
import { useNotification } from "./useNotification.js";
|
|
6
|
+
export const useCartStockReservation = () => {
|
|
7
|
+
const state = useState(`useCartStockReservation`, () => ({
|
|
8
|
+
loading: false
|
|
9
|
+
}));
|
|
10
|
+
const reserve = async () => {
|
|
11
|
+
state.value.loading = true;
|
|
12
|
+
try {
|
|
13
|
+
const { data } = await useSdk().plentysystems.doPreparePayment();
|
|
14
|
+
if (data.type === "errorCode") {
|
|
15
|
+
if (data.value) {
|
|
16
|
+
const { send } = useNotification();
|
|
17
|
+
send({
|
|
18
|
+
type: "negative",
|
|
19
|
+
message: data.value,
|
|
20
|
+
persist: true
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
} catch (error) {
|
|
27
|
+
useHandleError(error);
|
|
28
|
+
} finally {
|
|
29
|
+
state.value.loading = false;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
const unreserve = async () => {
|
|
34
|
+
state.value.loading = true;
|
|
35
|
+
try {
|
|
36
|
+
await useSdk().plentysystems.deleteBasketReservations();
|
|
37
|
+
return true;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
useHandleError(error);
|
|
40
|
+
} finally {
|
|
41
|
+
state.value.loading = false;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
...toRefs(state.value),
|
|
47
|
+
reserve,
|
|
48
|
+
unreserve
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
+
import type { Endpoints } from '@plentymarkets/shop-api';
|
|
1
2
|
/**
|
|
2
3
|
* @description Composable for using the SDK.
|
|
3
|
-
* To use it locally, add the type: { plentysystems: Endpoints }
|
|
4
4
|
*/
|
|
5
|
-
export declare const useSdk: () =>
|
|
6
|
-
plentysystems:
|
|
7
|
-
|
|
8
|
-
context: {
|
|
9
|
-
requestSender: import("@vue-storefront/sdk").RequestSender;
|
|
10
|
-
};
|
|
11
|
-
} & {
|
|
12
|
-
subscribers: {
|
|
13
|
-
'*_after': (payload: any) => void;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
}>;
|
|
5
|
+
export declare const useSdk: () => {
|
|
6
|
+
plentysystems: Endpoints;
|
|
7
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plentymarkets/shop-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "Core module for PlentyONE Shop",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@plentymarkets/shop-api": "^0.
|
|
45
|
+
"@plentymarkets/shop-api": "^0.126.0",
|
|
46
46
|
"@vue-storefront/sdk": "^3.4.1",
|
|
47
47
|
"js-sha256": "^0.11.0",
|
|
48
48
|
"mitt": "^3.0.1",
|