payment gateways and plans billing and signup pages refactored

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-07 13:02:53 +00:00
parent ad1756c349
commit ad75fa031e
17 changed files with 4587 additions and 500 deletions

View File

@@ -1,5 +1,5 @@
import { useEffect, useMemo, useState } from "react";
import { Link, useNavigate } from "react-router-dom";
import { Link } from "react-router-dom";
import PageMeta from "../../components/common/PageMeta";
import SignUpFormUnified from "../../components/auth/SignUpFormUnified";
@@ -19,7 +19,6 @@ interface Plan {
}
export default function SignUp() {
const navigate = useNavigate();
const planSlug = useMemo(() => {
const params = new URLSearchParams(window.location.search);
return params.get("plan") || "";
@@ -28,38 +27,10 @@ export default function SignUp() {
const [plans, setPlans] = useState<Plan[]>([]);
const [plansLoading, setPlansLoading] = useState(true);
const [selectedPlan, setSelectedPlan] = useState<Plan | null>(null);
const [geoChecked, setGeoChecked] = useState(false);
// Check geo location and redirect PK users to /signup/pk
// Using free public API: https://api.country.is (no signup required, CORS enabled)
useEffect(() => {
const checkGeoAndRedirect = async () => {
try {
// Free public geo API - no signup required
const response = await fetch('https://api.country.is/', {
signal: AbortSignal.timeout(3000), // 3 second timeout
});
if (response.ok) {
const data = await response.json();
const countryCode = data?.country;
if (countryCode === 'PK') {
// Preserve query params when redirecting
const queryString = window.location.search;
navigate(`/signup/pk${queryString}`, { replace: true });
return;
}
}
} catch (err) {
// Silently fail - continue with global signup
console.log('Geo detection failed, using global signup');
}
setGeoChecked(true);
};
checkGeoAndRedirect();
}, [navigate]);
// NOTE: Geo detection removed per payment system refactor
// Country is now selected via dropdown in the signup form
// Payment method selection happens on /account/plans after registration
useEffect(() => {
const fetchPlans = async () => {
@@ -101,15 +72,6 @@ export default function SignUp() {
fetchPlans();
}, [planSlug]);
// Don't render until geo check is complete (prevents flash)
if (!geoChecked) {
return (
<div className="min-h-screen bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 flex items-center justify-center">
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-brand-500"></div>
</div>
);
}
return (
<>
<PageMeta