diff --git a/.gitignore b/.gitignore
index fd3dbb5..0109a4b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,8 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+# IDEA
+/.idea
+
# dependencies
/node_modules
/.pnp
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index b58b603..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Editor-based HTTP Client requests
-/httpRequests/
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index 03d9549..0000000
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 85b1200..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/tremor-dashboard.iml b/.idea/tremor-dashboard.iml
deleted file mode 100644
index 24643cc..0000000
--- a/.idea/tremor-dashboard.iml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/app/a.client.tsx b/src/app/a.client.tsx
index 79b5159..713879b 100644
--- a/src/app/a.client.tsx
+++ b/src/app/a.client.tsx
@@ -15,7 +15,13 @@ export function SubjectOverviewCard({
}) {
const {
data: _project
- } = useSWR(`/api/project?select=raw_json&toggl_id=eq.${projectId}`, fetcher);
+ } = useSWR<{
+ raw_json: {
+ name: string,
+ color: string,
+ }
+ }[]>(`/api/project?select=raw_json&toggl_id=eq.${projectId}`, fetcher);
+
const [project, setProject] = useState({
name: '',
color: '',
@@ -43,7 +49,7 @@ export function SubjectOverviewCard({
}, [data]);
return (
-
+
{title ?? project?.name}
Total
{(a / (60 * 60)).toFixed(2)} hours
@@ -55,26 +61,37 @@ export function SubjectComparisonCard({projectIds}: {
projectIds: number[]
}) {
const {
- data,
+ data: rawData,
error,
isLoading,
- } = useSWR(`/api/time_entry?select=raw_json,project:project_id(name,raw_json)&project_id=in.(${projectIds.join(',')})`, fetcher, {});
+ } = useSWR<{
+ raw_json: {
+ seconds: number,
+ },
+ project: {
+ name: string,
+ raw_json: any
+ }
+ }[]>(`/api/time_entry?select=raw_json,project:project_id(name,raw_json)&project_id=in.(${projectIds.join(',')})`, fetcher, {});
- const [a, setA] = useState<{ name: string, value: number }[]>([]);
+ const [breakdownData, setBreakdownData] = useState<{
+ name: string,
+ value: number
+ }[]>([]);
const [colours, setColours] = useState([]);
useEffect(() => {
- const a = R.toPairs(R.groupBy((entry) => entry.project.name, data ?? []))
+ const breakdownData = R.toPairs(R.groupBy((entry) => entry.project.name, rawData ?? []))
.map(([name, entries]) => ({
name,
value: (entries ?? []).map((entry) => entry.raw_json.seconds).reduce((a, b) => a + b, 0),
colour: entries?.[0].project.raw_json.color
}))
- setA(a);
+ setBreakdownData(breakdownData);
- setColours(a.map((entry) => entry.colour));
- }, [data]);
+ setColours(breakdownData.map((entry) => entry.colour));
+ }, [rawData]);
const valueFormatter = (number: number) => `${(number / (60 * 60)).toFixed(2)} hours`;
@@ -83,7 +100,7 @@ export function SubjectComparisonCard({projectIds}: {
Relative Breakdown
+
+