@kirby-tools/licensing 0.1.7 → 0.1.9
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.mjs +18 -7
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3,19 +3,25 @@ import { usePanel, useApi } from 'kirbyuse';
|
|
|
3
3
|
const TRANSLATIONS = {
|
|
4
4
|
en: {
|
|
5
5
|
"modal.info": "Thanks for purchasing {label}! Please enter your email address and order ID to activate your license.",
|
|
6
|
-
"modal.
|
|
6
|
+
"modal.fields.orderId.help": '<a href="https://app.lemonsqueezy.com/my-orders" target="_blank">Get your order number</a> from Lemon Squeezy or <a href="mailto:hello@kirby.tools">contact us</a> if you cannot find it.',
|
|
7
|
+
"modal.error.required.fields": "Email address and order ID are required",
|
|
8
|
+
"modal.error.invalid.licenseKey": "License key invalid for this plugin",
|
|
7
9
|
"activate": "Activate",
|
|
8
10
|
"activated": "Plugin activated"
|
|
9
11
|
},
|
|
10
12
|
de: {
|
|
11
13
|
"modal.info": "Dankesch\xF6n f\xFCr den Kauf von {label}! Bitte gib deine E-Mail-Adresse und Bestellnummer ein, um deine Lizenz zu aktivieren.",
|
|
12
|
-
"modal.
|
|
14
|
+
"modal.fields.orderId.help": 'Rufe die <a href="https://app.lemonsqueezy.com/my-orders" target="_blank">Bestellnummer von Lemon Squeezy ab</a> oder <a href="mailto:hello@kirby.tools">kontaktiere uns</a>, wenn du sie nicht finden kannst.',
|
|
15
|
+
"modal.error.required.fields": "E-Mail-Adresse und Bestellnummer sind notwendig",
|
|
16
|
+
"modal.error.invalid.licenseKey": "Lizenzschl\xFCssel ung\xFCltig f\xFCr dieses Plugin",
|
|
13
17
|
"activate": "Aktivieren",
|
|
14
18
|
"activated": "Plugin aktiviert"
|
|
15
19
|
},
|
|
16
20
|
fr: {
|
|
17
21
|
"modal.info": "Merci d'avoir achet\xE9 {label} ! Veuillez saisir votre adresse e-mail et votre num\xE9ro de commande pour activer votre licence.",
|
|
18
|
-
"modal.
|
|
22
|
+
"modal.fields.orderId.help": 'Obtenez votre num\xE9ro de commande sur <a href="https://app.lemonsqueezy.com/my-orders" target="_blank">Lemon Squeezy</a> ou <a href="mailto:hello@kirby.tools">contactez-nous</a> si vous ne le trouvez pas.',
|
|
23
|
+
"modal.error.required.fields": "Adresse e-mail et num\xE9ro de commande requis",
|
|
24
|
+
"modal.error.invalid.licenseKey": "Cl\xE9 de licence invalide pour ce plugin",
|
|
19
25
|
"activate": "Activer",
|
|
20
26
|
"activated": "Plugin activ\xE9"
|
|
21
27
|
}
|
|
@@ -56,7 +62,7 @@ function useLicense({
|
|
|
56
62
|
return true;
|
|
57
63
|
};
|
|
58
64
|
const openLicenseModal = () => {
|
|
59
|
-
|
|
65
|
+
let isRegistered = false;
|
|
60
66
|
return new Promise((resolve) => {
|
|
61
67
|
panel.dialog.open({
|
|
62
68
|
component: "k-form-dialog",
|
|
@@ -78,7 +84,7 @@ function useLicense({
|
|
|
78
84
|
orderId: {
|
|
79
85
|
label: "Order ID",
|
|
80
86
|
type: "text",
|
|
81
|
-
help: t("modal.
|
|
87
|
+
help: t("modal.fields.orderId.help", { label })
|
|
82
88
|
}
|
|
83
89
|
}
|
|
84
90
|
},
|
|
@@ -90,15 +96,20 @@ function useLicense({
|
|
|
90
96
|
submit: async (event) => {
|
|
91
97
|
const { email, orderId } = event;
|
|
92
98
|
if (!email || !orderId) {
|
|
93
|
-
panel.notification.error("
|
|
99
|
+
panel.notification.error(t("modal.error.required.fields"));
|
|
94
100
|
return;
|
|
95
101
|
}
|
|
96
102
|
try {
|
|
97
103
|
await register(email, Number(orderId));
|
|
98
104
|
} catch (error) {
|
|
99
|
-
|
|
105
|
+
let message = error.message;
|
|
106
|
+
if (message === "License key not valid for this plugin") {
|
|
107
|
+
message = t("modal.error.invalid.licenseKey");
|
|
108
|
+
}
|
|
109
|
+
panel.notification.error(message);
|
|
100
110
|
return;
|
|
101
111
|
}
|
|
112
|
+
isRegistered = true;
|
|
102
113
|
panel.dialog.close();
|
|
103
114
|
panel.notification.success(t("activated"), { label });
|
|
104
115
|
}
|
package/package.json
CHANGED