diff --git a/src/components/settings/SettingsPanel.tsx b/src/components/settings/SettingsPanel.tsx index 9e4af71..edaa290 100644 --- a/src/components/settings/SettingsPanel.tsx +++ b/src/components/settings/SettingsPanel.tsx @@ -5,7 +5,7 @@ import toast from 'react-hot-toast'; import { Card } from '@/components/ui'; import { bcClient } from '@/services/bc/bcClient'; import { useAuth, useProfilePhoto } from '@/services/auth'; -import { useCompanyStore } from '@/hooks'; +import { useCompanyStore, useSettingsStore } from '@/hooks'; import { BuildingOffice2Icon, BuildingOfficeIcon, @@ -33,6 +33,7 @@ export function SettingsPanel() { const { account, isAuthenticated } = useAuth(); const { photoUrl } = useProfilePhoto(isAuthenticated); const { selectedCompany } = useCompanyStore(); + const { requireTimesheetComments, updateSettings } = useSettingsStore(); const [companyInfo, setCompanyInfo] = useState(null); const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(null); @@ -236,7 +237,30 @@ export function SettingsPanel() {

Get reminded to fill in your timesheet

+ +
+
+

Require Comments on Time Entries

+

+ Enforce adding notes/comments when logging time +

+
+
diff --git a/src/components/timesheet/TimeEntryModal.tsx b/src/components/timesheet/TimeEntryModal.tsx index 3134db2..a57e638 100644 --- a/src/components/timesheet/TimeEntryModal.tsx +++ b/src/components/timesheet/TimeEntryModal.tsx @@ -4,7 +4,7 @@ import { useState, useEffect, useMemo, useCallback } from 'react'; import toast from 'react-hot-toast'; import { TrashIcon, ExclamationTriangleIcon } from '@heroicons/react/24/outline'; import { Modal, Button, Input, Select } from '@/components/ui'; -import { useTimeEntriesStore, useProjectsStore } from '@/hooks'; +import { useTimeEntriesStore, useProjectsStore, useSettingsStore } from '@/hooks'; import { useAuth } from '@/services/auth'; import { bcClient } from '@/services/bc/bcClient'; import type { TimeEntry, SelectOption } from '@/types'; @@ -26,6 +26,7 @@ export function TimeEntryModal({ isOpen, onClose, date, entry }: TimeEntryModalP const { addEntry, updateEntry, deleteEntry } = useTimeEntriesStore(); const { projects, selectedProject, selectedTask, selectProject, selectTask } = useProjectsStore(); + const { requireTimesheetComments } = useSettingsStore(); const [customerId, setCustomerId] = useState(''); const [projectId, setProjectId] = useState(''); @@ -193,6 +194,11 @@ export function TimeEntryModal({ isOpen, onClose, date, entry }: TimeEntryModalP return; } + if (requireTimesheetComments && !notes.trim()) { + toast.error('Notes are required. Please add a comment before saving.'); + return; + } + if (notes.length > MAX_NOTES_LENGTH) { toast.error(`Notes cannot exceed ${MAX_NOTES_LENGTH} characters.`); return; @@ -354,7 +360,7 @@ export function TimeEntryModal({ isOpen, onClose, date, entry }: TimeEntryModalP {/* Notes */}