Skip to content

Commit

Permalink
🎨 Format code after upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
karlosos committed Feb 7, 2024
1 parent d5eb632 commit e1cd491
Show file tree
Hide file tree
Showing 29 changed files with 109 additions and 98 deletions.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
4 changes: 2 additions & 2 deletions src/app/features/Settings/DropZone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const DropZone: React.FC<Props> = ({ setFile, setError }) => {
(acceptedFiles: File[]) => {
setFile(acceptedFiles[0]);
},
[setFile]
[setFile],
);

const { getRootProps, getInputProps, isDragActive } = useDropzone({
Expand All @@ -30,7 +30,7 @@ export const DropZone: React.FC<Props> = ({ setFile, setError }) => {
htmlFor="dropzone-file"
className={cn(
"dark:hover:bg-bray-800 flex h-52 w-full cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed border-gray-300 bg-gray-50 hover:bg-gray-100 dark:border-gray-600 dark:bg-gray-700 dark:hover:border-gray-500 dark:hover:bg-gray-600",
isDragActive ? "border-sky-500" : ""
isDragActive ? "border-sky-500" : "",
)}
>
<div className="flex flex-col items-center justify-center pb-6 pt-5">
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/Settings/ExperimentalFeatures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const ExperimentalFeatures = () => {
const dispatch = useAppDispatch();
const isAdjustableTimeReportingEnabled = useAppSelector(
(state: RootState) =>
state.settings.featureFlags.isAdjustableTimeReportingEnabled
state.settings.featureFlags.isAdjustableTimeReportingEnabled,
);

return (
Expand Down
4 changes: 2 additions & 2 deletions src/app/features/Settings/LinkPatterns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ export const LinkPatterns = () => {
const dispatch = useAppDispatch();

const storePatterns = useAppSelector(
(state: RootState) => state.settings.patterns
(state: RootState) => state.settings.patterns,
);

const [patterns, setPatterns] = useState<LinkPattern[]>(
structuredClone(storePatterns)
structuredClone(storePatterns),
);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ export const GroupedTimeEntryRow: React.FC<GroupedTimeEntryRowProps> = ({
useState(false);
const isAdjustableTimeReportingEnabled = useAppSelector(
(state: RootState) =>
state.settings.featureFlags.isAdjustableTimeReportingEnabled
state.settings.featureFlags.isAdjustableTimeReportingEnabled,
);

const handleAddTimeEntryClick = () => {
dispatch(
timeEntryAdded({ text: groupedTimeEntry.text, startTime: Date.now() })
timeEntryAdded({ text: groupedTimeEntry.text, startTime: Date.now() }),
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const TIME_ENTRIES_LIMIT = 50;
export const TimeEntriesList = () => {
const [timeEntriesLimit, setTimeEntriesLimit] = useState(TIME_ENTRIES_LIMIT);
const groupedTimeEntries = useAppSelector((state) =>
selectTimeEntriesGroupedByDate(state, timeEntriesLimit)
selectTimeEntriesGroupedByDate(state, timeEntriesLimit),
);

const sortedTimeEntries = Array.from(groupedTimeEntries.entries()).sort(
(a, b) => (a[0] > b[0] ? -1 : 1)
(a, b) => (a[0] > b[0] ? -1 : 1),
);

if (sortedTimeEntries.length === 0) {
Expand All @@ -35,7 +35,7 @@ export const TimeEntriesList = () => {
acc[0] + groupedTimeEntries.elapsedTime,
acc[1] + groupedTimeEntries.loggedTime,
],
[0, 0]
[0, 0],
);
return (
<div
Expand Down Expand Up @@ -76,7 +76,7 @@ function DayHeader({
}) {
const isAdjustableTimeReportingEnabled = useAppSelector(
(state: RootState) =>
state.settings.featureFlags.isAdjustableTimeReportingEnabled
state.settings.featureFlags.isAdjustableTimeReportingEnabled,
);

if (isAdjustableTimeReportingEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const TimeReportingDialog = ({
<TextField
label="Reported time"
value={formatElapsedTime(
reportedTimesPerEntry[idx].reportedTime
reportedTimesPerEntry[idx].reportedTime,
)}
className="flex-grow"
autoFocus={false}
Expand Down Expand Up @@ -178,7 +178,7 @@ function useReportedTimeState(groupedTimeEntry: GroupedTimeEntry) {
const [reportedTimeString, setReportedTimeString] = useState(
groupedTimeEntry.loggedTime !== 0
? formatElapsedTime(groupedTimeEntry.loggedTime)
: formatElapsedTime(groupedTimeEntry.elapsedTime)
: formatElapsedTime(groupedTimeEntry.elapsedTime),
);
const isValid = /^\d{2}:\d{2}:\d{2}$/.test(reportedTimeString);
const reportedTimeNumerical = isValid
Expand All @@ -198,7 +198,7 @@ function useReportedTimeState(groupedTimeEntry: GroupedTimeEntry) {
});
const combinedTimes = result.reduce(
(sum, entry) => sum + entry.reportedTime,
0
0,
);
result[0].reportedTime =
result[0].reportedTime + (reportedTimeNumerical - combinedTimes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("TimeEntriesList Deleting", () => {
render(
connectStore(<TimeEntriesList />, {
timeEntries: timeEntriesFixture,
})
}),
);
return { user };
};
Expand Down Expand Up @@ -42,7 +42,7 @@ describe("TimeEntriesList Deleting", () => {

// assert
expect(
screen.queryByText("Delete entry DX1-1: Task 1?")
screen.queryByText("Delete entry DX1-1: Task 1?"),
).not.toBeInTheDocument();
user.click(expandButton); // collapse grouped entry
expect(screen.getAllByTitle("DX1-1: Task 1")).toHaveLength(2);
Expand Down Expand Up @@ -80,17 +80,18 @@ describe("TimeEntriesList Deleting", () => {
const getEntryWithOneChild = () => {
const entryRow = screen.getAllByTitle("DX1-1: Task 1")[0].parentElement!;
const expandButton = within(entryRow).getByLabelText(
"Grouped entry accordion"
"Grouped entry accordion",
);

return { entryRow, expandButton };
};

const getEntryWithMultipleChildren = () => {
const entryRow = screen.getByTitle("DX1-3: Task 3 with logged entries")
.parentElement!;
const entryRow = screen.getByTitle(
"DX1-3: Task 3 with logged entries",
).parentElement!;
const expandButton = within(entryRow).getByLabelText(
"Grouped entry accordion"
"Grouped entry accordion",
);

return { entryRow, expandButton };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("TimeEntriesList Logged Status", () => {
render(
connectStore(<TimeEntriesList />, {
timeEntries: timeEntriesFixture,
})
}),
);

return { user };
Expand Down Expand Up @@ -43,7 +43,7 @@ describe("TimeEntriesList Logged Status", () => {
expect(within(entryRow).getByRole("checkbox")).toBeDisabled();
expect(within(entryRow).getByRole("checkbox")).toHaveAttribute(
"data-indeterminate",
"true"
"true",
);
});

Expand Down Expand Up @@ -78,46 +78,47 @@ describe("TimeEntriesList Logged Status", () => {
await user.click(within(entryRow).getByRole("checkbox"));
await user.click(
within(screen.getAllByLabelText("Time entry child row")[0]).getByRole(
"checkbox"
)
"checkbox",
),
);

// assert
expect(within(entryRow).getByRole("checkbox")).toBeDisabled();
expect(within(entryRow).getByRole("checkbox")).toHaveAttribute(
"data-indeterminate",
"true"
"true",
);
});
});

const getEntryWithUncheckedChildren = () => {
const entryRow = screen.getAllByTitle(
"DX1-2: Task 2 with multiple entries"
"DX1-2: Task 2 with multiple entries",
)[0].parentElement!;
const expandButton = within(entryRow).getByLabelText(
"Grouped entry accordion"
"Grouped entry accordion",
);

return { entryRow, expandButton };
};

const getEntryWithCheckedChildren = () => {
const entryRow = screen.getByTitle("DX1-3: Task 3 with logged entries")
.parentElement!;
const entryRow = screen.getByTitle(
"DX1-3: Task 3 with logged entries",
).parentElement!;
const expandButton = within(entryRow).getByLabelText(
"Grouped entry accordion"
"Grouped entry accordion",
);

return { entryRow, expandButton };
};

const getEntryWithMixedChildren = () => {
const entryRow = screen.getByTitle(
"DX1-4444: Task 4 with some logged entries"
"DX1-4444: Task 4 with some logged entries",
).parentElement!;
const expandButton = within(entryRow).getByLabelText(
"Grouped entry accordion"
"Grouped entry accordion",
);

return { entryRow, expandButton };
Expand All @@ -126,7 +127,7 @@ const getEntryWithMixedChildren = () => {
const assertAllChidrenCheckedStatus = async (
user: UserEvent,
expandRowButton: HTMLElement,
isChecked: boolean
isChecked: boolean,
) => {
await user.click(expandRowButton);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("TimeEntriesList", () => {
render(
connectStore(<TimeEntriesList />, {
timeEntries: timeEntriesFixture,
})
}),
);
};

Expand All @@ -18,14 +18,14 @@ describe("TimeEntriesList", () => {

// assert
expect(
screen.getByTitle("DX1-4444: Task 4 with some logged entries")
screen.getByTitle("DX1-4444: Task 4 with some logged entries"),
).toBeInTheDocument();
expect(
screen.getByTitle("DX1-3: Task 3 with logged entries")
screen.getByTitle("DX1-3: Task 3 with logged entries"),
).toBeInTheDocument();
expect(screen.getAllByTitle("DX1-1: Task 1")).toHaveLength(2);
expect(
screen.getAllByTitle("DX1-2: Task 2 with multiple entries")
screen.getAllByTitle("DX1-2: Task 2 with multiple entries"),
).toHaveLength(2);
});

Expand All @@ -42,15 +42,15 @@ describe("TimeEntriesList", () => {
it("THEN tasks are collapsed by name and time is summed", () => {
arrange();
const groupedRow = screen.getByTitle(
"DX1-4444: Task 4 with some logged entries"
"DX1-4444: Task 4 with some logged entries",
).parentElement;

// assert
expect(within(groupedRow!).getByText("3")).toBeInTheDocument(); // number of collapsed elements
expect(
within(groupedRow!).getByTitle(
"DX1-4444: Task 4 with some logged entries"
)
"DX1-4444: Task 4 with some logged entries",
),
).toBeInTheDocument();
expect(within(groupedRow!).getByText("00:03:05")).toBeInTheDocument();
expect(within(groupedRow!).getByRole("checkbox")).toBeDisabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ describe("TimeEntry Edit", () => {
render(
connectStore(<TimeEntriesList />, {
timeEntries: timeEntriesFixture,
})
}),
);

const entryRow = screen.getAllByTitle("DX1-1: Task 1")[0].parentElement!;
const expandButton = within(entryRow).getByLabelText(
"Grouped entry accordion"
"Grouped entry accordion",
);
await user.click(expandButton);
await user.click(screen.getByLabelText("Edit entry"));
Expand Down Expand Up @@ -76,7 +76,7 @@ describe("TimeEntry Edit", () => {

// assert
expect(
screen.queryByText("--Completely new task--")
screen.queryByText("--Completely new task--"),
).not.toBeInTheDocument();
expect(screen.getAllByTitle("DX1-1: Task 1")).toHaveLength(2);
});
Expand Down
6 changes: 3 additions & 3 deletions src/app/features/TimeEntries/TopBar/CurrentTimeEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ export const CurrentTimeEntry: React.FC<CurrentTimeEntryProps> = ({

const useElapsedTimeForEntry = (currentTimeEntry: TimeEntry) => {
const [elapsedTime, setElapsedTime] = useState<number>(
currentTimeEntry ? Date.now() - currentTimeEntry.startTime : 0
currentTimeEntry ? Date.now() - currentTimeEntry.startTime : 0,
);
const intervalRef = useRef<ReturnType<typeof setInterval>>();

useEffect(() => {
setElapsedTime(
currentTimeEntry ? Date.now() - currentTimeEntry.startTime : 0
currentTimeEntry ? Date.now() - currentTimeEntry.startTime : 0,
);
}, [currentTimeEntry]);

useEffect(() => {
intervalRef.current = setInterval(() => {
setElapsedTime(
currentTimeEntry ? Date.now() - currentTimeEntry.startTime : 0
currentTimeEntry ? Date.now() - currentTimeEntry.startTime : 0,
);
}, 500);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("TopBar Editing", () => {
},
},
},
})
}),
);

const timer = screen.getByText("00:03:00");
Expand Down Expand Up @@ -73,7 +73,7 @@ describe("TopBar Editing", () => {

// assert
expect(
screen.queryByText("--Completely new task--")
screen.queryByText("--Completely new task--"),
).not.toBeInTheDocument();
expect(screen.getByTitle("DX1-3213: Doing something")).toBeInTheDocument();
});
Expand Down
Loading

0 comments on commit e1cd491

Please sign in to comment.