feat: add Start View On setting (Today/Yesterday) in General Settings Modal
This commit is contained in:
parent
0632e03326
commit
182e634f23
@ -676,6 +676,7 @@ export default function WeeklyView() {
|
||||
dayHeaderGap?: string;
|
||||
showTaskCheckboxes?: boolean;
|
||||
quoteSourceUrls?: string[];
|
||||
startDayOffset?: number;
|
||||
}>({
|
||||
name: session?.user?.name || "",
|
||||
email: session?.user?.email || "",
|
||||
@ -2150,6 +2151,7 @@ export default function WeeklyView() {
|
||||
const goToToday = () => {
|
||||
const d = new Date();
|
||||
d.setHours(0, 0, 0, 0);
|
||||
d.setDate(d.getDate() + (profile?.startDayOffset || 0));
|
||||
setCurrentWeekStart(d);
|
||||
};
|
||||
|
||||
@ -5827,6 +5829,7 @@ export default function WeeklyView() {
|
||||
somedayLists={somedayLists}
|
||||
handleToggleTaskList={handleToggleTaskList}
|
||||
fetchAvailableTaskLists={fetchAvailableTaskLists}
|
||||
setCurrentWeekStart={setCurrentWeekStart}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@ -6843,8 +6846,10 @@ interface SettingsSidebarProps {
|
||||
yearColor?: string;
|
||||
dayHeaderGap?: string;
|
||||
showTaskCheckboxes?: boolean;
|
||||
startDayOffset?: number;
|
||||
quoteSourceUrls: string[];
|
||||
}) => void;
|
||||
setCurrentWeekStart: (d: Date) => void;
|
||||
quoteSourceUrls?: string[];
|
||||
goal: string;
|
||||
setGoal: (goal: string) => void;
|
||||
@ -7090,6 +7095,7 @@ function SettingsSidebar({
|
||||
handleToggleTaskList,
|
||||
fetchAvailableTaskLists,
|
||||
initialTab,
|
||||
setCurrentWeekStart,
|
||||
}: SettingsSidebarProps) {
|
||||
const [activeTab, setActiveTab] = useState<
|
||||
"calendar" | "general" | "account" | "styling" | "motivation" | "about"
|
||||
@ -7202,6 +7208,7 @@ function SettingsSidebar({
|
||||
dayHeaderGap?: string;
|
||||
showTaskCheckboxes?: boolean;
|
||||
quoteSourceUrls?: string[];
|
||||
startDayOffset?: number;
|
||||
}>({
|
||||
name: "",
|
||||
email: "",
|
||||
@ -7361,6 +7368,7 @@ function SettingsSidebar({
|
||||
yearFontWeight: profile.yearFontWeight,
|
||||
dayHeaderGap: profile.dayHeaderGap,
|
||||
showTaskCheckboxes: profile.showTaskCheckboxes,
|
||||
startDayOffset: profile.startDayOffset,
|
||||
} as any);
|
||||
}, [profile, showTimeGrid, cellDuration, viewStyle, fontSize, showNextTask, showSomeday, showAllDay, showSchedule]);
|
||||
|
||||
@ -7436,6 +7444,7 @@ function SettingsSidebar({
|
||||
showSubHourSlots: data.user.showSubHourSlots !== undefined ? data.user.showSubHourSlots : true,
|
||||
allDayPosition: data.user.allDayPosition || "below",
|
||||
showTaskCheckboxes: data.user.showTaskCheckboxes || false,
|
||||
startDayOffset: data.user.startDayOffset !== undefined ? data.user.startDayOffset : 0,
|
||||
});
|
||||
|
||||
if (data.user.showTimeGrid !== undefined)
|
||||
@ -7452,6 +7461,14 @@ function SettingsSidebar({
|
||||
setShowSchedule(data.user.showSchedule);
|
||||
if (data.user.focusBreakDuration)
|
||||
setFocusBreakDuration(data.user.focusBreakDuration);
|
||||
|
||||
// Apply the initial start date offset if set
|
||||
if (data.user.startDayOffset !== undefined && data.user.startDayOffset !== 0) {
|
||||
const d = new Date();
|
||||
d.setHours(0, 0, 0, 0);
|
||||
d.setDate(d.getDate() + data.user.startDayOffset);
|
||||
setCurrentWeekStart(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@ -7647,6 +7664,7 @@ function SettingsSidebar({
|
||||
goalScope: profile.goalScope,
|
||||
dateLayout: profile.dateLayout,
|
||||
dateAlignment: profile.dateAlignment,
|
||||
startDayOffset: profile.startDayOffset,
|
||||
} as any);
|
||||
}
|
||||
|
||||
@ -7774,6 +7792,29 @@ function SettingsSidebar({
|
||||
>
|
||||
|
||||
{/* Visibility Toggles */}
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: "8px", marginBottom: "8px" }}>
|
||||
<label style={{ fontSize: "0.9rem", fontWeight: 600 }}>Start View On</label>
|
||||
<select
|
||||
value={profile.startDayOffset === -1 ? "-1" : "0"}
|
||||
onChange={(e) => {
|
||||
const offset = parseInt(e.target.value);
|
||||
setProfile({ ...profile, startDayOffset: offset });
|
||||
saveSetting("startDayOffset", offset);
|
||||
}}
|
||||
className="weekly-input"
|
||||
style={{
|
||||
padding: "8px",
|
||||
border: "1px solid var(--weekly-border, #ddd)",
|
||||
borderRadius: "4px",
|
||||
background: "var(--weekly-settings-input-bg, white)",
|
||||
color: "var(--weekly-settings-text, #333)",
|
||||
}}
|
||||
>
|
||||
<option value="0">Today</option>
|
||||
<option value="-1">Yesterday</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div
|
||||
style={{ display: "flex", alignItems: "center", gap: "8px" }}
|
||||
>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user