From 58c42d9013a4893d8ee1ef9d7ee34f94796754e5 Mon Sep 17 00:00:00 2001 From: abhishek Date: Wed, 22 Jul 2026 17:35:07 +0530 Subject: [PATCH] Fix app_users.configid mismatch blocking Staff/Rider first login UsersPanel.tsx was sending configid: 15 (Staff) / 6 (Rider) when creating users, copied from an unrelated Hasura "role config" convention. Every login call (auth.ts) queries app_users with configid: 1, so any account created with 15/6 could never be found on login and was stuck before it even reached the password-setup step. Both create paths and the CreateUserInput default now consistently use configid: 1. Also fixes getRiderLogs() calling riders/getriderlogs, which 404s since the backend only registers this route under /partners. --- src/components/UsersPanel.tsx | 10 +++++++--- src/services/fiestaApi.ts | 12 ++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/components/UsersPanel.tsx b/src/components/UsersPanel.tsx index 1db6f55..5ee7745 100644 --- a/src/components/UsersPanel.tsx +++ b/src/components/UsersPanel.tsx @@ -105,8 +105,12 @@ export default function UsersPanel({ tenantId = FIESTA_TENANT_ID, defaultNewUser // Selectable roles for the Add User modal - limited to Staff and Rider. const roleChoices = React.useMemo(() => { return [ - { id: 4, label: 'Staff', desc: 'Standard store staff duties', icon: User, configid: 15 }, - { id: 5, label: 'Rider', desc: 'Delivery fleet rider', icon: Bike, configid: 6 }, + // configid must be 1 here — it's the same app_users.configid column the + // login endpoints filter on (auth.ts hardcodes configid: 1 for every + // login attempt), not the unrelated Hasura "role config" id. Any other + // value means the account can never be found on login. + { id: 4, label: 'Staff', desc: 'Standard store staff duties', icon: User, configid: 1 }, + { id: 5, label: 'Rider', desc: 'Delivery fleet rider', icon: Bike, configid: 1 }, ]; }, []); @@ -247,7 +251,7 @@ export default function UsersPanel({ tenantId = FIESTA_TENANT_ID, defaultNewUser email: newUser.email, contactno: newUser.contactno, roleid: Number(newUser.roleid), - configid: selectedRole?.configid ?? 15, + configid: selectedRole?.configid ?? 1, // Store binding — sent exactly as the backend expects so the user is tied // to the chosen branch (tenantid + locationid + applocationid). tenantid: tenantId, diff --git a/src/services/fiestaApi.ts b/src/services/fiestaApi.ts index c8172ad..56c9030 100644 --- a/src/services/fiestaApi.ts +++ b/src/services/fiestaApi.ts @@ -943,7 +943,11 @@ export interface CreateUserInput { /** Optional — merchant_web's create form doesn't collect one. */ password?: string; roleid: number; - /** Role config (the selected role's configid) — matches merchant_web's create payload. */ + /** + * app_users.configid — the same column every login call filters on + * (auth.ts hardcodes configid: 1). Must stay 1 or the account can never + * be found on login; this is NOT the unrelated Hasura "role config" id. + */ configid?: number; /** Business module id (merchant_web sends the logged-in user's; 0 when absent). */ moduleid?: number; @@ -975,7 +979,7 @@ export async function createUser(input: CreateUserInput): Promise { dialcode: input.dialcode ?? '+91', contactno: input.contactno, roleid: input.roleid, - configid: input.configid ?? 15, + configid: input.configid ?? 1, moduleid: input.moduleid ?? 0, pin: input.pin ?? 0, address: input.address ?? '', @@ -1138,7 +1142,7 @@ export async function getRiderPeriodicLogs(opts: { ); } -/** /riders/getriderlogs?userid=&riderid=&fromdate=&todate=&tenantid=&applocationid= — +/** /partners/getriderlogs?userid=&riderid=&fromdate=&todate=&tenantid=&applocationid= — * full telemetry logs (GPS traces, events, etc.) for a rider. */ export async function getRiderLogs(opts: { userid?: number; @@ -1151,7 +1155,7 @@ export async function getRiderLogs(opts: { pagesize?: number; }): Promise { return toRows( - await fiestaGet('riders/getriderlogs', { + await fiestaGet('partners/getriderlogs', { userid: opts.userid, riderid: opts.riderid, fromdate: opts.fromdate,