diff --git a/src/components/settings/LicenseCard.tsx b/src/components/settings/LicenseCard.tsx index c502aa5..021db1f 100644 --- a/src/components/settings/LicenseCard.tsx +++ b/src/components/settings/LicenseCard.tsx @@ -2,7 +2,7 @@ import { useState, useEffect, useCallback } from "react"; import { useTranslation } from "react-i18next"; import { openUrl } from "@tauri-apps/plugin-opener"; import { KeyRound, CheckCircle, AlertCircle, Loader2, ExternalLink, Monitor, ChevronDown, ChevronUp } from "lucide-react"; -import { useLicense } from "../../hooks/useLicense"; +import { useLicenseContext } from "../../contexts/LicenseContext"; import { MachineInfo, ActivationStatus, @@ -16,7 +16,8 @@ const PURCHASE_URL = "https://lacompagniemaximus.com/simpl-resultat"; export default function LicenseCard() { const { t } = useTranslation(); - const { state, submitKey } = useLicense(); + const { status: licenseStatus, edition, info, error, validating, validationError, submitKey } = + useLicenseContext(); const [keyInput, setKeyInput] = useState(""); const [showInput, setShowInput] = useState(false); const [showMachines, setShowMachines] = useState(false); @@ -26,7 +27,7 @@ export default function LicenseCard() { const [deactivatingId, setDeactivatingId] = useState(null); const [machineError, setMachineError] = useState(null); - const hasLicense = state.edition !== "free"; + const hasLicense = edition !== "free"; const loadActivation = useCallback(async () => { if (!hasLicense) return; @@ -108,7 +109,7 @@ export default function LicenseCard() { return new Date(timestamp * 1000).toLocaleDateString(); }; - const editionLabel = t(`license.editions.${state.edition}`); + const editionLabel = t(`license.editions.${edition}`); return (
@@ -124,25 +125,25 @@ export default function LicenseCard() {

{editionLabel} - {state.edition !== "free" && ( + {edition !== "free" && ( )}

- {state.info && state.info.expires_at > 0 && ( + {info && info.expires_at > 0 && (

{t("license.expiresAt")}

-

{formatExpiry(state.info.expires_at)}

+

{formatExpiry(info.expires_at)}

)} - {state.status === "error" && state.error && ( + {licenseStatus === "error" && error && (
-

{state.error}

+

{error}

)} @@ -155,7 +156,7 @@ export default function LicenseCard() { > {t("license.enterKey")} - {state.edition === "free" && ( + {edition === "free" && (