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);
|
const [sessionLoading, setSessionLoading] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
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) => {
|
const { data: { subscription } } = supabase.auth.onAuthStateChange(async (event, session) => {
|
||||||
if (session) {
|
if (session) {
|
||||||
localStorage.setItem("repairit_token", session.access_token);
|
localStorage.setItem("repairit_token", session.access_token);
|
||||||
|
|
@ -84,9 +94,13 @@ export default function App() {
|
||||||
localStorage.setItem("repairit_user", JSON.stringify(userData));
|
localStorage.setItem("repairit_user", JSON.stringify(userData));
|
||||||
|
|
||||||
if (event === "SIGNED_IN") {
|
if (event === "SIGNED_IN") {
|
||||||
|
if (window.location.hostname.includes("repairit.cloud")) {
|
||||||
|
window.location.href = "https://app.repairit.cloud/dashboard";
|
||||||
|
} else {
|
||||||
window.location.href = "/dashboard";
|
window.location.href = "/dashboard";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Error al sincronizar perfil en onAuthStateChange:", err);
|
console.error("Error al sincronizar perfil en onAuthStateChange:", err);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,21 @@ export default function LandingPage() {
|
||||||
const handleSearch = (e) => {
|
const handleSearch = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (trackingId.trim()) {
|
if (trackingId.trim()) {
|
||||||
|
if (window.location.hostname.includes("repairit.cloud")) {
|
||||||
|
window.location.href = `https://tracking.repairit.cloud/seguimiento/${trackingId.trim()}`;
|
||||||
|
} else {
|
||||||
navigate(`/seguimiento/${trackingId.trim()}`);
|
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");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleContactSubmit = (e) => {
|
const handleContactSubmit = (e) => {
|
||||||
|
|
@ -102,7 +115,7 @@ export default function LandingPage() {
|
||||||
|
|
||||||
{/* Ejemplo rápido para testing */}
|
{/* Ejemplo rápido para testing */}
|
||||||
<div className="text-xs text-muted-foreground font-medium">
|
<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>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user