mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-01-20 22:24:28 +01:00
added start day of week settings
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Version 0.1.23
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- settings to adjust week start day for calendar (#45)
|
||||||
|
|
||||||
## Version 0.1.22
|
## Version 0.1.22
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { Label } from '@/components/ui/label'
|
|||||||
import { DynamicTimeNoSSR } from '@/components/DynamicTimeNoSSR'
|
import { DynamicTimeNoSSR } from '@/components/DynamicTimeNoSSR'
|
||||||
import { useAtom } from 'jotai'
|
import { useAtom } from 'jotai'
|
||||||
import { settingsAtom } from '@/lib/atoms'
|
import { settingsAtom } from '@/lib/atoms'
|
||||||
import { Settings } from '@/lib/types'
|
import { Settings, WeekDay } from '@/lib/types'
|
||||||
import { saveSettings, uploadAvatar } from '../actions/data'
|
import { saveSettings, uploadAvatar } from '../actions/data'
|
||||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
|
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
@@ -94,7 +94,7 @@ export default function SettingsPage() {
|
|||||||
system: { ...settings.system, timezone: e.target.value }
|
system: { ...settings.system, timezone: e.target.value }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
className="w-[200px] rounded-md border border-input bg-background px-3 py-2"
|
className="w-[200px] rounded-md border border-input bg-background px-3 py-2 mb-4"
|
||||||
>
|
>
|
||||||
{Intl.supportedValuesOf('timeZone').map((tz) => (
|
{Intl.supportedValuesOf('timeZone').map((tz) => (
|
||||||
<option key={tz} value={tz}>
|
<option key={tz} value={tz}>
|
||||||
@@ -105,6 +105,41 @@ export default function SettingsPage() {
|
|||||||
<DynamicTimeNoSSR />
|
<DynamicTimeNoSSR />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<div className="space-y-0.5">
|
||||||
|
<Label htmlFor="timezone">Week Start Day</Label>
|
||||||
|
<div className="text-sm text-muted-foreground">
|
||||||
|
Select your preferred first day of the week
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col items-end gap-2">
|
||||||
|
<select
|
||||||
|
id="weekStartDay"
|
||||||
|
value={settings.system.weekStartDay}
|
||||||
|
onChange={(e) =>
|
||||||
|
updateSettings({
|
||||||
|
...settings,
|
||||||
|
system: { ...settings.system, weekStartDay: Number(e.target.value) as WeekDay }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
className="w-[200px] rounded-md border border-input bg-background px-3 py-2"
|
||||||
|
>
|
||||||
|
{([
|
||||||
|
['sunday', 0],
|
||||||
|
['monday', 1],
|
||||||
|
['tuesday', 2],
|
||||||
|
['wednesday', 3],
|
||||||
|
['thursday', 4],
|
||||||
|
['friday', 5],
|
||||||
|
['saturday', 6]
|
||||||
|
] as Array<[string, WeekDay]>).map(([dayName, dayNumber]) => (
|
||||||
|
<option key={dayNumber} value={dayNumber}>
|
||||||
|
{dayName.charAt(0).toUpperCase() + dayName.slice(1)}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
<Card className="mb-6">
|
<Card className="mb-6">
|
||||||
@@ -161,7 +196,7 @@ export default function SettingsPage() {
|
|||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div >
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ export default function HabitCalendar() {
|
|||||||
mode="single"
|
mode="single"
|
||||||
selected={selectedDate.toJSDate()}
|
selected={selectedDate.toJSDate()}
|
||||||
onSelect={(e) => e && setSelectedDate(DateTime.fromJSDate(e))}
|
onSelect={(e) => e && setSelectedDate(DateTime.fromJSDate(e))}
|
||||||
|
weekStartsOn={settings.system.weekStartDay}
|
||||||
className="rounded-md border"
|
className="rounded-md border"
|
||||||
modifiers={{
|
modifiers={{
|
||||||
completed: (date) => completedDates.has(
|
completed: (date) => completedDates.has(
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ export const getDefaultSettings = (): Settings => ({
|
|||||||
useGrouping: true,
|
useGrouping: true,
|
||||||
},
|
},
|
||||||
system: {
|
system: {
|
||||||
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||||
|
weekStartDay: 1 // Monday
|
||||||
},
|
},
|
||||||
profile: {}
|
profile: {}
|
||||||
});
|
});
|
||||||
@@ -85,8 +86,11 @@ export interface UISettings {
|
|||||||
useGrouping: boolean;
|
useGrouping: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6; // 0 = Sunday, 6 = Saturday
|
||||||
|
|
||||||
export interface SystemSettings {
|
export interface SystemSettings {
|
||||||
timezone: string;
|
timezone: string;
|
||||||
|
weekStartDay: WeekDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProfileSettings {
|
export interface ProfileSettings {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "habittrove",
|
"name": "habittrove",
|
||||||
"version": "0.1.22",
|
"version": "0.1.23",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev --turbopack",
|
"dev": "next dev --turbopack",
|
||||||
|
|||||||
Reference in New Issue
Block a user