Skip to content

Commit

Permalink
hjkh
Browse files Browse the repository at this point in the history
  • Loading branch information
neerajrekwar committed Aug 24, 2024
1 parent 0ac4494 commit 7ac3b5e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 22 deletions.
40 changes: 28 additions & 12 deletions app/components/AdminLocation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React, { useEffect, useState } from "react";
import axios from "axios";

interface Location {
interface LocationData {
city: string;
region: string;
country: string;
Expand All @@ -12,7 +12,7 @@ interface Location {
}

const AdminLocation: React.FC = () => {
const [location, setLocation] = useState<Location | null>(null);
const [location, setLocation] = useState<LocationData | null>(null);
const [error, setError] = useState<string | null>(null);

const adminLocation = {
Expand All @@ -24,24 +24,40 @@ const AdminLocation: React.FC = () => {
const fetchLocation = async () => {
try {
const response = await axios.get("https://ipapi.co/json/");
const { latitude, longitude, city, region, country_name: country } = response.data;
console.log("Response data:", response.data);

const {
latitude,
longitude,
city,
region,
country_name: country,
} = response.data;

const userLatitude = parseFloat(latitude);
const userLongitude = parseFloat(longitude);

console.log("User Latitude:", userLatitude);
console.log("User Longitude:", userLongitude);

if (
parseFloat(latitude) === adminLocation.latitude &&
parseFloat(longitude) === adminLocation.longitude
userLatitude.toFixed(2) === adminLocation.latitude.toFixed(2) &&
userLongitude.toFixed(2) === adminLocation.longitude.toFixed(2)
) {
setLocation({
city,
region,
country,
latitude: parseFloat(latitude),
longitude: parseFloat(longitude),
latitude: userLatitude,
longitude: userLongitude,
});
console.log("Admin location matched!");
} else {
setLocation(null); // Set to null if location doesn't match
setLocation(null);
console.log("Location does not match admin location.");
}
} catch (error) {
console.error(error);
console.error("Error fetching location:", error);
setError("Failed to fetch location data");
}
};
Expand All @@ -56,15 +72,15 @@ const AdminLocation: React.FC = () => {
) : location ? (
<div>
<h2 className="text-lg">Admin Location</h2>
<p className="ml-1">
<p>
{location.city}, {location.region}, {location.country}
</p>
<p className="ml-1">
<p>
Latitude: {location.latitude}, Longitude: {location.longitude}
</p>
</div>
) : (
<p>Loading...</p>
<p>Loading or not an admin location...</p>
)}
</div>
);
Expand Down
20 changes: 10 additions & 10 deletions app/contact/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,23 @@ const ContactPage: React.FC = () => {
{/* <CurrentTime />{" "} */}
</li>
admin &#9679; <CurrentTime/>

</ul>
</div>
<section className="">
<div className="max-w-6xl justify-center lg:h-[87vh] m-auto rounded-xl border-rose-600 sm:flex sm:border-rose-600 md:border-blue-400 gap-2 lg:w-[70%] lg:flex-1 lg:border-yellow-500">
<div className="basis-1/2 backdrop-filter-sm flex flex-col justify-between border-four md:w-[40%] p-2 aspect-square bg-[#242424] rounded-xl m-2">
<h1 className="md:text-3xl text-4xl font-medium tracking-tight md:text-7xl text-four font-bold mb-6">
<div className="basis-1/2 backdrop-blur-sm flex flex-col justify-between border-four md:w-[40%] p-2 aspect-square bg-seven rounded-xl m-2">
<h1 className="md:text-3xl text-4xl font-medium tracking-tight md:text-7xl text-secondary font-bold mb-6">
Facilis blanditiis impedit atque.
</h1>
<div className="rounded-xl bg-seven p-2 ">
<p className=" bg-gradient-to-br from-five via-four to-four py-4 bg-clip-text text-transparent">
Nothing could be awesome until you think an idea for talk about
something amazing!
<div className="rounded-xl overflow-hidden bg-[url('https://images.unsplash.com/photo-1724373506008-ab646f67067c?q=80&w=1563&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D')] relative h-44 w-full bg-cover bg-no-repeat bg-bottom ">
<p className="z-10 text-sm text-five p-2 bg-seven backdrop-blur-sm">
Nothing could be awesome until you think an idea, sustaiable
</p>
</div>
<div className="text-four p-1 justify-between flex-col flex ">
<h4 className="font-semibold">admin Info</h4>
<div className="flex text-yellow-600 text-xs justify-between">
<div className="flex text-five text-xs justify-between">
<p className=" border-five">New Delhi & Dwarka.</p>
<p>Hin &#9679; Eng &#9679; Sanskrit </p>
<AdminWeather />
Expand All @@ -100,8 +100,8 @@ const ContactPage: React.FC = () => {

</div>

<div className="basis-2/2 text-blue-200 border-four md:w-[60%] aspect-square bg-gradient-to-r from-seven rounded-xl m-2 bg-secondary p-2 sm:w-[60%]">
<h6 className="mb-2 p-2 bg-gradient-to-br from-five via-four to-four py-4 bg-clip-text text-xl font-semibold md:text-4xl md:font-medium tracking-tight text-transparent">
<div className="basis-2/2 text-primary bg-secondary border-four md:w-[60%] aspect-square bg-gradient-to-r from-seven rounded-xl m-2 p-2 sm:w-[60%]">
<h6 className="mb-2 p-2 text-four text-xl font-semibold md:text-4xl md:font-medium tracking-tight ">
&#9679; Reach at me
</h6>

Expand All @@ -126,7 +126,7 @@ const ContactPage: React.FC = () => {
onChange={handleChange}
placeholder="Enter your name"
required
className="mt-1 border-input bg-[#ffffff0a] ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring focus-visible:ring-2 flex h-10 w-full rounded border-none px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus:bg-seven disabled:cursor-not-allowed disabled:opacity-50 focus:ring-four focus:border-four"
className="mt-1 border border-input bg-[#ffffff0a] ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring focus-visible:ring-2 flex h-10 w-full rounded border-none px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus:bg-seven disabled:cursor-not-allowed disabled:opacity-50 focus:ring-four focus:border-four"
/>
</div>
<div className="p-2">
Expand Down

0 comments on commit 7ac3b5e

Please sign in to comment.