feat(appshell): integrate @abe-kap/appshell-sdk (strangler, mock fallback)

Wire the AppShell SDK for auth/identity across the CRM, gated behind
isShellConfigured() so the existing mock portal + static demo user stay
the fallback until the Shell BFF is configured.

- providers.tsx: app-wide <AppShellProvider> (auth passed only when Supabase env set)
- next.config.ts: transpilePackages + /shell -> BFF rewrite (keeps /api/geo intact)
- login: password -> login(), social -> loginWithOAuth(), OAuth return -> completeOAuthLogin()
- register: email/password sign-ups call register() on finish
- dashboard: AuthGate bounces unauthenticated visitors; topbar shows ACE identity
- docs/APPSHELL_INTEGRATION.md, .env.local.example, .npmrc for GitHub Packages
This commit is contained in:
tanweer919
2026-07-09 20:51:17 +05:30
parent 9675bf014d
commit 1d37593102
13 changed files with 253 additions and 16 deletions
+31
View File
@@ -0,0 +1,31 @@
"use client";
import { useEffect } from "react";
import { useRouter } from "next/navigation";
import { useAuth } from "@abe-kap/appshell-sdk/react";
import { isShellConfigured } from "@/lib/appshell";
/**
* Client gate for the dashboard. When the Shell is live, an unauthenticated
* visitor is bounced to the portal; while the session is resolving we hold a
* lightweight splash. When the Shell is NOT configured this is a pass-through,
* so the existing mock demo (any login → /dashboard) keeps working unchanged.
*/
export function AuthGate({ children }: { children: React.ReactNode }) {
const router = useRouter();
const { status } = useAuth();
const shell = isShellConfigured();
useEffect(() => {
if (shell && status === "unauthenticated") router.replace("/portal/login");
}, [shell, status, router]);
if (shell && status !== "authenticated") {
return (
<div style={{ minHeight: "60vh", display: "grid", placeItems: "center", color: "var(--muted, #888)" }}>
{status === "loading" ? "Loading your workspace…" : "Redirecting to sign in…"}
</div>
);
}
return <>{children}</>;
}