diff --git a/app/routes/_app+/recipients+/_layout.tsx b/app/routes/_app+/recipients+/_layout.tsx index a90f6efe..517760a2 100644 --- a/app/routes/_app+/recipients+/_layout.tsx +++ b/app/routes/_app+/recipients+/_layout.tsx @@ -1,16 +1,8 @@ import { json, type LoaderFunctionArgs } from '@remix-run/node' import { Link, NavLink, Outlet, useLoaderData } from '@remix-run/react' -import { useState } from 'react' import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx' import { ButtonLink } from '#app/components/ui/button.tsx' -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, -} from '#app/components/ui/dropdown-menu.tsx' import { Icon } from '#app/components/ui/icon.tsx' -import { SimpleTooltip } from '#app/components/ui/tooltip.js' import { requireUserId } from '#app/utils/auth.server.js' import { CronParseError, getNextScheduledTime } from '#app/utils/cron.server.ts' import { prisma } from '#app/utils/db.server.ts' @@ -70,7 +62,6 @@ export async function loader({ request }: LoaderFunctionArgs) { export default function RecipientsLayout() { const { recipients } = useLoaderData() - const [isOpen, setIsOpen] = useState(false) return (
@@ -93,73 +84,71 @@ export default function RecipientsLayout() {
- - - Select recipient - - - {recipients.map((recipient) => ( - - setIsOpen(false)} - className={cn( - 'flex w-full items-center gap-2 overflow-x-auto rounded-sm px-2 py-1.5 text-xl transition-colors', - 'hover:bg-accent hover:text-accent-foreground', - 'focus:bg-accent focus:text-accent-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2', - )} - > - {({ isActive }) => ( -
- - {recipient.name} - {recipient.disabled ? ( - - - - ) : recipient.cronError ? ( - - - - ) : recipient._count.messages > 0 ? null : ( - - - - )} -
- )} -
-
- ))} - {recipients.length === 0 && ( -
+
+ + Recipient links + + +
+ {recipients.length === 0 ? ( +

No recipients found. Add one to get started. -

+

+ ) : ( + recipients.map((recipient) => { + const statusText = recipient.disabled + ? 'Disabled' + : recipient.cronError + ? 'Invalid schedule' + : recipient._count.messages > 0 + ? null + : 'No messages' + const statusTone = recipient.cronError + ? 'text-destructive' + : 'text-muted-foreground' + const statusTitle = recipient.cronError + ? `Invalid cron: ${recipient.cronError}` + : undefined + + return ( + + cn( + 'flex items-center justify-between gap-3 rounded-md px-3 py-2 text-sm transition-colors', + 'hover:bg-muted/60 hover:text-foreground', + 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2', + isActive + ? 'bg-muted text-foreground font-semibold' + : 'text-muted-foreground', + ) + } + > + + {recipient.name} + + {statusText ? ( + + {statusText} + + ) : null} + + ) + }) )} - - +
+