feat: enrutamiento inteligente por subdominios (app.repairit.cloud y tracking.repairit.cloud)
This commit is contained in:
parent
f8b1b6fd65
commit
98c99d68be
|
|
@ -29,6 +29,16 @@ export default function App() {
|
|||
const [sessionLoading, setSessionLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
// Detección inteligente de subdominio en producción
|
||||
const hostname = window.location.hostname;
|
||||
const pathname = window.location.pathname;
|
||||
|
||||
if (hostname === "app.repairit.cloud" && pathname === "/") {
|
||||
window.location.href = "/dashboard";
|
||||
} else if (hostname === "tracking.repairit.cloud" && pathname === "/") {
|
||||
window.location.href = "/seguimiento/demo-id";
|
||||
}
|
||||
|
||||
const { data: { subscription } } = supabase.auth.onAuthStateChange(async (event, session) => {
|
||||
if (session) {
|
||||
localStorage.setItem("repairit_token", session.access_token);
|
||||
|
|
@ -84,7 +94,11 @@ export default function App() {
|
|||
localStorage.setItem("repairit_user", JSON.stringify(userData));
|
||||
|
||||
if (event === "SIGNED_IN") {
|
||||
window.location.href = "/dashboard";
|
||||
if (window.location.hostname.includes("repairit.cloud")) {
|
||||
window.location.href = "https://app.repairit.cloud/dashboard";
|
||||
} else {
|
||||
window.location.href = "/dashboard";
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,20 @@ export default function LandingPage() {
|
|||
const handleSearch = (e) => {
|
||||
e.preventDefault();
|
||||
if (trackingId.trim()) {
|
||||
navigate(`/seguimiento/${trackingId.trim()}`);
|
||||
if (window.location.hostname.includes("repairit.cloud")) {
|
||||
window.location.href = `https://tracking.repairit.cloud/seguimiento/${trackingId.trim()}`;
|
||||
} else {
|
||||
navigate(`/seguimiento/${trackingId.trim()}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleDemoClick = () => {
|
||||
setTrackingId("demo-id");
|
||||
if (window.location.hostname.includes("repairit.cloud")) {
|
||||
window.location.href = "https://tracking.repairit.cloud/seguimiento/demo-id";
|
||||
} else {
|
||||
navigate("/seguimiento/demo-id");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -102,7 +115,7 @@ export default function LandingPage() {
|
|||
|
||||
{/* Ejemplo rápido para testing */}
|
||||
<div className="text-xs text-muted-foreground font-medium">
|
||||
¿Querés probar? Ingresá <span onClick={() => { setTrackingId("demo-id"); navigate("/seguimiento/demo-id"); }} className="text-primary hover:underline cursor-pointer font-bold">demo-id</span> para ver una reparación simulada.
|
||||
¿Querés probar? Ingresá <span onClick={handleDemoClick} className="text-primary hover:underline cursor-pointer font-bold">demo-id</span> para ver una reparación simulada.
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user