Commit Graph

406 Commits

Author SHA1 Message Date
Urtzi Alfaro
bf1db7cb9e New token arch 2026-01-10 21:45:37 +01:00
Urtzi Alfaro
560c7ba86f Improve enterprise tier child tenants access 2026-01-07 16:01:19 +01:00
Urtzi Alfaro
2c1fc756a1 Improve public pages 2 2026-01-05 20:17:44 +01:00
Urtzi Alfaro
6c6be6f5a5 Improve public pages 2026-01-05 19:51:28 +01:00
Urtzi Alfaro
18627f02d4 Fix onboarding UI 2026-01-05 19:42:35 +01:00
Urtzi Alfaro
429e724a2c Improve onboarding flow 2026-01-04 21:37:44 +01:00
Urtzi Alfaro
47ccea4900 Imporve the UI 5 2026-01-03 15:55:24 +01:00
Urtzi Alfaro
db12c57b0b Imporve the UI 4 2026-01-02 22:03:25 +01:00
Urtzi Alfaro
ddf95958d2 fix demo session 3 2026-01-02 13:27:48 +01:00
Urtzi Alfaro
0a1951051f fix demo session 2 2026-01-02 12:18:46 +01:00
Urtzi Alfaro
9aee368580 fix demo issues 2026-01-01 19:56:07 +01:00
Urtzi Alfaro
93c9475239 fix UI 1 2026-01-01 19:01:33 +01:00
Urtzi Alfaro
d6728b4bd8 fix traslations 2026-01-01 14:09:59 +01:00
Urtzi Alfaro
cba55c2805 Improve UI and traslations 2026-01-01 13:36:45 +01:00
Urtzi Alfaro
007cbda598 Improve unified wizard 2 2025-12-31 07:32:29 +01:00
Urtzi Alfaro
0dc5f76938 Improve unified wizard 2025-12-30 20:51:03 +01:00
Urtzi Alfaro
c07df124fb Improve UI 2025-12-30 14:40:20 +01:00
Urtzi Alfaro
e494ea8635 Fix UI issues 2 2025-12-29 21:52:53 +01:00
Urtzi Alfaro
02f0c91a15 Fix UI issues 2025-12-29 19:33:35 +01:00
Urtzi Alfaro
c1dedfa44f Fix childer tennats 2025-12-29 17:25:20 +01:00
Urtzi Alfaro
2e7e1f5557 Add frontend alerts imporvements 2025-12-29 08:11:29 +01:00
Urtzi Alfaro
96d8576103 Add frontend loading imporvements 2 2025-12-28 22:29:27 +01:00
Urtzi Alfaro
54662dde79 Add frontend loading imporvements 2025-12-27 21:30:42 +01:00
Urtzi Alfaro
6e3a6590d6 add traslations 2 2025-12-25 20:51:03 +01:00
Urtzi Alfaro
cd85eb6c12 Add traslations 3 2025-12-25 19:52:31 +01:00
Urtzi Alfaro
8a585058ed Add traslations 2 2025-12-25 18:59:56 +01:00
Urtzi Alfaro
b95b86ee2c Add traslations 2025-12-25 18:35:37 +01:00
Urtzi Alfaro
82567b8701 Imporve testing 2025-12-24 11:25:08 +01:00
Urtzi Alfaro
bfa5ff0637 Imporve onboarding UI 2025-12-19 13:10:24 +01:00
Urtzi Alfaro
71ee2976a2 Update readmes and imporve UI 2025-12-19 09:28:36 +01:00
Urtzi Alfaro
a6ae730ef0 Add page UI imporvements 2025-12-18 22:23:16 +01:00
Urtzi Alfaro
033cdf84f0 Add traslations 2 2025-12-18 20:14:17 +01:00
Urtzi Alfaro
acb3a40844 Add traslations 2025-12-18 20:12:32 +01:00
Urtzi Alfaro
f10a2b92ea Improve onboarding 2025-12-18 13:26:32 +01:00
Urtzi Alfaro
f8591639a7 Imporve enterprise 2025-12-17 20:50:22 +01:00
Urtzi Alfaro
e3ef47b879 Fix demo session exit redirecting to unauthorized page
Clear auth store when exiting demo session to prevent unauthorized page redirect.

