Compare commits

...

2 Commits

Author SHA1 Message Date
denis_ireri 34ea64c4d4 Merge pull request 'Send platform operators to the platform console after sign-in' (#9) from fix/operator-landing into main
Reviewed-on: #9
2026-10-13 15:06:36 +00:00
denis_ireri d15273e2a6 Send platform operators to the platform console after sign-in
The operator account is the owner of a placeholder business, so sign-in
landed it on that business's empty dashboard with a "Create your first
branch" nudge. Operators now land on /platform (sign-in and the root page),
the dashboard header says "Platform operator", and the nudge is hidden on
the operator's own business.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 18:04:58 +03:00
4 changed files with 26 additions and 5 deletions
+7 -3
View File
@@ -113,7 +113,8 @@ export default function AdminDashboardPage() {
} }
const scope: "global" | "branch" = selectedBranchId === "ALL" ? "global" : "branch"; const scope: "global" | "branch" = selectedBranchId === "ALL" ? "global" : "branch";
const showNoBranchesNudge = me.role === "SUPER_ADMIN" && branchesLoaded && branches.length === 0; // The operator's own business is a placeholder; don't nudge it to set up branches.
const showNoBranchesNudge = me.role === "SUPER_ADMIN" && !me.isPlatformAdmin && branchesLoaded && branches.length === 0;
return ( return (
<main className="min-h-screen bg-sand-50 pb-12"> <main className="min-h-screen bg-sand-50 pb-12">
@@ -130,7 +131,10 @@ export default function AdminDashboardPage() {
? `${me.branchName} Dashboard` ? `${me.branchName} Dashboard`
: "Branch Dashboard"} : "Branch Dashboard"}
</h1> </h1>
<p className="mt-1 text-xs text-sand-200/60">{me.name}</p> <p className="mt-1 text-xs text-sand-200/60">
{me.name}
{me.isPlatformAdmin && " · Platform operator"}
</p>
<div className="mt-2"> <div className="mt-2">
<AccountLinks /> <AccountLinks />
</div> </div>
@@ -142,7 +146,7 @@ export default function AdminDashboardPage() {
onChange={setSelectedBranchId} onChange={setSelectedBranchId}
isSuperAdmin={me.role === "SUPER_ADMIN"} isSuperAdmin={me.role === "SUPER_ADMIN"}
/> />
{me.isPlatformAdmin && ( {me.isPlatformAdmin && (
<Link href="/platform" className="tap-target flex items-center rounded-xl2 bg-gradient-to-r from-flow-500 to-flow-700 px-4 text-sm font-semibold text-depth-950 hover:opacity-90"> <Link href="/platform" className="tap-target flex items-center rounded-xl2 bg-gradient-to-r from-flow-500 to-flow-700 px-4 text-sm font-semibold text-depth-950 hover:opacity-90">
Platform Platform
</Link> </Link>
+3 -1
View File
@@ -167,7 +167,9 @@ export async function POST(req: NextRequest) {
phoneNumber: user.phoneNumber, phoneNumber: user.phoneNumber,
email: user.email, email: user.email,
}, },
redirectTo: user.role === "DELIVERY" ? "/terminal" : "/admin/dashboard", // Platform operators start on the console for every business, not on
// their own (placeholder) business's dashboard.
redirectTo: isPlatformAdmin(user) ? "/platform" : user.role === "DELIVERY" ? "/terminal" : "/admin/dashboard",
isPlatformAdmin: isPlatformAdmin(user), isPlatformAdmin: isPlatformAdmin(user),
}); });
+3 -1
View File
@@ -12,7 +12,9 @@ export default function RootPage() {
(async () => { (async () => {
try { try {
const result = await apiFetch<{ user: AuthUser }>("/api/auth/me"); const result = await apiFetch<{ user: AuthUser }>("/api/auth/me");
if (result.user.role === "DELIVERY") { if (result.user.isPlatformAdmin) {
router.replace("/platform");
} else if (result.user.role === "DELIVERY") {
router.replace("/terminal"); router.replace("/terminal");
} else { } else {
router.replace("/admin/dashboard"); router.replace("/admin/dashboard");
+13
View File
@@ -132,3 +132,16 @@ describe("moving staff between branches", () => {
expect((await move(t.owner, t.branchB)).status).toBe(404); expect((await move(t.owner, t.branchB)).status).toBe(404);
}); });
}); });
describe("where sign-in lands", () => {
it("sends the platform operator to the platform console, owners to the dashboard, cashiers to the till", async () => {
const t = await makeTenant();
await Promise.all([setPassword(t.owner, "owner-pass"), setPassword(t.cashierA, "cashier-pass")]);
expect((await json(await signIn(t.owner, "owner-pass"))).body.redirectTo).toBe("/admin/dashboard");
expect((await json(await signIn(t.cashierA, "cashier-pass"))).body.redirectTo).toBe("/terminal");
await db(() => User.updateOne({ _id: t.owner.id }, { email: "operator@aquaflow.test", platformAdmin: true }));
const operator = { ...t.owner, email: "operator@aquaflow.test" };
expect((await json(await signIn(operator, "owner-pass"))).body.redirectTo).toBe("/platform");
});
});