@@ -21,7 +21,7 @@ import {
2121 FetchMailboxUnreadCountsResult ,
2222} from "@/lib/actions/mailbox" ;
2323import { MailboxKind } from "@schema" ;
24- import { IdentityEntity , MailboxEntity } from "@db" ;
24+ import { DraftMessageEntity , IdentityEntity , MailboxEntity } from "@db" ;
2525import AddNewFolder from "@/components/mailbox/default/add-new-folder" ;
2626import { Menu } from "@mantine/core" ;
2727import DeleteMailboxFolder from "@/components/mailbox/default/delete-folder" ;
@@ -115,12 +115,12 @@ function buildTree(
115115export default function IdentityMailboxesList ( {
116116 identityMailboxes,
117117 unreadCounts,
118- scheduledCounts ,
118+ scheduledDrafts ,
119119 onComplete,
120120} : {
121121 identityMailboxes : FetchIdentityMailboxListResult ;
122122 unreadCounts : FetchMailboxUnreadCountsResult ;
123- scheduledCounts : number ;
123+ scheduledDrafts : DraftMessageEntity [ ] ;
124124 onComplete ?: ( ) => void ;
125125} ) {
126126 const pathname = usePathname ( ) ;
@@ -176,7 +176,7 @@ export default function IdentityMailboxesList({
176176 < div className = "flex w-full items-start" >
177177 < Link
178178 href = { href }
179- onClick = { onComplete ? ( ) => onComplete ( ) : undefined }
179+ onClick = { onComplete ? ( ) => onComplete ( ) : undefined }
180180 aria-disabled = { ! m . selectable }
181181 className = { cn (
182182 "flex min-w-0 flex-1 items-center gap-2 rounded-md py-1.5 pl-2 text-sm" ,
@@ -247,6 +247,7 @@ export default function IdentityMailboxesList({
247247 { identityMailboxes . map ( ( { identity, mailboxes } ) => {
248248 const tree = buildTree ( mailboxes as MailboxEntity [ ] , unreadCounts ) ;
249249
250+ const scheduledCounts = scheduledDrafts . filter ( draft => draft . identityId === identity . id ) . length ;
250251 return (
251252 < div key = { identity . id } >
252253 < div className = "px-1 mb-1 mt-2 text-xs font-semibold text-sidebar-foreground/60 flex items-center gap-1" >
@@ -263,10 +264,10 @@ export default function IdentityMailboxesList({
263264 />
264265 ) ) }
265266 </ div >
266- < Link href = { `/dashboard/mail/${ params . identityPublicId } /scheduled` } className = { `my-2 rounded hover:dark:bg-neutral-800 ${ currentSlug === "scheduled" ? "dark:bg-neutral-800 dark:text-brand-foreground bg-brand-200 text-brand" : "" } flex justify-start gap-1 w-full p-1.5` } >
267+ { scheduledCounts > 0 && < Link href = { `/dashboard/mail/${ params . identityPublicId } /scheduled` } className = { `my-2 rounded hover:dark:bg-neutral-800 ${ currentSlug === "scheduled" ? "dark:bg-neutral-800 dark:text-brand-foreground bg-brand-200 text-brand" : "" } flex justify-start gap-1 w-full p-1.5` } >
267268 < IconMailFast size = { 22 } />
268269 < span className = { "font-normal text-sm" } > Scheduled ({ scheduledCounts } )</ span >
269- </ Link >
270+ </ Link > }
270271
271272 </ div >
272273 ) ;
0 commit comments