-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add basic subject archive functionality
- Loading branch information
Showing
37 changed files
with
298 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const Loading = () => null; | ||
|
||
export default Loading; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import SubjectList from '@/_components/subject-list'; | ||
import CollapsibleArchive from '@/_queries/collapsible-archive'; | ||
import countArchivedSubjects from '@/_queries/count-archived-subjects'; | ||
|
||
const Page = async () => { | ||
const { count } = await countArchivedSubjects(); | ||
if (!count) return null; | ||
|
||
return ( | ||
<CollapsibleArchive label="subjects"> | ||
<SubjectList archived /> | ||
</CollapsibleArchive> | ||
); | ||
}; | ||
export default Page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,7 @@ | ||
import Avatar from '@/_components/avatar'; | ||
import Button from '@/_components/button'; | ||
import Empty from '@/_components/empty'; | ||
import SubjectMenu from '@/_components/subject-menu'; | ||
import getCurrentUser from '@/_queries/get-current-user'; | ||
import listSubjects, { ListSubjectsData } from '@/_queries/list-subjects'; | ||
import ArrowRightIcon from '@heroicons/react/24/outline/ArrowRightIcon'; | ||
import EllipsisVerticalIcon from '@heroicons/react/24/outline/EllipsisVerticalIcon'; | ||
import InformationCircleIcon from '@heroicons/react/24/outline/InformationCircleIcon'; | ||
import SubjectList from '@/_components/subject-list'; | ||
|
||
export const metadata = { title: 'Subjects' }; | ||
|
||
const Page = async () => { | ||
const [{ data: subjects }, user] = await Promise.all([ | ||
listSubjects(), | ||
getCurrentUser(), | ||
]); | ||
|
||
if (!subjects?.length) { | ||
return ( | ||
<Empty className="mx-4"> | ||
<InformationCircleIcon className="w-7" /> | ||
Subjects can be dogs, cats, humans or | ||
<br /> | ||
anything else you want to track. | ||
</Empty> | ||
); | ||
} | ||
|
||
const { | ||
clientSubjects, | ||
teamSubjects, | ||
}: { | ||
clientSubjects: NonNullable<ListSubjectsData>; | ||
teamSubjects: NonNullable<ListSubjectsData>; | ||
} = subjects.reduce( | ||
(acc, subject) => { | ||
if (!!user && subject.team_id === user.id) acc.teamSubjects.push(subject); | ||
else acc.clientSubjects.push(subject); | ||
return acc; | ||
}, | ||
{ | ||
clientSubjects: [] as NonNullable<ListSubjectsData>, | ||
teamSubjects: [] as NonNullable<ListSubjectsData>, | ||
}, | ||
); | ||
|
||
return ( | ||
<div className="space-y-4"> | ||
{!!teamSubjects.length && ( | ||
<ul className="mx-4 rounded border border-alpha-1 bg-bg-2 py-1"> | ||
{teamSubjects.map((subject) => ( | ||
<li | ||
className="flex items-stretch hover:bg-alpha-1" | ||
key={subject.id} | ||
> | ||
<Button | ||
className="m-0 w-full gap-4 px-4 py-3 pr-0 leading-snug" | ||
href={`/subjects/${subject.id}/events`} | ||
variant="link" | ||
> | ||
<Avatar | ||
className="-my-0.5" | ||
file={subject.image_uri} | ||
key={subject.id} | ||
id={subject.id} | ||
size="sm" | ||
/> | ||
{subject.name} | ||
</Button> | ||
<SubjectMenu | ||
className="group flex h-full items-center justify-center px-2 text-fg-3 hover:text-fg-2" | ||
itemsClassName="mr-2 mt-2" | ||
subject={subject} | ||
> | ||
<div className="rounded-full p-2 group-hover:bg-alpha-1"> | ||
<EllipsisVerticalIcon className="w-5" /> | ||
</div> | ||
</SubjectMenu> | ||
</li> | ||
))} | ||
</ul> | ||
)} | ||
{!!clientSubjects.length && ( | ||
<ul className="mx-4 rounded border border-alpha-1 bg-bg-2 py-1"> | ||
{clientSubjects.map((subject) => ( | ||
<li key={subject.id}> | ||
<Button | ||
className="m-0 w-full gap-6 px-4 py-3 leading-snug hover:bg-alpha-1" | ||
href={`/subjects/${subject.id}/events`} | ||
variant="link" | ||
> | ||
<Avatar | ||
className="-my-0.5 -mr-2" | ||
file={subject.image_uri} | ||
id={subject.id} | ||
size="sm" | ||
/> | ||
{subject.name} | ||
<ArrowRightIcon className="ml-auto w-5 shrink-0" /> | ||
</Button> | ||
</li> | ||
))} | ||
</ul> | ||
)} | ||
</div> | ||
); | ||
}; | ||
const Page = () => <SubjectList />; | ||
|
||
export default Page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.