La Previa Restobar uses a role-based access model enforced at authentication time. Once a user signs in through Firebase Authentication, their role is resolved from Firestore and stored inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/luisumit/LaPreviaRestobar/llms.txt
Use this file to discover all available pages before exploring further.
LoginViewModel. The root AppNavigation composable then reads the role from LoginViewModel.userRole and immediately routes the user to the correct top-level destination — waiter_main, chef_main, or admin_main — clearing the back stack so the login screen cannot be revisited. All routes are defined in a single NavHost inside AppNavigation; each destination is protected so that if the authenticated role does not match the route, the user is redirected back to login.
The UserRole Sealed Class
Roles are modelled as a Kotlin sealed class so that when expressions are exhaustive by default and no string comparison is needed at runtime outside of Firebase deserialization.
fromString() — Deserializing from Firestore
When the user document is fetched from Firestore, the role field arrives as a plain string. fromString() converts it back to the sealed class, defaulting to MESERO if the value is unrecognised.
The
else -> MESERO fallback in fromString() means a missing or misspelled role field in Firestore will silently grant waiter-level access rather than blocking login. Ensure Firestore user documents always include a valid role field.Login to Role Routing
After a successful Firebase sign-in,AppNavigation observes LoginViewModel.userRole via collectAsState() and calls navController.navigate() inside a LaunchedEffect. The popUpTo("login") { inclusive = true } block ensures the login screen is removed from the back stack.
UserRole variant. Tapping a card calls viewModel.selectRole(role), which transitions the LoginUiState to RoleSelected and displays an EmailLoginForm pre-labeled with the chosen role.
Role Comparison
| Property | Mesero (Waiter) | Cocinero (Chef) | Admin |
|---|---|---|---|
| Route | waiter_main | chef_main | admin_main |
| ViewModel | WaiterViewModel | ChefViewModel | AdminViewModel |
| Primary job | Table and order management | Kitchen queue and status updates | Product catalog and operations |
| Screens | Tables, TableDetails, Products, Orders, Inventory | Orders (kitchen queue), Inventory | Dashboard, Reports, Products, QR |
| Notifications | NotificationPanel — order status changes from chef | ChefNotificationPanel — new orders and cancellations | AdminStockWorker — low-stock and out-of-stock alerts |
| Offline support | Room cache + pending sync via SyncManager | Room cache + SyncManager.syncOrders() | Room cache + SyncManager.syncProducts() |
Individual Role Pages
Waiter
Tables grid, product catalog, order builder, and live order tracker driven by
WaiterViewModel.Chef
Kitchen order queue with status progression from
ENVIADO to LISTO, plus ingredient inventory view.Admin
Full product CRUD via
ProductFormDialog, sales reports, QR menu, and scheduled low-stock notifications.