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

@@ -1015,6 +1015,18 @@ export async function updateUser(input: UpdateUserInput): Promise<Row> {
return fiestaSend<Row>('users/update', 'PUT', input);
}
export interface CreateTenantLocationPayload {
locationname: string;
email?: string;
contactno?: string;
address?: string;
suburb?: string;
city?: string;
state?: string;
postcode?: string;
applocationid?: number;
}
export interface CreateTenantInput {
tenantname: string;
companyname: string;
@@ -1027,11 +1039,15 @@ export interface CreateTenantInput {
postcode?: string;
approved?: number;
status?: string;
applocationid?: number;
categoryid?: number;
/** Auto-provisions the tenant's primary (Active) location in the same call. */
tenantlocations?: CreateTenantLocationPayload;
}
/** POST /tenants/createtenantuser — Onboard a new tenant and create their admin user. */
/** POST /tenants/createtenantuser — Onboard a new tenant, primary location, and admin user. */
export async function createTenantUser(input: CreateTenantInput): Promise<Row> {
const res = await fetch(`${FIESTA_MOB_BASE}/tenants/createtenantuser`, {
const res = await fetch(`${FIESTA_BASE}/tenants/createtenantuser`, {
method: 'POST',
headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
body: JSON.stringify(input),