mirror of
https://github.com/dyzulk/trustlab.git
synced 2026-01-26 05:25:36 +07:00
feat: localize mirror page and open download links in new tab
This commit is contained in:
@@ -3,10 +3,12 @@
|
||||
import { Suspense, useEffect, useState } from "react";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import CommonGridShape from "@/components/common/CommonGridShape";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
function DownloadMirrorContent() {
|
||||
const t = useTranslations("DownloadMirror");
|
||||
const searchParams = useSearchParams();
|
||||
const [status, setStatus] = useState("Preparing your download...");
|
||||
const [status, setStatus] = useState(t("preparing"));
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [downloadUrl, setDownloadUrl] = useState<string | null>(null);
|
||||
|
||||
@@ -16,7 +18,7 @@ function DownloadMirrorContent() {
|
||||
const target = searchParams.get("target");
|
||||
|
||||
if (!serial) {
|
||||
setError("Missing certificate serial.");
|
||||
setError(t("missing_serial"));
|
||||
setStatus("");
|
||||
return;
|
||||
}
|
||||
@@ -38,15 +40,15 @@ function DownloadMirrorContent() {
|
||||
setDownloadUrl(url);
|
||||
|
||||
// Mirroring: Redirect to the backend download URL
|
||||
setStatus("Redirecting to download...");
|
||||
setStatus(t("redirecting"));
|
||||
window.location.href = url;
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
setStatus("Your download should have started.");
|
||||
setStatus(t("started"));
|
||||
}, 3000);
|
||||
|
||||
return () => clearTimeout(timeout);
|
||||
}, [searchParams]);
|
||||
}, [searchParams, t]);
|
||||
|
||||
return (
|
||||
<div className="relative z-1 bg-white p-6 sm:p-0 dark:bg-gray-900 flex-grow flex items-center justify-center min-h-screen">
|
||||
@@ -59,14 +61,14 @@ function DownloadMirrorContent() {
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-xl font-bold text-gray-900 dark:text-white">Download Error</h2>
|
||||
<h2 className="text-xl font-bold text-gray-900 dark:text-white">{t("error_title")}</h2>
|
||||
<p className="mt-2 text-sm text-gray-600 dark:text-gray-400">{error}</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => window.history.back()}
|
||||
className="inline-flex w-full justify-center rounded-lg bg-brand-500 px-4 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-brand-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-600"
|
||||
>
|
||||
Go Back
|
||||
{t("go_back")}
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
@@ -79,13 +81,13 @@ function DownloadMirrorContent() {
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-xl font-bold text-gray-900 dark:text-white">{status}</h2>
|
||||
<p className="text-sm text-gray-500 dark:text-gray-400 mt-2">Mirroring Download from TrustLab Trust Store</p>
|
||||
<p className="text-sm text-gray-500 dark:text-gray-400 mt-2">{t("mirroring_from")}</p>
|
||||
</div>
|
||||
|
||||
{downloadUrl && (
|
||||
<div className="pt-4 animate-in fade-in slide-in-from-bottom-4 duration-700 delay-500 fill-mode-both">
|
||||
<p className="text-sm text-gray-500 dark:text-gray-400 mb-4">
|
||||
If your download didn't start automatically,
|
||||
{t("if_not_started")}
|
||||
</p>
|
||||
<a
|
||||
href={downloadUrl}
|
||||
@@ -94,7 +96,7 @@ function DownloadMirrorContent() {
|
||||
<svg className="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
|
||||
</svg>
|
||||
klik disini untuk download manual
|
||||
{t("manual_download")}
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -401,6 +401,17 @@
|
||||
"fail_title": "Sending Failed",
|
||||
"fail_message": "An error occurred while sending. Please try again."
|
||||
},
|
||||
"DownloadMirror": {
|
||||
"preparing": "Preparing your download...",
|
||||
"redirecting": "Redirecting to download...",
|
||||
"started": "Your download should have started.",
|
||||
"error_title": "Download Error",
|
||||
"missing_serial": "Missing certificate serial.",
|
||||
"go_back": "Go Back",
|
||||
"mirroring_from": "Mirroring Download from TrustLab Trust Store",
|
||||
"if_not_started": "If your download didn't start automatically,",
|
||||
"manual_download": "click here for manual download"
|
||||
},
|
||||
"Legal": {
|
||||
"center_title": "Legal Center",
|
||||
"center_desc": "Transparency and trust are at the heart of our mission. Review our terms, policies, and compliance documents below.",
|
||||
|
||||
@@ -400,6 +400,17 @@
|
||||
"fail_title": "Pengiriman Gagal",
|
||||
"fail_message": "Terjadi kesalahan. Silakan coba lagi."
|
||||
},
|
||||
"DownloadMirror": {
|
||||
"preparing": "Menyiapkan unduhan Anda...",
|
||||
"redirecting": "Mengalihkan ke unduhan...",
|
||||
"started": "Unduhan Anda seharusnya sudah dimulai.",
|
||||
"error_title": "Kesalahan Unduhan",
|
||||
"missing_serial": "Nomor seri sertifikat tidak ditemukan.",
|
||||
"go_back": "Kembali",
|
||||
"mirroring_from": "Mirroring Unduhan dari TrustLab Trust Store",
|
||||
"if_not_started": "Jika unduhan Anda tidak dimulai secara otomatis,",
|
||||
"manual_download": "klik disini untuk download manual"
|
||||
},
|
||||
"Legal": {
|
||||
"center_title": "Pusat Legal",
|
||||
"center_desc": "Transparansi dan kepercayaan adalah inti dari misi kami. Tinjau syarat, kebijakan, dan dokumen kepatuhan kami di bawah ini.",
|
||||
|
||||
Reference in New Issue
Block a user