## Problem

When users clicked "Salir" (Exit) from the demo session, they were redirected to the unauthorized page (`/unauthorized`) instead of the demo landing page (`/demo`).

## Root Cause

The `handleExpiration()` function in DemoBanner.tsx was clearing localStorage and navigating to `/demo`, but was NOT clearing the auth store. This created an inconsistent state:

- `isDemoMode = false` (localStorage cleared)
- `demoSessionId = null` (localStorage cleared)
- `isAuthenticated = true` (auth store NOT cleared - still has demo user)

The `useHasAccess()` hook checks:
```typescript
return isAuthenticated || (isDemoMode && !!demoSessionId);
```

After clearing localStorage but not auth:
- `isAuthenticated = true` but the demo session is invalid
- `isDemoMode = false` and `demoSessionId = null`
- Result: `useHasAccess()` returns `false`

When navigating to `/demo`, the ProtectedRoute checked access and found it was `false`, redirecting to `/unauthorized`.

## Solution

Call `logout()` on the auth store before navigating to clear the demo user session completely. This ensures:
- Auth store is cleared (`isAuthenticated = false`)
- User is properly logged out from demo session
- Navigation to `/demo` succeeds without authentication check

## Additional Improvements

- Also clear `virtual_tenant_id` and `subscription_tier` from localStorage
- Updated comment to clarify navigation intent

## Files Changed

- frontend/src/components/layout/DemoBanner/DemoBanner.tsx:73-74
  - Added auth store logout before navigation
  - Added clearing of virtual_tenant_id and subscription_tier
  - Updated comment for clarity

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-17 17:37:46 +01:00
Urtzi Alfaro
6f5e8b11f6 Fix enterprise demo tenant loading race condition
Prevent loadUserTenants from being called too early for demo sessions by excluding demo mode from the authenticated user auto-load logic.

## Problem

In enterprise demo sessions, loadUserTenants() was being called BEFORE child tenants were created, resulting in only the parent tenant (1 tenant) being returned instead of all 6 tenants (parent + 5 children).

Timeline of the race condition:
- 15:37:20: Session created, parent tenant cloning started
- 15:37:21: loadUserTenants() called by first useEffect → returned 1 tenant 
- 15:37:22: Child tenants created (5 tenants)
- 15:38:03: Session status changed to 'ready'

The first useEffect (for authenticated users) triggered immediately when isAuthenticated became true, calling loadUserTenants() at 15:37:21. This happened BEFORE the session polling logic in the second useEffect could wait for status='ready' and BEFORE child tenants were created.

## Solution

Added `!isDemoMode` condition to the first useEffect that auto-loads tenants for authenticated users. This ensures demo sessions use only the special initialization logic with session status polling (second useEffect), which waits for the session to be fully ready before loading tenants.

## Files Changed

- frontend/src/stores/useTenantInitializer.ts:61
  - Added `&& !isDemoMode` to prevent early tenant loading for demo users
  - Added dependency `isDemoMode` to useEffect dependency array
  - Updated comment to clarify demo users have separate initialization

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-17 16:43:45 +01:00
Urtzi Alfaro
b715a14848 Fix Demo enterprise list 2025-12-17 16:28:58 +01:00
Urtzi Alfaro
388e27e309 Fix timing issue: Poll demo session status before loading tenants
Implemented polling mechanism to wait for demo session to be fully ready
before attempting to load tenant list.

## The Problem:

Frontend was calling GET /tenants/user/demo-user/tenants immediately after
session creation, but tenant cloning is asynchronous and takes 5-10 seconds.
This caused the API to return empty array [] even though it returned 200 OK.

## The Solution:

Added pollSessionStatus() function that:
1. Polls /api/v1/demo-sessions/{session_id}/status every 1 second
2. Waits for status to become 'ready' (max 30 seconds)
3. Only loads tenants after session is confirmed ready
4. Logs detailed status updates for debugging

## Flow (Before):

User clicks demo → Session created → API called immediately → Empty []

