Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-02-01 03:51:00 +00:00
parent 4292c62ad1
commit 15aecb3795
4 changed files with 35 additions and 23 deletions

File diff suppressed because one or more lines are too long

2
dist/index.html vendored
View File

@@ -5,7 +5,7 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Siti Plugin Repo</title> <title>Siti Plugin Repo</title>
<script type="module" crossorigin src="/assets/index-B996h0A2.js"></script> <script type="module" crossorigin src="/assets/index-Ciepux24.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CFgb3VsA.css"> <link rel="stylesheet" crossorigin href="/assets/index-CFgb3VsA.css">
</head> </head>

View File

@@ -390,7 +390,10 @@ app.post("/api/licenses/verify", async (req, res) => {
const result = await touchLicenseHostname(license, hostname, { pluginVersion }); const result = await touchLicenseHostname(license, hostname, { pluginVersion });
if (!result.ok) { if (!result.ok) {
const status = result.conflict ? 403 : 400; const status = result.conflict ? 403 : 400;
return res.status(status).json({ valid: false, error: result.error, boundHostname: license.primary_hostname }); const payload = await buildLicensePayload(license);
return res
.status(status)
.json({ valid: false, error: result.error, boundHostname: license.primary_hostname, license: payload });
} }
const freshLicense = await getLicenseById(license.id); const freshLicense = await getLicenseById(license.id);

View File

@@ -274,11 +274,13 @@ export default function LicenseManager() {
}) })
}); });
const data = await response.json().catch(() => ({})); const data = await response.json().catch(() => ({}));
if (!response.ok) { const statusPayload = {
throw new Error(data.error || "Controle mislukt."); ok: response.ok,
} data,
setVerifyStatus({ ok: true, data }); message: response.ok ? null : data.error || "Controle mislukt."
if (data.license) { };
setVerifyStatus(statusPayload);
if (response.ok && data.license) {
setLicenses((prev) => prev.map((license) => (license.key === data.license.key ? data.license : license))); setLicenses((prev) => prev.map((license) => (license.key === data.license.key ? data.license : license)));
} }
} catch (err) { } catch (err) {
@@ -454,9 +456,11 @@ export default function LicenseManager() {
{verifying ? "Controleren…" : "Controleer licentie"} {verifying ? "Controleren…" : "Controleer licentie"}
</button> </button>
</form> </form>
{verifyStatus && verifyStatus.ok && verifyStatus.data?.license && ( {verifyStatus?.data?.license && (
<div className="state success inline"> <div
<strong>Licentie geldig</strong> className={`state inline ${verifyStatus.ok ? "success" : ""}`.trim()}
>
<strong>{verifyStatus.ok ? "Licentie geldig" : "Plugin informatie"}</strong>
<p>{verifyStatus.data.license.pluginName || "Plugin"}</p> <p>{verifyStatus.data.license.pluginName || "Plugin"}</p>
<p> <p>
Huidige versie:{" "} Huidige versie:{" "}
@@ -474,9 +478,14 @@ export default function LicenseManager() {
Gekoppeld aan:{" "} Gekoppeld aan:{" "}
<strong>{verifyStatus.data.license.primaryHostname || "Nog niet gekoppeld"}</strong> <strong>{verifyStatus.data.license.primaryHostname || "Nog niet gekoppeld"}</strong>
</p> </p>
{!verifyStatus.ok && (
<p className="hint">
Licentie is ongeldig; downloaden blijft geblokkeerd.
</p>
)}
</div> </div>
)} )}
{verifyStatus && !verifyStatus.ok && ( {verifyStatus && !verifyStatus.ok && verifyStatus.message && (
<div className="state error inline">{verifyStatus.message}</div> <div className="state error inline">{verifyStatus.message}</div>
)} )}
</article> </article>