-
Notifications
You must be signed in to change notification settings - Fork 1
fix: Persist Settings Panel preferences using Zustand store #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ import { useState, useEffect } from 'react'; | |||||||
| import { Card } from '@/components/ui'; | ||||||||
| import { bcClient } from '@/services/bc/bcClient'; | ||||||||
| import { useAuth } from '@/services/auth'; | ||||||||
| import { useSettingsStore } from '@/hooks/useSettingsStore'; | ||||||||
| import { | ||||||||
| BuildingOffice2Icon, | ||||||||
| EnvelopeIcon, | ||||||||
|
|
@@ -26,6 +27,7 @@ interface CompanyInfo { | |||||||
|
|
||||||||
| export function SettingsPanel() { | ||||||||
| const { account } = useAuth(); | ||||||||
| const { weeklyHoursTarget, notificationsEnabled, updateSettings } = useSettingsStore(); | ||||||||
| const [companyInfo, setCompanyInfo] = useState<CompanyInfo | null>(null); | ||||||||
| const [isLoading, setIsLoading] = useState(true); | ||||||||
| const [error, setError] = useState<string | null>(null); | ||||||||
|
|
@@ -136,7 +138,15 @@ export function SettingsPanel() { | |||||||
| </div> | ||||||||
| <input | ||||||||
| type="number" | ||||||||
| defaultValue={40} | ||||||||
| value={weeklyHoursTarget} | ||||||||
| min={1} | ||||||||
| max={168} | ||||||||
| onChange={(e) => { | ||||||||
| const value = parseInt(e.target.value, 10); | ||||||||
| if (!isNaN(value) && value >= 1 && value <= 168) { | ||||||||
| updateSettings({ weeklyHoursTarget: value }); | ||||||||
| } | ||||||||
| }} | ||||||||
| className="w-20 rounded-lg border border-dark-600 bg-dark-800 px-3 py-2 text-dark-100 focus:outline-none focus:ring-2 focus:ring-thyme-500" | ||||||||
| /> | ||||||||
|
Comment on lines
139
to
151
|
||||||||
| </div> | ||||||||
|
|
@@ -146,7 +156,12 @@ export function SettingsPanel() { | |||||||
| <p className="text-sm text-dark-400">Get reminded to fill in your timesheet</p> | ||||||||
| </div> | ||||||||
| <label className="relative inline-flex cursor-pointer items-center"> | ||||||||
| <input type="checkbox" defaultChecked className="peer sr-only" /> | ||||||||
| <input | ||||||||
| type="checkbox" | ||||||||
| checked={notificationsEnabled} | ||||||||
| onChange={(e) => updateSettings({ notificationsEnabled: e.target.checked })} | ||||||||
| className="peer sr-only" | ||||||||
|
||||||||
| className="peer sr-only" | |
| className="peer sr-only" | |
| aria-label="Timesheet Reminders" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number input is missing a 'step' attribute. While the validation ensures only integers between 1 and 168 are accepted, without an explicit step attribute, some browsers may allow decimal inputs via the input spinner buttons. Consider adding step={1} to ensure the input only accepts whole numbers through all input methods.