diff --git a/apps/desktop2/src/components/main/body/daily.tsx b/apps/desktop2/src/components/main/body/daily.tsx new file mode 100644 index 000000000..9ca705395 --- /dev/null +++ b/apps/desktop2/src/components/main/body/daily.tsx @@ -0,0 +1,67 @@ +import { format } from "date-fns"; +import { CalendarIcon, CheckSquare, Mail, Sun } from "lucide-react"; + +import { type Tab } from "../../../store/zustand/tabs"; +import { type TabItem, TabItemBase } from "./shared"; + +export const TabItemDaily: TabItem = ({ tab, handleClose, handleSelect }) => { + return ( + } + title={tab.type === "daily" ? format(tab.date, "MMM d, yyyy") : "Daily Note"} + active={tab.active} + handleClose={() => handleClose(tab)} + handleSelect={() => handleSelect(tab)} + /> + ); +}; + +export function TabContentDaily({ tab }: { tab: Tab }) { + if (tab.type !== "daily") { + return null; + } + + return ( +
+

{format(tab.date, "MMM d, yyyy")}

+ +
+
+

Task

+
+ {[1, 2, 3].map((i) => ( +
+ + task {i} +
+ ))} +
+
+ +
+

Email

+
+ {[1, 2, 3].map((i) => ( +
+ + email {i} +
+ ))} +
+
+ +
+

Event

+
+ {[1, 2, 3].map((i) => ( +
+ + event {i} +
+ ))} +
+
+
+
+ ); +} diff --git a/apps/desktop2/src/components/main/body/index.tsx b/apps/desktop2/src/components/main/body/index.tsx index 1463dc153..95f778d0b 100644 --- a/apps/desktop2/src/components/main/body/index.tsx +++ b/apps/desktop2/src/components/main/body/index.tsx @@ -7,6 +7,7 @@ import { type Tab, uniqueIdfromTab, useTabs } from "../../../store/zustand/tabs" import { useLeftSidebar } from "@hypr/utils/contexts"; import { TabContentCalendar, TabItemCalendar } from "./calendars"; import { TabContentContact, TabItemContact } from "./contacts"; +import { TabContentDaily, TabItemDaily } from "./daily"; import { TabContentEvent, TabItemEvent } from "./events"; import { TabContentFolder, TabItemFolder } from "./folders"; import { TabContentHuman, TabItemHuman } from "./humans"; @@ -93,6 +94,9 @@ function TabItem( if (tab.type === "humans") { return ; } + if (tab.type === "daily") { + return ; + } if (tab.type === "calendars") { return ; @@ -117,6 +121,9 @@ function Content({ tab }: { tab: Tab }) { if (tab.type === "humans") { return ; } + if (tab.type === "daily") { + return ; + } if (tab.type === "calendars") { return ; diff --git a/apps/desktop2/src/components/main/body/shared.tsx b/apps/desktop2/src/components/main/body/shared.tsx index 52ae142bb..47dc113c1 100644 --- a/apps/desktop2/src/components/main/body/shared.tsx +++ b/apps/desktop2/src/components/main/body/shared.tsx @@ -21,7 +21,7 @@ export function TabItemBase(
✕ diff --git a/apps/desktop2/src/components/main/sidebar/index.tsx b/apps/desktop2/src/components/main/sidebar/index.tsx index 7ead99695..7bc9a6a5e 100644 --- a/apps/desktop2/src/components/main/sidebar/index.tsx +++ b/apps/desktop2/src/components/main/sidebar/index.tsx @@ -2,6 +2,7 @@ import { clsx } from "clsx"; import { PanelLeftCloseIcon } from "lucide-react"; import { useLeftSidebar } from "@hypr/utils/contexts"; +import { NewNoteButton } from "./new-note-button"; import { ProfileSection } from "./profile"; import { TimelineView } from "./timeline"; @@ -27,6 +28,7 @@ export function LeftSidebar() {
+
diff --git a/apps/desktop2/src/components/main/sidebar/new-note-button.tsx b/apps/desktop2/src/components/main/sidebar/new-note-button.tsx new file mode 100644 index 000000000..6f05e9e09 --- /dev/null +++ b/apps/desktop2/src/components/main/sidebar/new-note-button.tsx @@ -0,0 +1,34 @@ +import { PencilIcon } from "lucide-react"; +import { useCallback } from "react"; + +import { Button } from "@hypr/ui/components/ui/button"; +import { cn } from "@hypr/ui/lib/utils"; +import { useTabs } from "../../../store/zustand/tabs"; + +export function NewNoteButton() { + const { openNew } = useTabs(); + + const handleCreateNote = useCallback(() => { + openNew({ + type: "sessions", + id: crypto.randomUUID(), + active: true, + state: { editor: "raw" }, + }); + }, [openNew]); + + return ( + + ); +} diff --git a/apps/desktop2/src/components/main/sidebar/profile/index.tsx b/apps/desktop2/src/components/main/sidebar/profile/index.tsx index 3abc332f1..a24d093af 100644 --- a/apps/desktop2/src/components/main/sidebar/profile/index.tsx +++ b/apps/desktop2/src/components/main/sidebar/profile/index.tsx @@ -65,9 +65,9 @@ export function ProfileSection() { }, [openNew, closeMenu]); const handleClickDailyNote = useCallback(() => { - console.log("Daily note"); + openNew({ type: "daily", date: new Date(), active: true }); closeMenu(); - }, [closeMenu]); + }, [openNew, closeMenu]); const menuItems = [ { icon: FolderOpen, label: "Folders", onClick: handleClickFolders }, diff --git a/apps/desktop2/src/store/zustand/tabs.ts b/apps/desktop2/src/store/zustand/tabs.ts index ef81adcad..a8f991ea4 100644 --- a/apps/desktop2/src/store/zustand/tabs.ts +++ b/apps/desktop2/src/store/zustand/tabs.ts @@ -171,6 +171,10 @@ export const tabSchema = z.discriminatedUnion("type", [ type: z.literal("calendars"), month: z.coerce.date(), }), + baseTabSchema.extend({ + type: z.literal("daily"), + date: z.coerce.date(), + }), ]); export type Tab = z.infer; @@ -187,6 +191,7 @@ export const rowIdfromTab = (tab: Tab): string => { return tab.id; case "calendars": case "contacts": + case "daily": throw new Error("invalid_resource"); case "folders": if (!tab.id) { @@ -210,6 +215,8 @@ export const uniqueIdfromTab = (tab: Tab): string => { return `calendars-${tab.month.getFullYear()}-${tab.month.getMonth()}`; case "contacts": return `contacts`; + case "daily": + return `daily-${tab.date.getFullYear()}-${tab.date.getMonth()}-${tab.date.getDate()}`; case "folders": return `folders-${tab.id ?? "all"}`; }