Add Super Admin login routing and wire tenant onboarding to auto-create a location

super_admin is now a real LoginRole, derived from the server's
issuperadmin flag (not a client-guessable roleid) — routes exclusively
to a new minimal SuperAdminPage, never the merchant console.

That page reuses the existing tenant/store/rider onboarding wizard
(AdminConsole) rather than duplicating it — its Tenant tab was already
calling the right composite endpoint but had nowhere to send location
data, and was never actually reachable from anywhere in the app. Now
it collects a primary outlet name + business category and sends a
nested tenantlocations object, so one submit provisions tenant +
active location + admin user instead of leaving the tenant
locationless. createTenantUser also moves off the mob API base onto
the web one, matching where this is actually called from.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Suriya
2026-07-16 20:46:07 +05:30
parent 186546f1fe
commit ecbae9d8fc
5 changed files with 143 additions and 9 deletions

View File

@@ -0,0 +1,45 @@
/**
* @license
* SPDX-License-Identifier: Apache-2.0
*/
/**
* Exclusive landing page for issuperadmin logins — a platform operator, not
* scoped to any tenant. Deliberately minimal: no sidebar, no merchant nav,
* just the shared Header (for logout) and the existing tenant/store/rider
* onboarding wizard (AdminConsole), which until now was only reachable
* scoped to a single tenant's own Settings page.
*/
import React from 'react';
import { Routes, Route, Navigate } from 'react-router-dom';
import Header from './Header';
import AdminConsole from './AdminConsole';
import type { AuthUser } from '../services/auth';
interface SuperAdminPageProps {
user: AuthUser;
onLogout: () => void;
}
export default function SuperAdminPage({ user, onLogout }: SuperAdminPageProps) {
const profile = { name: user.name, role: 'Super Admin', email: user.email };
return (
<div className="min-h-screen bg-slate-50 flex flex-col">
<Header
isSidebarOpen={false}
onToggleSidebar={() => {}}
onHelpClick={() => {}}
onLogoutClick={onLogout}
profile={profile}
/>
<main className="flex-1 p-4 md:p-6">
<Routes>
<Route path="onboarding" element={<AdminConsole showHeader />} />
<Route path="*" element={<Navigate to="onboarding" replace />} />
</Routes>
</main>
</div>
);
}