## Flow (After):

User clicks demo → Session created → Poll status (1s interval) →
Status: initializing → cloning_data → ready → Load tenants → Success!

## Benefits:

 No more empty tenant lists due to timing
 Clear console logs showing progress
 Handles session failures gracefully
 Timeout protection (30 seconds max)
 Works for both enterprise (6 tenants) and professional (1 tenant)

## Console Output Example:

 Session status poll 1/30: initializing
 Session status poll 2/30: cloning_data
 Session status poll 8/30: ready
 Demo session is ready!
🔄 Loading available tenants for enterprise demo...
📋 Loaded available tenants: 6

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-17 16:16:00 +01:00
Urtzi Alfaro
d98558ed97 Refactor demo session architecture: consolidate metadata into fixture files
This commit refactors the demo session architecture to consolidate all demo
configuration data into the fixture files, removing redundant metadata files.

## Changes Made:

### 1. Data Consolidation
- **Removed**: `shared/demo/metadata/demo_users.json`
- **Removed**: `shared/demo/metadata/tenant_configs.json`
- **Updated**: Merged all user data into `02-auth.json` files
- **Updated**: Merged all tenant config data into `01-tenant.json` files

### 2. Enterprise Parent Tenant Updates
- Updated owner name to "Director" (matching auth fixtures)
- Added description field matching tenant_configs.json
- Added `base_tenant_id` to all child tenant entries
- Now includes all 5 child locations (Madrid, Barcelona, Valencia, Seville, Bilbao)

### 3. Professional Tenant Updates
- Added description field from tenant_configs.json
- Ensured consistency with auth fixtures

### 4. Code Updates
- **services/tenant/app/api/internal_demo.py**:
  - Fixed child tenant staff members to use enterprise parent users
  - Changed from professional staff IDs to enterprise staff IDs (Laura López, José Martínez, Francisco Moreno)

- **services/demo_session/app/core/config.py**:
  - Updated DEMO_ACCOUNTS configuration with all 5 child outlets
  - Updated enterprise tenant name and email to match fixtures
  - Added descriptions for all child locations

- **gateway/app/middleware/demo_middleware.py**:
  - Updated comments to reference fixture files as source of truth
  - Clarified that owner IDs come from 01-tenant.json files

- **frontend/src/stores/useTenantInitializer.ts**:
  - Updated tenant names and descriptions to match fixture files
  - Added comments linking to source fixture files

## Benefits:

1. **Single Source of Truth**: All demo data now lives in fixture files
2. **Consistency**: No more sync issues between metadata and fixtures
3. **Maintainability**: Easier to update demo data (one place per tenant type)
4. **Clarity**: Clear separation between template data (fixtures) and runtime config

## Enterprise Demo Fix:

The enterprise owner is now correctly added as a member of all child tenants, fixing
the issue where the tenant switcher didn't show parent/child tenants and the
establishments page didn't load tenants for the demo enterprise user.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-17 15:48:14 +01:00
Urtzi Alfaro
8bfe4f2dd7 Fix Demo enterprise 2025-12-17 13:03:52 +01:00
Urtzi Alfaro
c566967bea Add AI insights feature 2025-12-15 21:14:22 +01:00
Urtzi Alfaro
5642b5a0c0 demo seed change 7 2025-12-15 13:39:33 +01:00
Urtzi Alfaro
82f9622411 demo seed change 4 2025-12-14 19:05:37 +01:00
Urtzi Alfaro
a030bd14c8 demo seed change 2 2025-12-14 11:58:14 +01:00
Urtzi Alfaro
ff830a3415 demo seed change 2025-12-13 23:57:54 +01:00
Urtzi Alfaro
e116ac244c Fix and UI imporvements 3 2025-12-10 11:23:53 +01:00
Urtzi Alfaro
46f5158536 Fix and UI imporvements 2 2025-12-09 13:45:09 +01:00
Urtzi Alfaro
508f4569b9 Fix and UI imporvements 2025-12-09 10:21:41 +01:00
Urtzi Alfaro
667e6e0404 New alert service 2025-12-05 20:07:01 +01:00