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