Skip to content

Commit 119df9d

Browse files
committed
fix: Fixed time entires
1 parent 99fc046 commit 119df9d

File tree

3 files changed

+47
-6
lines changed

3 files changed

+47
-6
lines changed

src/components/time/TimeEntryList.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { addDays, format, isFuture, isWeekend, parseISO, previousMonday, startOfDay, subWeeks } from "date-fns";
1+
import { addDays, format, isFuture, isMonday, isWeekend, parseISO, previousMonday, startOfDay, subWeeks } from "date-fns";
22
import { TTimeEntry } from "../../types/redmine";
33
import TimeEntry from "./TimeEntry";
44

@@ -39,10 +39,13 @@ const TimeEntryList = ({ entries }: PropTypes) => {
3939

4040
const maxHours = Math.max(...groupedEntries.map(({ hours }) => hours));
4141

42+
const today = startOfDay(new Date());
43+
const monday = isMonday(today) ? today : previousMonday(today);
44+
4245
return (
4346
<>
4447
{Array(2)
45-
.fill(previousMonday(startOfDay(new Date())))
48+
.fill(monday)
4649
.map((d, i) => subWeeks(d, i))
4750
.map((monday) => {
4851
const days = Array(7)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const TimeEntryListSkeleton = () => {
2+
return (
3+
<>
4+
{[...Array(2).keys()].map(() => {
5+
return (
6+
<div className="animate-pulse flex flex-col gap-y-1 mb-5">
7+
<div className="flex items-center gap-x-3">
8+
<h1 className="h-4 w-40 bg-gray-200 dark:bg-gray-700"></h1>
9+
<span className="rounded h-5 w-12 bg-gray-200 dark:bg-gray-700"></span>
10+
</div>
11+
{[...Array(5).keys()].map((d) => {
12+
return (
13+
<div className="grid grid-cols-10 items-center gap-x-1">
14+
<h4 className="col-span-1 h-3 w-8 bg-gray-200 dark:bg-gray-700"></h4>
15+
<h3 className="col-span-2 justify-self-end h-3 w-6 bg-gray-200 dark:bg-gray-700"></h3>
16+
<div className="col-span-7">
17+
<div className="flex gap-x-0.5 items-center">
18+
{[...Array(Math.floor(Math.random() * 4 + 1)).keys()].map(() => (
19+
<div
20+
className="h-4 rounded bg-gray-200 dark:bg-gray-700"
21+
style={{
22+
width: `${(Math.floor(Math.random() * 2 + 1) / 8) * 100}%`,
23+
}}
24+
/>
25+
))}
26+
</div>
27+
</div>
28+
</div>
29+
);
30+
})}
31+
</div>
32+
);
33+
})}
34+
</>
35+
);
36+
};
37+
38+
export default TimeEntryListSkeleton;

src/pages/TimePage.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { previousMonday, startOfDay, subWeeks } from "date-fns";
1+
import { isMonday, previousMonday, startOfDay, subWeeks } from "date-fns";
22
import Toast from "../components/general/Toast";
3-
import IssuesListSkeleton from "../components/issues/IssuesListSkeleton";
43
import TimeEntryList from "../components/time/TimeEntryList";
4+
import TimeEntryListSkeleton from "../components/time/TimeEntryListSkeleton";
55
import useMyTimeEntries from "../hooks/useMyTimeEntries";
66

77
const TimePage = () => {
88
const today = startOfDay(new Date());
9-
const startOfLastWeek = subWeeks(previousMonday(today), 1);
9+
const startOfLastWeek = subWeeks(isMonday(today) ? today : previousMonday(today), 1);
1010

1111
const myTimeEntriesQuery = useMyTimeEntries(startOfLastWeek, today);
1212

1313
return (
1414
<>
1515
<div className="flex flex-col gap-y-2">
16-
{myTimeEntriesQuery.isLoading && <IssuesListSkeleton />}
16+
{myTimeEntriesQuery.isLoading && <TimeEntryListSkeleton />}
1717

1818
{!myTimeEntriesQuery.isLoading && <TimeEntryList entries={myTimeEntriesQuery.data} />}
1919

0 commit comments

Comments
 (0)