Skip to content

API: add a useTenant() hook backed by the auth context - #211

Merged
Baskarayelu merged 1 commit into
QuickLendX:mainfrom
greatest0fallt1me:feat/102-use-tenant-hook
Aug 28, 2026
Merged

Baskarayelu merged 1 commit into
QuickLendX:mainfrom
greatest0fallt1me:feat/102-use-tenant-hook

Conversation

@greatest0fallt1me

@greatest0fallt1me greatest0fallt1me commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

No multi-tenant/org concept exists in this app -- it's single-tenant-per-session, identified by the signed-in wallet's public key. `useTenant()` resolves that as the tenant, wrapping the existing `useSession()` hook (reusing its fetch/cache/error logic) rather than duplicating it.

Change

`lib/hooks/useTenant.ts`: `useTenant()` returns `{ tenantId, isAuthenticated, loading, error }`, where `tenantId` is `user.publicKey` from the session, or `null` when signed out.

Tests

Added `lib/hooks/useTenant.test.ts` (MSW, matching `useSession.test.ts`'s style): unauthenticated by default, resolves `tenantId` to the signed-in public key, and a session error doesn't get treated as authenticated.

`npx vitest run lib/hooks/useTenant.test.ts`: 3 passed. `npx tsc --noEmit` / `npx eslint` on changed files: clean.

Related to #102

This app is single-tenant-per-session (no separate org/workspace
concept), so useTenant() resolves the current tenant as the
authenticated wallet's public key, wrapping the existing useSession()
hook rather than duplicating its fetch/cache logic.
@Baskarayelu
Baskarayelu merged commit 6f0cff1 into QuickLendX:main Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants