Overview
The Ai Studio application settings control essential business configuration such as location validation, delivery radius, and reservation management. Settings are stored in Firestore and cached locally for performance.AppSettings Interface
Application settings are defined by theAppSettings interface:
types.ts
Configuration Parameters
Location Settings
The business location coordinates and address
Delivery Configuration
Maximum delivery distance in meters from the business locationThis value determines the service area for delivery orders. Customer addresses beyond this radius will be rejected.Example:
5000 (5 kilometers)Enable or disable location-based delivery validationWhen
true, customer addresses are validated against the delivery radius. When false, all delivery addresses are accepted.Reservation Settings
Reservation-specific settings are managed through theReservationSettings interface:
types.ts
Reservation Parameters
Default duration for each reservation in minutesExample:
120 (2 hours)Minimum advance booking time required in minutesPrevents customers from making last-minute reservations that cannot be fulfilled.Example:
60 (1 hour in advance)Time in minutes to block a table before the reservation startsAllows for table preparation and ensures availability.Example:
15 (15 minutes before)Time in minutes to block a table after the reservation endsProvides buffer time for table turnover and cleaning.Example:
30 (30 minutes after)Time in minutes before a reservation when modifications are lockedPrevents last-minute changes that could disrupt operations.Example:
30 (30 minutes before)Time interval in minutes between available reservation slotsExample:
30 (slots at :00 and :30)Managing Settings
Retrieving Settings
Fetch the current application settings from Firestore:The
getSettings() function returns null if no settings document exists in Firestore.Saving Settings
Update application settings:The
saveSettings() function uses Firestore’s merge option, so you can update partial settings without overwriting the entire document.Storage Location
Settings are stored in Firestore at:settingsService.ts
Local Storage Management
The settings service provides a utility to clear local storage while preserving specific keys:'pizzeria-theme') to maintain user preferences across cache clears.
Error Handling
BothgetSettings() and saveSettings() include error handling:
- getSettings(): Returns
nullon error and logs to console - saveSettings(): Throws an error that should be caught by the caller
Best Practices
Validate Location Coordinates
Validate Location Coordinates
Ensure latitude is between -90 and 90, and longitude is between -180 and 180.
Set Reasonable Delivery Radius
Set Reasonable Delivery Radius
Consider your delivery capabilities when setting the radius. A typical restaurant might use:
- Urban area: 2000-3000 meters
- Suburban area: 5000-8000 meters
- Rural area: 10000+ meters
Configure Reservation Times Appropriately
Configure Reservation Times Appropriately
Balance customer convenience with operational efficiency:
duration: 90-120 minutes for typical diningminBookingTime: 60-120 minutes to prepareslotInterval: 15-30 minutes for flexibility
