fix: display default reset date when limitResetDate is null

Fixed empty "Resets on" date display for new users:

Issue:
- Users who haven't created any conversations yet have limitResetDate = NULL
- The "Resets on" field was showing empty/blank
- This confused users about when their limit would reset

Solution:
- Updated formatResetDate() in 3 components to calculate default date
- If limitResetDate is NULL, display "1 month from now"
- This gives users a clear expectation of when limits reset

Files Updated:
- app/[locale]/subscription/page.tsx
  * formatResetDate() now returns calculated date if null
- components/subscription/usage-display.tsx
  * formatResetDate() now returns calculated date if null
- components/subscription/upgrade-modal.tsx
  * formatResetDate() now returns calculated date if null
  * Removed conditional check - always show reset date

User Experience:
- New users see "Resets on: [date one month from now]"
- Once they create their first conversation, actual reset date is set
- Consistent messaging across all subscription UI components

Note: The actual limitResetDate is set when the user creates their
first conversation (in incrementConversationCount function). This fix
only affects the UI display for users who haven't chatted yet.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-12 22:43:31 +00:00
parent 17141abb05
commit 9d82e719ed
3 changed files with 21 additions and 8 deletions

View File

@@ -164,7 +164,12 @@ export default function SubscriptionPage() {
}
const formatResetDate = (dateString: string | null) => {
if (!dateString) return ''
if (!dateString) {
// If no reset date set, calculate 1 month from now
const nextMonth = new Date()
nextMonth.setMonth(nextMonth.getMonth() + 1)
return nextMonth.toLocaleDateString(locale, { year: 'numeric', month: 'long', day: 'numeric' })
}
const date = new Date(dateString)
return date.toLocaleDateString(locale, { year: 'numeric', month: 'long', day: 'numeric' })
}

View File

@@ -37,7 +37,12 @@ export default function UpgradeModal({ open, onClose, limitData }: UpgradeModalP
const usagePercentage = limitData ? ((limitData.limit - limitData.remaining) / limitData.limit) * 100 : 100
const formatResetDate = (dateString: string | null) => {
if (!dateString) return ''
if (!dateString) {
// If no reset date set, calculate 1 month from now
const nextMonth = new Date()
nextMonth.setMonth(nextMonth.getMonth() + 1)
return nextMonth.toLocaleDateString(locale, { year: 'numeric', month: 'long', day: 'numeric' })
}
const date = new Date(dateString)
return date.toLocaleDateString(locale, { year: 'numeric', month: 'long', day: 'numeric' })
}
@@ -94,11 +99,9 @@ export default function UpgradeModal({ open, onClose, limitData }: UpgradeModalP
}
}}
/>
{limitData.resetDate && (
<Typography variant="caption" color="text.secondary" sx={{ mt: 1, display: 'block' }}>
{t('resetsOn', { date: formatResetDate(limitData.resetDate) })}
</Typography>
)}
<Typography variant="caption" color="text.secondary" sx={{ mt: 1, display: 'block' }}>
{t('resetsOn', { date: formatResetDate(limitData.resetDate) })}
</Typography>
</Box>
)}

View File

@@ -79,7 +79,12 @@ export default function UsageDisplay({ compact = false, showUpgradeButton = true
}
const formatResetDate = (dateString: string | null) => {
if (!dateString) return ''
if (!dateString) {
// If no reset date set, calculate 1 month from now
const nextMonth = new Date()
nextMonth.setMonth(nextMonth.getMonth() + 1)
return nextMonth.toLocaleDateString(locale, { year: 'numeric', month: 'long', day: 'numeric' })
}
const date = new Date(dateString)
return date.toLocaleDateString(locale, { year: 'numeric', month: 'long', day: 'numeric' })
}