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(
|
||||
async (entry) =>
|
||||
await prisma.timeEntry.update({
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ export async function loader({ request }: LoaderArgs) {
|
|||
|
||||
const url = new URL(request.url);
|
||||
const dateFrom = url.searchParams.get('dateFrom')
|
||||
? dayjs(url.searchParams.get('dateFrom')).toDate()
|
||||
: dayjs().startOf('month').toDate();
|
||||
? dayjs(url.searchParams.get('dateFrom')).startOf('day').toDate()
|
||||
: dayjs().startOf('month').startOf('day').toDate();
|
||||
const dateTo = url.searchParams.get('dateTo')
|
||||
? dayjs(url.searchParams.get('dateTo')).toDate()
|
||||
: dayjs().endOf('month').toDate();
|
||||
? dayjs(url.searchParams.get('dateTo')).endOf('day').toDate()
|
||||
: dayjs().endOf('month').endOf('day').toDate();
|
||||
|
||||
await updateDuration(userId);
|
||||
|
||||
|
|
@ -62,8 +62,8 @@ export default function ReportPage() {
|
|||
const reports = useFetcher<typeof loader>();
|
||||
|
||||
const [dateRange, setDateRange] = useState<DateRangePickerValue>([
|
||||
dayjs().startOf('month').toDate(),
|
||||
dayjs().endOf('month').toDate()
|
||||
dayjs().startOf('month').startOf('day').toDate(),
|
||||
dayjs().endOf('month').endOf('day').toDate()
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import invariant from 'tiny-invariant';
|
|||
import {
|
||||
deleteTimeEntry,
|
||||
getTimeEntry,
|
||||
updateDuration,
|
||||
updateTimeEntry
|
||||
} from '~/models/timeEntry.server';
|
||||
import { requireUserId } from '~/session.server';
|
||||
|
|
@ -160,6 +161,8 @@ export async function action({ request, params }: ActionArgs) {
|
|||
});
|
||||
}
|
||||
|
||||
updateDuration(userId);
|
||||
|
||||
return redirect('/time-entries');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue