From a94c23c20eff98977376a1bfccc211fd4a019a79 Mon Sep 17 00:00:00 2001 From: abhishek Date: Tue, 8 Sep 2026 19:20:42 +0530 Subject: [PATCH] profile name change --- src/api/tenants.ts | 18 ++++++++++ src/api/types.ts | 4 +++ .../nearle-admin/pages/OnboardTenantPage.tsx | 18 ++++++++++ .../store-admin/pages/ShopProfilePage.tsx | 33 +++++++++++++++---- 4 files changed, 67 insertions(+), 6 deletions(-) diff --git a/src/api/tenants.ts b/src/api/tenants.ts index 2be96fa..a0c8352 100644 --- a/src/api/tenants.ts +++ b/src/api/tenants.ts @@ -9,6 +9,21 @@ export interface CreateTenantRequest { companyname: string; primarycontact: string; primaryemail: string; + /** + * Who runs the shop — `tenants.firstname`. + * + * Asked here because here is the only moment it can be asked. The primary + * branch and the merchant's own admin login are both created inside + * `CreateTenantUser`'s transaction, and the login is copied from the tenant + * row — so a name given now names the business AND the account that will + * sign in. Left out, both are blank, which is what every merchant on the + * platform currently has: the store profile prints "—" for Store admin and + * the account carries no person's name at all. + * + * One field, not two: `tenants` has a `firstname` column and no + * `lastname`, so this is the whole name. + */ + firstname?: string; locationname: string; categoryid: number; subcategoryid?: number; @@ -200,6 +215,9 @@ function toTenantBody(form: CreateTenantRequest): Record { companyname: form.companyname, primaryemail: form.primaryemail, primarycontact: form.primarycontact, + // Written to `tenants.firstname` and copied onto the admin login the same + // transaction creates — see the note on the field. + firstname: (form.firstname ?? '').trim(), categoryid: form.categoryid, subcategoryid: form.subcategoryid ?? 0, address: form.address, diff --git a/src/api/types.ts b/src/api/types.ts index fdb557a..92bcad8 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -109,6 +109,10 @@ export interface TenantInfo { approved?: number; moduleid?: number; subcategoryname?: string; + /** The app category by name — "Daily Needs", not "Category 2". */ + categoryname?: string; + /** When the merchant was created. Not returned before Sept 2026. */ + created?: string; firstname?: string; lastname?: string; /** Capitalised on the wire. */ diff --git a/src/features/nearle-admin/pages/OnboardTenantPage.tsx b/src/features/nearle-admin/pages/OnboardTenantPage.tsx index 8991b7a..b13a955 100644 --- a/src/features/nearle-admin/pages/OnboardTenantPage.tsx +++ b/src/features/nearle-admin/pages/OnboardTenantPage.tsx @@ -20,6 +20,8 @@ import { useAppCategories } from '@/queries/hooks'; interface FormState { tenantname: string; companyname: string; + /** Who runs the shop. Written to `tenants.firstname` — see `CreateTenantRequest`. */ + adminname: string; primarycontact: string; primaryemail: string; locationname: string; @@ -34,6 +36,7 @@ interface FormState { const EMPTY: FormState = { tenantname: '', companyname: '', + adminname: '', primarycontact: '', primaryemail: '', locationname: '', @@ -94,6 +97,7 @@ export function OnboardTenantPage() { const isComplete = form.tenantname.trim() !== '' && form.companyname.trim() !== '' && + form.adminname.trim() !== '' && form.primarycontact.trim() !== '' && form.primaryemail.trim() !== '' && form.locationname.trim() !== '' && @@ -109,6 +113,7 @@ export function OnboardTenantPage() { mutation.mutate({ tenantname: form.tenantname.trim(), companyname: form.companyname.trim(), + firstname: form.adminname.trim(), primarycontact: form.primarycontact.trim(), primaryemail: form.primaryemail.trim(), locationname: form.locationname.trim(), @@ -193,6 +198,19 @@ export function OnboardTenantPage() { onChange={set('companyname')} placeholder="e.g. Kaveri Retail Pvt. Ltd." /> + {/* Asked here because here is the only place it can be asked. + The primary outlet and the merchant's own admin login are + both created inside this one call, and the login is copied + from the tenant row — so the name given here names the + business AND the account that signs in. Left out, both are + blank, which is the state every merchant is in today. */} + Store admin * as any} + value={form.adminname} + onChange={set('adminname')} + placeholder="e.g. Ravi Kumar" + description="The person who administers this shop. Their name goes on the store profile and on the admin login created with it — the account is provisioned as Admin, which is what this field is named after." + /> Primary phone * as any} value={form.primarycontact} diff --git a/src/features/store-admin/pages/ShopProfilePage.tsx b/src/features/store-admin/pages/ShopProfilePage.tsx index f665bf6..22f8852 100644 --- a/src/features/store-admin/pages/ShopProfilePage.tsx +++ b/src/features/store-admin/pages/ShopProfilePage.tsx @@ -33,8 +33,9 @@ * Two things the design asks for do not exist behind it, and are shown as * absent rather than invented: a separate TRADE LICENCE (the `tenants` table * has one licence column, `licenseno`, which is where FSSAI goes), and a store - * manager (`firstname`, `lastname` and `Accountname` come back empty for every - * merchant read so far). `created` does exist and is now returned — the column + * admin (`tenants.firstname` — there is no lastname column — which was + * collected by no form and permitted by no allowlist until now, so it is empty + * on every merchant created before this). `created` does exist and is now returned — the column * was always there and the endpoint simply never selected it. */ @@ -77,6 +78,7 @@ type CardId = 'basic' | 'contact' | 'licence' | 'more'; /** Every field this page may write, so a save cannot send anything else. */ const EDITABLE = [ 'tenantname', + 'firstname', 'tenanttype', 'primarycontact', 'primaryemail', @@ -95,7 +97,7 @@ const EDITABLE = [ type Editable = (typeof EDITABLE)[number]; const CARD_FIELDS: Record = { - basic: ['tenantname', 'tenanttype'], + basic: ['tenantname', 'firstname', 'tenanttype'], contact: ['primarycontact', 'primaryemail', 'address', 'suburb', 'city', 'state', 'postcode'], licence: ['licenseno'], more: ['tenantinfo', 'minorder', 'registrationno'], @@ -262,7 +264,7 @@ export function ShopProfilePage() { + {/* `tenants.firstname`, and there is no lastname column — so + this is the whole name. Collected at onboarding from now + on; editable here because every merchant created before + that has it empty. */} + + + @@ -591,7 +607,12 @@ export function ShopProfilePage() {