🐛 fix(_extra): no needed files

This commit is contained in:
Eshan Roy
2024-12-08 14:33:59 +05:30
parent 47dc880bb6
commit 2d11208801

View File

@@ -1,15 +1,9 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { import { Download as DownloadIcon, Monitor, Server, HardDrive, Smartphone, Code } from 'lucide-react';
Download as DownloadIcon,
Monitor,
Server,
HardDrive,
Smartphone,
Code,
} from 'lucide-react';
export function DownloadPage() { export function DownloadPage() {
const [userLocation, setUserLocation] = useState<string | null>(null); const [userLocation, setUserLocation] = useState<string | null>(null);
const [userRegion, setUserRegion] = useState<string | null>(null); // Added userRegion to store the region
// Detect user location using a public API // Detect user location using a public API
useEffect(() => { useEffect(() => {
@@ -18,14 +12,28 @@ export function DownloadPage() {
const response = await fetch('https://ipapi.co/json/'); const response = await fetch('https://ipapi.co/json/');
const data = await response.json(); const data = await response.json();
setUserLocation(`${data.city}, ${data.country}`); setUserLocation(`${data.city}, ${data.country}`);
setUserRegion(data.country); // Store the user's country or region
} catch (error) { } catch (error) {
console.error('Failed to fetch user location:', error); console.error('Failed to fetch user location:', error);
setUserLocation(null); setUserLocation(null);
setUserRegion(null); // Ensure region is null on error
} }
} }
fetchLocation(); fetchLocation();
}, []); }, []);
// Find the closest mirror based on the user's region
const getSuggestedMirror = () => {
if (!userRegion) return null; // If region is not detected, return null
// Map userRegion to mirror data and suggest the closest region
return mirrorData.find((mirror) =>
mirror.region.toLowerCase().includes(userRegion.toLowerCase())
);
};
const suggestedMirror = getSuggestedMirror();
return ( return (
<div className="py-12"> <div className="py-12">
<div className="container mx-auto px-4"> <div className="container mx-auto px-4">
@@ -52,19 +60,6 @@ export function DownloadPage() {
perfect for home users, professionals, and enterprises. Download perfect for home users, professionals, and enterprises. Download
today to unlock the full potential of your hardware. today to unlock the full potential of your hardware.
</p> </p>
<div className="mt-8">
<ActionButton
href="#"
color="indigo"
text="Explore Editions"
/>
<ActionButton
href="#"
color="gray"
text="Read More"
className="ml-4"
/>
</div>
</div> </div>
</section> </section>
@@ -125,6 +120,14 @@ export function DownloadPage() {
<MirrorButton key={index} {...mirror} /> <MirrorButton key={index} {...mirror} />
))} ))}
</div> </div>
{suggestedMirror && (
<div className="mt-8 text-center">
<h3 className="text-2xl font-bold text-indigo-600">
Suggested Mirror for You
</h3>
<MirrorButton {...suggestedMirror} />
</div>
)}
</section> </section>
</div> </div>
</div> </div>
@@ -148,27 +151,6 @@ function FeatureBadge({
); );
} }
function ActionButton({
href,
text,
color,
className = '',
}: {
href: string;
text: string;
color: string;
className?: string;
}) {
return (
<a
href={href}
className={`px-6 py-3 bg-${color}-600 text-white text-lg font-semibold rounded-lg shadow-lg hover:bg-${color}-700 transition-colors ${className}`}
>
{text}
</a>
);
}
function EditionCard({ function EditionCard({
title, title,
description, description,