@kirby-tools/licensing 0.1.3 → 0.1.5

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.mts CHANGED
@@ -2,9 +2,12 @@ interface LicenseOptions {
2
2
  label: string;
3
3
  apiNamespace: string;
4
4
  }
5
+ interface LicenseModalResult {
6
+ isRegistered?: boolean;
7
+ }
5
8
  declare function useLicense({ label, apiNamespace, }: LicenseOptions): {
6
9
  isLocalhost: boolean;
7
- openLicenseModal: () => void;
10
+ openLicenseModal: () => Promise<LicenseModalResult>;
8
11
  };
9
12
 
10
13
  export { useLicense };
package/dist/index.d.ts CHANGED
@@ -2,9 +2,12 @@ interface LicenseOptions {
2
2
  label: string;
3
3
  apiNamespace: string;
4
4
  }
5
+ interface LicenseModalResult {
6
+ isRegistered?: boolean;
7
+ }
5
8
  declare function useLicense({ label, apiNamespace, }: LicenseOptions): {
6
9
  isLocalhost: boolean;
7
- openLicenseModal: () => void;
10
+ openLicenseModal: () => Promise<LicenseModalResult>;
8
11
  };
9
12
 
10
13
  export { useLicense };
package/dist/index.mjs CHANGED
@@ -50,54 +50,61 @@ function useLicense({
50
50
  throw new Error("Email and order ID are required");
51
51
  }
52
52
  const response = await api.post(`${apiNamespace}/register`, { email, orderId });
53
- if (!response?.ok) {
53
+ if (response?.status !== "ok") {
54
54
  throw new Error("Registration failed");
55
55
  }
56
56
  return true;
57
57
  };
58
58
  const openLicenseModal = () => {
59
- panel.dialog.open({
60
- component: "k-form-dialog",
61
- props: {
62
- submitButton: {
63
- icon: "check",
64
- theme: "love",
65
- text: t("activate", { label })
66
- },
67
- fields: {
68
- info: {
69
- type: "info",
70
- text: t("modal.info", { label })
71
- },
72
- email: {
73
- label: panel.t("email"),
74
- type: "email"
59
+ return new Promise((resolve) => {
60
+ panel.dialog.open({
61
+ component: "k-form-dialog",
62
+ props: {
63
+ submitButton: {
64
+ icon: "check",
65
+ theme: "love",
66
+ text: t("activate", { label })
75
67
  },
76
- orderId: {
77
- label: "Order ID",
78
- type: "text",
79
- help: t("modal.help.orderId", { label })
80
- }
81
- }
82
- },
83
- on: {
84
- submit: async (event) => {
85
- const { email, orderId } = event;
86
- if (!email || !orderId) {
87
- panel.notification.error("Email and order ID are required");
88
- return;
68
+ fields: {
69
+ info: {
70
+ type: "info",
71
+ text: t("modal.info", { label })
72
+ },
73
+ email: {
74
+ label: panel.t("email"),
75
+ type: "email"
76
+ },
77
+ orderId: {
78
+ label: "Order ID",
79
+ type: "text",
80
+ help: t("modal.help.orderId", { label })
81
+ }
89
82
  }
90
- try {
91
- await register(email, Number(orderId));
92
- } catch (error) {
93
- panel.notification.error(error.message);
94
- return;
83
+ },
84
+ on: {
85
+ close: () => {
86
+ resolve({});
87
+ },
88
+ submit: async (event) => {
89
+ const { email, orderId } = event;
90
+ if (!email || !orderId) {
91
+ panel.notification.error("Email and order ID are required");
92
+ resolve({});
93
+ return;
94
+ }
95
+ try {
96
+ await register(email, Number(orderId));
97
+ } catch (error) {
98
+ panel.notification.error(error.message);
99
+ resolve({});
100
+ return;
101
+ }
102
+ panel.dialog.close();
103
+ panel.notification.success(t("activated"), { label });
104
+ resolve({ isRegistered: true });
95
105
  }
96
- panel.dialog.close();
97
- await panel.view.reload();
98
- panel.notification.success(t("activated"), { label });
99
106
  }
100
- }
107
+ });
101
108
  });
102
109
  };
103
110
  return {
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@kirby-tools/licensing",
3
3
  "type": "module",
4
- "version": "0.1.3",
4
+ "version": "0.1.5",
5
5
  "packageManager": "pnpm@9.3.0",
6
6
  "description": "Shared tooling for licensing in the Panel",
7
7
  "author": "Johann Schopplich <hello@johannschopplich.com>",
8
8
  "license": "MIT",
9
- "homepage": "https://github.com/kirby-tools/licensing#readme",
9
+ "homepage": "https://github.com/kirby-tools/licensing-panel#readme",
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "git+https://github.com/kirby-tools/licensing.git"
12
+ "url": "git+https://github.com/kirby-tools/licensing-panel.git"
13
13
  },
14
14
  "bugs": {
15
- "url": "https://github.com/kirby-tools/licensing/issues"
15
+ "url": "https://github.com/kirby-tools/licensing-panel/issues"
16
16
  },
17
17
  "sideEffects": false,
18
18
  "exports": {