Add ability to manually adjust the running timer's start time
Allows users to retroactively correct the start time of an ongoing timer without stopping it. A pencil icon in the timer widget opens an inline time input pre-filled with the current start time; confirming sends the new time to the backend which validates it is in the past before persisting.
This commit is contained in:
@@ -102,9 +102,24 @@ export class TimerService {
|
||||
projectId = data.projectId;
|
||||
}
|
||||
|
||||
// Validate startTime if provided
|
||||
let startTime: Date | undefined = undefined;
|
||||
if (data.startTime) {
|
||||
const parsed = new Date(data.startTime);
|
||||
const now = new Date();
|
||||
if (parsed >= now) {
|
||||
throw new BadRequestError("Start time must be in the past");
|
||||
}
|
||||
startTime = parsed;
|
||||
}
|
||||
|
||||
const updateData: Record<string, unknown> = {};
|
||||
if (projectId !== undefined) updateData.projectId = projectId;
|
||||
if (startTime !== undefined) updateData.startTime = startTime;
|
||||
|
||||
return prisma.ongoingTimer.update({
|
||||
where: { userId },
|
||||
data: projectId !== undefined ? { projectId } : {},
|
||||
data: updateData,
|
||||
include: {
|
||||
project: {
|
||||
select: {
|
||||
|
||||
Reference in New Issue
Block a user