feat: add maintenance banner with configurable time window#701
feat: add maintenance banner with configurable time window#701jjramirezn merged 1 commit intodevelopfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis update enhances the maintenance mode functionality by adding a time-based check to the existing route-based verification. The Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Banner
participant Config
participant Clock
User->>Banner: Navigate to route
Banner->>Config: Retrieve maintenance config (routes & maintenanceTime)
Banner->>Clock: Fetch current time
Clock-->>Banner: Return current timestamp
Banner->>Banner: Check if route is under maintenance and time is within window
alt Conditions met
Banner->>User: Display maintenance banner (active/scheduled message)
else Conditions not met
Banner->>User: Render no banner (null)
end
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/components/Global/Banner/MaintenanceBanner.tsx (1)
23-23: Consider using or removing the unusedformatDateutility.
SinceformatDateis defined but never called, you may either remove it if it’s not needed or incorporate it into your banner message to improve user clarity about the maintenance schedule.src/config/routesUnderMaintenance.ts (1)
24-27: Consider externalizing maintenance times to environment variables.
If these maintenance windows might change often, storing them in environment variables (or a more accessible configuration) and referencing them here could simplify updates without requiring code changes.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/Global/Banner/MaintenanceBanner.tsx(1 hunks)src/config/routesUnderMaintenance.ts(2 hunks)
🔇 Additional comments (2)
src/components/Global/Banner/MaintenanceBanner.tsx (2)
11-14: Consider validating the configured start and end times for the maintenance window.
Ifconfig.maintenanceTime.startorconfig.maintenanceTime.endis invalid or in an unexpected format,new Date(...)will yieldNaN, which breaks the range comparisons (NaN >= startTime && NaN <= endTimewill be false). You might want to implement a check or fallback for invalid configurations.
16-18: Confirm inclusivity of the maintenance window boundaries.
The current logic (now >= startTime && now <= endTime) includes both endpoints in the window. Verify that this is by design—in some use cases, you might want the maintenance to take effect strictly after the start time or expire strictly before the end time.
| maintenanceTime?: { | ||
| start: string | ||
| end: string | ||
| } | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Document or constrain the allowed date format for maintenanceTime.
While the code currently accepts any string, invalid or poorly formatted values will cause issues in the logic. Consider providing documentation or validation to ensure only valid ISO8601/UTC date strings are used.
Summary by CodeRabbit