The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
WIP messages
Tim Wilsondb7798421b07
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/[partnerId]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/[partnerId]/page-client.tsxnew file mode 100644index 0000000000..91753f9e64--- /dev/null+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/[partnerId]/page-client.tsx@@ -0,0 +1,72 @@+"use client";++import { useMessagesContext } from "@/ui/messages/messages-context";+import { ToggleSidePanelButton } from "@/ui/messages/toggle-side-panel-button";+import { X } from "@/ui/shared/icons";+import { ChevronLeft } from "@dub/ui/icons";+import { cn } from "@dub/utils";+import { useState } from "react";++export function ProgramMessagesPartnerPageClient() {+ const [isRightPanelOpen, setIsRightPanelOpen] = useState(false);++ const { setCurrentPanel } = useMessagesContext();++ return (+ <div+ className="relative grid h-full"+ style={{+ gridTemplateColumns: "minmax(340px, 1fr) minmax(0, min-content)",+ }}+ >+ <div>+ <div className="border-border-subtle flex h-12 items-center justify-between gap-4 border-b px-4 sm:h-16 sm:px-6">+ <div className="flex items-center gap-2">+ <button+ type="button"+ onClick={() => setCurrentPanel("index")}+ className="@[800px]/page:hidden rounded-lg p-1.5 text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-900"+ >+ <ChevronLeft className="size-3.5" />+ </button>+ <h2 className="text-content-emphasis text-lg font-semibold leading-7">+ [Partner Name]+ </h2>+ </div>+ <ToggleSidePanelButton+ isOpen={isRightPanelOpen}+ onClick={() => setIsRightPanelOpen((o) => !o)}+ />+ </div>+ [messages with partner]+ </div>++ {/* Right panel - Profile */}+ <div+ className={cn(+ "absolute right-0 top-0 h-full w-0 overflow-hidden bg-white shadow-lg transition-[width]",+ "@[960px]/page:shadow-none @[960px]/page:relative",+ isRightPanelOpen && "w-full sm:w-[340px]",+ )}+ >+ <div className="border-border-subtle size-full w-full border-l sm:w-[340px]">+ <div className="border-border-subtle flex h-12 items-center justify-between gap-4 border-b px-4 sm:h-16 sm:px-6">+ <h2 className="text-content-emphasis text-lg font-semibold leading-7">+ Profile+ </h2>+ <div className="flex items-center gap-2">+ <button+ type="button"+ onClick={() => setIsRightPanelOpen(false)}+ className="@[960px]/page:hidden rounded-lg p-2 text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-900"+ >+ <X className="size-4" />+ </button>+ </div>+ </div>+ <div>[profile panel content]</div>+ </div>+ </div>+ </div>+ );+}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/[partnerId]/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/[partnerId]/page.tsxnew file mode 100644index 0000000000..ac151fc1ec--- /dev/null+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/[partnerId]/page.tsx@@ -0,0 +1,5 @@+import { ProgramMessagesPartnerPageClient } from "./page-client";++export default function ProgramMessagesPartnerPage() {+ return <ProgramMessagesPartnerPageClient />;+}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/layout.tsxnew file mode 100644index 0000000000..3cd8627fb6--- /dev/null+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/layout.tsx@@ -0,0 +1,124 @@+"use client";++import useWorkspace from "@/lib/swr/use-workspace";+import { NavButton } from "@/ui/layout/page-content/nav-button";+import { MessagesContext, MessagesPanel } from "@/ui/messages/messages-context";+import { MessagesList } from "@/ui/messages/messages-list";+import { Button } from "@dub/ui";+import { Msgs, Pen2 } from "@dub/ui/icons";+import { subMinutes } from "date-fns";+import { CSSProperties, ReactNode, useState } from "react";+import { toast } from "sonner";++export default function MessagesLayout({ children }: { children: ReactNode }) {+ const { slug: workspaceSlug } = useWorkspace();++ // TODO: [Messages] fetch real data+ const partnersWithMessages = [+ {+ id: "pn_1KcRT7do2foT1PZ9zZhLF0Cq",+ name: "Tim Wilson",+ avatar: "https://dubassets.com/avatars/clro5ctqd0000jv084g63ua08",+ messages: [+ {+ text: "Hello, how are you?",+ createdAt: subMinutes(new Date(), 5),+ readStatus: "read-app",+ },+ {+ text: "Great, thanks! What about you?",+ createdAt: subMinutes(new Date(), 5),+ readStatus: "read-app",+ },+ ],+ },+ {+ id: "pn_1JZ8GFVXAMTXEYF33QKWZAZ0Y",+ name: "Tim Partner11",+ avatar:+ "https://dev.dubassets.com/partners/pn_1JZ8GFVXAMTXEYF33QKWZAZ0Y/image_nMMv6kL",+ messages: [+ {+ text: "Thanks for approving my application!",+ createdAt: subMinutes(new Date(), 5),+ readStatus: "read-app",+ },+ ],+ },+ ];+ const isLoading = false;+ const error = null;++ const [currentPanel, setCurrentPanel] = useState<MessagesPanel>("index");++ return (+ <MessagesContext.Provider value={{ currentPanel, setCurrentPanel }}>+ <div className="@container/page h-[calc(100vh-0.5rem-1px)] w-full overflow-hidden rounded-t-[inherit] bg-white">+ <div+ className="@[800px]/page:grid-cols-[min-content_minmax(340px,1fr)] @[800px]/page:translate-x-0 grid h-full translate-x-[calc(var(--current-panel)*-100%)] grid-cols-[100%_100%]"+ style={+ {+ "--current-panel": { index: 0, main: 1 }[currentPanel],+ } as CSSProperties+ }+ >+ {/* Left panel - 800px/messages list */}+ <div className="@[800px]/page:w-[280px] @[960px]/page:w-[340px] flex w-full flex-col overflow-hidden">+ <div className="border-border-subtle flex h-12 items-center justify-between gap-4 border-b px-4 sm:h-16 sm:px-6">+ <div className="flex min-w-0 items-center gap-4">+ <NavButton />+ <h1 className="text-content-emphasis text-lg font-semibold leading-7">+ Messages+ </h1>+ </div>+ <Button+ variant="secondary"+ icon={<Pen2 className="size-4" />}+ className="size-8 rounded-lg p-0"+ onClick={() => toast.info("WIP")}+ />+ </div>+ <div className="grow">+ {partnersWithMessages?.length || isLoading ? (+ <MessagesList+ groupedMessages={partnersWithMessages.map((p) => ({+ ...p,+ href: `/${workspaceSlug}/program/messages/${p.id}`,+ }))}+ />+ ) : error ? (+ <div className="text-content-subtle flex size-full items-center justify-center text-sm">+ Failed to load messages+ </div>+ ) : (+ <div className="flex size-full flex-col items-center justify-center px-4">+ <Msgs className="size-10 text-black" />+ <div className="mt-6 max-w-64 text-center">+ <span className="text-content-emphasis text-base font-semibold">+ You don't have any messages+ </span>+ <p className="text-content-subtle text-sm font-medium">+ When you receive a new message, it will appear here. You+ can also start a conversation at any time.+ </p>+ </div>++ <Button+ variant="primary"+ className="mt-6 h-8 w-fit rounded-lg"+ text="Compose message"+ onClick={() => toast.info("WIP")}+ />+ </div>+ )}+ </div>+ </div>++ <div className="border-border-subtle @[800px]/page:border-l size-full">+ {children}+ </div>+ </div>+ </div>+ </MessagesContext.Provider>+ );+}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/page-client.tsxindex 67a946017e..ad5954bdd2 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/page-client.tsx@@ -1,165 +1,33 @@"use client";-import useWorkspace from "@/lib/swr/use-workspace";-import { NavButton } from "@/ui/layout/page-content/nav-button";-import { MessagesList } from "@/ui/messages/messages-list";-import { ToggleSidePanelButton } from "@/ui/messages/toggle-side-panel-button";-import { Button } from "@dub/ui";+import { useMessagesContext } from "@/ui/messages/messages-context";import { ChevronLeft, Msgs } from "@dub/ui/icons";-import { cn } from "@dub/utils";-import { subMinutes } from "date-fns";-import { CSSProperties, useState } from "react";-import { toast } from "sonner";export function ProgramMessagesPageClient() {- const { slug: workspaceSlug } = useWorkspace();-- const partnersWithMessages = [- {- id: "pn_1KcRT7do2foT1PZ9zZhLF0Cq",- name: "Tim Wilson",- avatar: "https://dubassets.com/avatars/clro5ctqd0000jv084g63ua08",- messages: [- {- text: "Hello, how are you?",- createdAt: subMinutes(new Date(), 5),- readStatus: "read-app",- },- {- text: "Great, thanks! What about you?",- createdAt: subMinutes(new Date(), 5),- readStatus: "read-app",- },- ],- },- {- id: "pn_1JZ8GFVXAMTXEYF33QKWZAZ0Y",- name: "Tim Partner11",- avatar:- "https://dev.dubassets.com/partners/pn_1JZ8GFVXAMTXEYF33QKWZAZ0Y/image_nMMv6kL",- messages: [- {- text: "Thanks for approving my application!",- createdAt: subMinutes(new Date(), 5),- readStatus: "read-app",- },- ],- },- ];- const isLoading = false;- const error = null;-- const [currentPanel, setCurrentPanel] = useState<0 | 1 | 2>(0);- const isRightPanelOpen = currentPanel === 2;+ const { setCurrentPanel } = useMessagesContext();return (- <div className="@container/page h-[calc(100vh-0.5rem-1px)] w-full overflow-hidden rounded-t-[inherit] bg-white">- <div- className="@[960px]/page:grid-cols-[min-content_minmax(340px,1fr)_minmax(0,min-content)] @[960px]/page:translate-x-0 grid h-full translate-x-[calc(var(--current-panel)*-100%)] grid-cols-[100%_100%_100%]"- style={- {- "--current-panel": currentPanel,- } as CSSProperties- }- >- {/* Left panel - Partner/messages list */}- <div className="@[960px]/page:w-[280px] @[1080px]/page:w-[340px] flex w-full flex-col overflow-hidden">- <div className="border-border-subtle flex h-12 items-center justify-between gap-4 border-b px-4 sm:h-16 sm:px-6">- <div className="flex min-w-0 items-center gap-4">- <NavButton />- <div className="flex items-center gap-2">- <h1 className="text-content-emphasis text-lg font-semibold leading-7">- Messages- </h1>- </div>- </div>- </div>- <div className="grow">- {partnersWithMessages?.length || isLoading ? (- <MessagesList- groupedMessages={partnersWithMessages.map((p) => ({- ...p,- href: `/${workspaceSlug}/program/messages/${p.id}`,- }))}- />- ) : error ? (- <div className="text-content-subtle flex size-full items-center justify-center text-sm">- Failed to load messages- </div>- ) : (- <div className="flex size-full flex-col items-center justify-center px-4">- <Msgs className="size-10 text-black" />- <div className="mt-6 max-w-64 text-center">- <span className="text-content-emphasis text-base font-semibold">- You don't have any messages- </span>- <p className="text-content-subtle text-sm font-medium">- When you receive a new message, it will appear here. You can- also start a conversation at any time.- </p>- </div>-- <Button- variant="primary"- className="mt-6 h-8 w-fit rounded-lg"- text="Compose message"- onClick={() => toast.info("WIP")}- />- </div>- )}- </div>- </div>-- {/* Middle panel - Messages */}- <div className="border-border-subtle @[960px]/page:border-l size-full">- <div className="border-border-subtle flex h-12 items-center justify-between gap-4 border-b px-4 sm:h-16 sm:px-6">- <div className="flex items-center gap-2">- <button- type="button"- onClick={() => setCurrentPanel(0)}- className="@[960px]/page:hidden rounded-lg p-1.5 text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-900"- >- <ChevronLeft className="size-3.5" />- </button>- <h2 className="text-content-emphasis text-lg font-semibold leading-7">- [Partner Name]- </h2>- </div>- <ToggleSidePanelButton- isOpen={currentPanel === 2}- onClick={() => {- setCurrentPanel((p) => (p === 2 ? 1 : 2));- }}- />- </div>- <div>[messages content]</div>+ <div className="flex h-full flex-col">+ <div className="border-border-subtle flex h-12 items-center justify-between gap-4 border-b px-4 sm:h-16 sm:px-6">+ <div className="flex items-center gap-2">+ <button+ type="button"+ onClick={() => setCurrentPanel("index")}+ className="@[800px]/page:hidden rounded-lg p-1.5 text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-900"+ >+ <ChevronLeft className="size-3.5" />+ </button>+ <h2 className="text-content-emphasis text-lg font-semibold leading-7">+ [Partner Name]+ </h2></div>+ </div>- {/* Right panel - Profile */}- <div- className={cn(- "@[960px]/page:w-0 w-full overflow-hidden transition-[width]",- isRightPanelOpen && "@[960px]/page:w-[340px]",- )}- >- <div className="border-border-subtle @[960px]/page:border-l @[960px]/page:w-[340px] size-full w-full">- <div className="border-border-subtle flex h-12 items-center justify-between gap-4 border-b px-4 sm:h-16 sm:px-6">- <div className="flex items-center gap-2">- <button- type="button"- onClick={() => setCurrentPanel(1)}- className="@[960px]/page:hidden rounded-lg p-1.5 text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-900"- >- <ChevronLeft className="size-3.5" />- </button>- <h2 className="text-content-emphasis text-lg font-semibold leading-7">- Profile- </h2>- </div>- </div>- <div>[profile panel content]</div>- </div>- </div>+ <div className="flex grow flex-col items-center justify-center gap-4">+ <Msgs className="text-content-muted size-10" />+ <p className="text-content-muted text-sm font-medium">+ Select or compose a message+ </p></div></div>);diff --git a/apps/web/ui/messages/messages-context.tsx b/apps/web/ui/messages/messages-context.tsxnew file mode 100644index 0000000000..06a55feb90--- /dev/null+++ b/apps/web/ui/messages/messages-context.tsx@@ -0,0 +1,15 @@+import { Dispatch, SetStateAction, createContext, useContext } from "react";++export type MessagesPanel = "index" | "main";++export const MessagesContext = createContext<{+ currentPanel: MessagesPanel;+ setCurrentPanel: Dispatch<SetStateAction<MessagesPanel>>;+}>({+ currentPanel: "index",+ setCurrentPanel: () => {},+});++export function useMessagesContext() {+ return useContext(MessagesContext);+}diff --git a/apps/web/ui/messages/messages-list.tsx b/apps/web/ui/messages/messages-list.tsxindex 169fe95cba..1d976d9f25 100644--- a/apps/web/ui/messages/messages-list.tsx+++ b/apps/web/ui/messages/messages-list.tsx@@ -1,5 +1,6 @@import { OG_AVATAR_URL, timeAgo } from "@dub/utils";import Link from "next/link";+import { useMessagesContext } from "./messages-context";export function MessagesList({groupedMessages,@@ -14,6 +15,8 @@ export function MessagesList({}[]| undefined;}) {+ const { setCurrentPanel } = useMessagesContext();+return (<div className="flex w-full flex-col">{groupedMessages@@ -24,6 +27,7 @@ export function MessagesList({<Linkkey={group.id}href={group.href}+ onClick={() => setCurrentPanel("main")}className="hover:bg-bg-muted border-border-subtle flex w-full items-center gap-2.5 border-b bg-white px-6 py-4"><img