1
1
"use client" ;
2
2
3
3
import { withAuth } from "@/hocs/withAuth" ;
4
- import { useCallback , useEffect , useMemo , useState , useRef } from "react" ;
5
4
import {
6
5
SupernovaTaskComponent ,
7
6
createBlankTask ,
8
7
} from "../components/supernova-task" ;
9
- import Mousetrap from "mousetrap" ;
10
8
import { TaskBuilderDialog } from "../components/task-builder-dialog" ;
11
- import { ISupernovaTask } from "@supernova/types" ;
12
- import { GearIcon } from "@radix-ui/react-icons" ;
9
+ import { ChevronDownIcon , GearIcon } from "@radix-ui/react-icons" ;
13
10
import Link from "next/link" ;
14
11
import { settingsRoute } from "./settings/meta" ;
15
12
import { SupernovaCommandCenter } from "../components/command-center" ;
@@ -18,6 +15,8 @@ import { Kbd } from "../components/kbd";
18
15
import { CreateTaskPlaceholder } from "@/components/create-task-placeholder" ;
19
16
import { SupernovaGlobeLogoImage } from "@/components/icons" ;
20
17
import useSupernovaTasksUI from "@/hooks/useSupernovaTasksUI" ;
18
+ import * as Accordion from "@radix-ui/react-accordion" ;
19
+ import React from "react" ;
21
20
22
21
function Home ( ) {
23
22
// get today's date in this format: Tue, 26th Aug
@@ -27,8 +26,9 @@ function Home() {
27
26
month : "short" ,
28
27
} ) ;
29
28
const {
29
+ accordionValue,
30
+ setAccordionValue,
30
31
taskFetchState,
31
- setTasks,
32
32
taskBuilderIsOpen,
33
33
setTaskBuilderIsOpen,
34
34
chosenTaskIndex,
@@ -42,6 +42,8 @@ function Home() {
42
42
taskListRef,
43
43
commands,
44
44
handleClickTask,
45
+ doneTasks,
46
+ undoneTasks,
45
47
} = useSupernovaTasksUI ( ) ;
46
48
47
49
return (
@@ -113,7 +115,7 @@ function Home() {
113
115
</ p >
114
116
</ div >
115
117
) }
116
- { memoizedTasksView . map ( ( task , index ) => (
118
+ { undoneTasks . map ( ( task , undoneIndex ) => (
117
119
< SupernovaTaskComponent
118
120
key = { task . id }
119
121
task = { task }
@@ -122,7 +124,7 @@ function Home() {
122
124
memoizedTasksView [ chosenTaskIndex ] . id === task . id
123
125
}
124
126
onClickCheck = { handleCheckTask ( task . id ) }
125
- onClick = { handleClickTask ( index ) }
127
+ onClick = { handleClickTask ( undoneIndex ) }
126
128
/>
127
129
) ) }
128
130
</ div >
@@ -131,11 +133,45 @@ function Home() {
131
133
< div className = "text-red-600 text-[16px]" > { taskFetchState . error } </ div >
132
134
</ div >
133
135
) }
136
+
134
137
< CreateTaskPlaceholder
135
138
onClick = { ( ) => {
136
139
openTaskBuilder ( ) ;
137
140
} }
138
141
/>
142
+ < Accordion . Root
143
+ className = "w-full max-w-xl"
144
+ type = "single"
145
+ value = { accordionValue }
146
+ onValueChange = { setAccordionValue }
147
+ collapsible
148
+ >
149
+ < Accordion . AccordionItem value = "supernova-dones" >
150
+ < Accordion . AccordionTrigger className = "flex items-center justify-between w-full hover:bg-gray-100 rounded px-1" >
151
+ < p className = "text-xs text-teal-800" > Dones ({ doneTasks . length } )</ p > { " " }
152
+ < ChevronDownIcon className = "text-teal-800" />
153
+ </ Accordion . AccordionTrigger >
154
+ < Accordion . AccordionContent className = "py-2" >
155
+ < div
156
+ className = "flex flex-col items-center w-full max-h-full gap-2 overflow-clip"
157
+ ref = { taskListRef }
158
+ >
159
+ { doneTasks . map ( ( task , doneIndex ) => (
160
+ < SupernovaTaskComponent
161
+ key = { task . id }
162
+ task = { task }
163
+ focused = {
164
+ chosenTaskIndex !== - 1 &&
165
+ memoizedTasksView [ chosenTaskIndex ] . id === task . id
166
+ }
167
+ onClickCheck = { handleCheckTask ( task . id ) }
168
+ onClick = { handleClickTask ( undoneTasks . length + doneIndex ) }
169
+ />
170
+ ) ) }
171
+ </ div >
172
+ </ Accordion . AccordionContent >
173
+ </ Accordion . AccordionItem >
174
+ </ Accordion . Root >
139
175
</ main >
140
176
) ;
141
177
}
0 commit comments