fix: update duration on save time entry
This commit is contained in:
parent
3abe667e65
commit
985e205232
|
|
@ -154,7 +154,7 @@ export async function updateDuration(userId: User['id']) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Promise.all(
|
return Promise.all(
|
||||||
timeEntriesWithoutDuration.map(
|
timeEntriesWithoutDuration.map(
|
||||||
async (entry) =>
|
async (entry) =>
|
||||||
await prisma.timeEntry.update({
|
await prisma.timeEntry.update({
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,11 @@ export async function loader({ request }: LoaderArgs) {
|
||||||
|
|
||||||
const url = new URL(request.url);
|
const url = new URL(request.url);
|
||||||
const dateFrom = url.searchParams.get('dateFrom')
|
const dateFrom = url.searchParams.get('dateFrom')
|
||||||
? dayjs(url.searchParams.get('dateFrom')).toDate()
|
? dayjs(url.searchParams.get('dateFrom')).startOf('day').toDate()
|
||||||
: dayjs().startOf('month').toDate();
|
: dayjs().startOf('month').startOf('day').toDate();
|
||||||
const dateTo = url.searchParams.get('dateTo')
|
const dateTo = url.searchParams.get('dateTo')
|
||||||
? dayjs(url.searchParams.get('dateTo')).toDate()
|
? dayjs(url.searchParams.get('dateTo')).endOf('day').toDate()
|
||||||
: dayjs().endOf('month').toDate();
|
: dayjs().endOf('month').endOf('day').toDate();
|
||||||
|
|
||||||
await updateDuration(userId);
|
await updateDuration(userId);
|
||||||
|
|
||||||
|
|
@ -62,8 +62,8 @@ export default function ReportPage() {
|
||||||
const reports = useFetcher<typeof loader>();
|
const reports = useFetcher<typeof loader>();
|
||||||
|
|
||||||
const [dateRange, setDateRange] = useState<DateRangePickerValue>([
|
const [dateRange, setDateRange] = useState<DateRangePickerValue>([
|
||||||
dayjs().startOf('month').toDate(),
|
dayjs().startOf('month').startOf('day').toDate(),
|
||||||
dayjs().endOf('month').toDate()
|
dayjs().endOf('month').endOf('day').toDate()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import invariant from 'tiny-invariant';
|
||||||
import {
|
import {
|
||||||
deleteTimeEntry,
|
deleteTimeEntry,
|
||||||
getTimeEntry,
|
getTimeEntry,
|
||||||
|
updateDuration,
|
||||||
updateTimeEntry
|
updateTimeEntry
|
||||||
} from '~/models/timeEntry.server';
|
} from '~/models/timeEntry.server';
|
||||||
import { requireUserId } from '~/session.server';
|
import { requireUserId } from '~/session.server';
|
||||||
|
|
@ -160,6 +161,8 @@ export async function action({ request, params }: ActionArgs) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateDuration(userId);
|
||||||
|
|
||||||
return redirect('/time-entries');
|
return redirect('/time-entries');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue