@kirby-tools/licensing 0.1.4 → 0.1.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/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
@@ -56,48 +56,53 @@ function useLicense({
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
+ return;
93
+ }
94
+ try {
95
+ await register(email, Number(orderId));
96
+ } catch (error) {
97
+ panel.notification.error(error.message);
98
+ return;
99
+ }
100
+ panel.dialog.close();
101
+ panel.notification.success(t("activated"), { label });
102
+ resolve({ isRegistered: true });
95
103
  }
96
- panel.dialog.close();
97
- await panel.view.reload();
98
- panel.notification.success(t("activated"), { label });
99
104
  }
100
- }
105
+ });
101
106
  });
102
107
  };
103
108
  return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kirby-tools/licensing",
3
3
  "type": "module",
4
- "version": "0.1.4",
4
+ "version": "0.1.6",
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>",