Skip to content

Commit

Permalink
fix(dashboard): allow custom period to be 1 day
Browse files Browse the repository at this point in the history
  • Loading branch information
RaunoT committed Oct 18, 2024
1 parent 876d487 commit 2f22857
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/app/dashboard/_components/PeriodSelectContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { GlobalContext } from '@/app/_components/GlobalContextProvider'
import { DashboardSearchParams } from '@/types/dashboard'
import { Settings } from '@/types/settings'
import { pluralize } from '@/utils/formatting'
import Link from 'next/link'
import { usePathname, useSearchParams } from 'next/navigation'
import { useContext, useEffect } from 'react'
Expand Down Expand Up @@ -38,7 +37,7 @@ export default function PeriodSelectContent({ settings }: Props) {
const periodOptions = [
{ label: '7 days', value: '7days' },
{
label: `${pluralize(customPeriod, 'day')}`,
label: customPeriod > 1 ? `${customPeriod} days` : 'Today',
value: 'custom',
},
{ label: 'Past year', value: 'pastYear' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ const schema = z.object({
(value) => {
const number = parseFloat(value)

return number > 1 && number <= 3000
return number > 0 && number <= 3000
},
{
message: 'Custom period must be > 1 and <= 3000',
message: 'Custom period must be > 0 and <= 3000',
},
)
.optional(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export default function DashboardSettingsForm({ settings }: Props) {
/>
<span className='label'>
<span className='label-wrapper'>Custom period</span>
<small>In days.</small>
</span>
</label>
<DatePicker
Expand Down

0 comments on commit 2f22857

Please sign in to comment.