;
diff --git a/frontend/packages/app/src/pages/project-details/tabs/notes/index.tsx b/frontend/packages/app/src/pages/project-details/tabs/notes/index.tsx
index 4eb042c4b..11ca262b8 100644
--- a/frontend/packages/app/src/pages/project-details/tabs/notes/index.tsx
+++ b/frontend/packages/app/src/pages/project-details/tabs/notes/index.tsx
@@ -8,10 +8,9 @@ import { ErrorFallback, Spinner } from "@next-pms/design-system/components";
*/
import { useNotes } from "./context";
import { NoteCard } from "./noteCard";
-import { NotesProvider } from "./provider";
import { NotesSubHeader } from "./subHeader";
-function NotesContent() {
+function NotesGrid() {
const notes = useNotes((s) => s.state.notes);
const isLoading = useNotes((s) => s.state.isLoading);
const error = useNotes((s) => s.state.error);
@@ -47,9 +46,7 @@ function NotesContent() {
export function Notes() {
return (
-
-
-
+
);
}
diff --git a/frontend/packages/app/src/pages/project-details/tabs/notes/noteCard.tsx b/frontend/packages/app/src/pages/project-details/tabs/notes/noteCard.tsx
index e3471f48b..219f301ab 100644
--- a/frontend/packages/app/src/pages/project-details/tabs/notes/noteCard.tsx
+++ b/frontend/packages/app/src/pages/project-details/tabs/notes/noteCard.tsx
@@ -1,13 +1,22 @@
/**
* External dependencies.
*/
-import { Avatar } from "@rtcamp/frappe-ui-react";
+import { useState } from "react";
+import { useNavigate, useParams } from "react-router-dom";
+import { Avatar, Dropdown, useToasts } from "@rtcamp/frappe-ui-react";
import { DotHorizontal } from "@rtcamp/frappe-ui-react/icons";
+import { FrappeError, useFrappeDeleteDoc } from "frappe-react-sdk";
/**
* Internal dependencies.
*/
-import { formatRelativeTimeShort, stripTags } from "@/lib/utils";
+import { ROUTES } from "@/lib/constant";
+import {
+ formatRelativeTimeShort,
+ parseFrappeErrorMsg,
+ stripTags,
+} from "@/lib/utils";
+import { useNotes } from "./context";
import type { Note } from "./types";
type NoteCardProps = {
@@ -15,9 +24,28 @@ type NoteCardProps = {
};
export function NoteCard({ note }: NoteCardProps) {
+ const navigate = useNavigate();
+ const { deleteDoc } = useFrappeDeleteDoc();
+ const [deleting, setDeleting] = useState(false);
+ const { refresh } = useNotes((s) => s.actions);
+ const { projectId = "" } = useParams<{ projectId: string }>();
const excerpt = stripTags(note.description);
const relativeDate = formatRelativeTimeShort(note.creation);
const authorHref = `/desk/user/${encodeURIComponent(note.owner)}`;
+ const toast = useToasts();
+
+ const handleDelete = async () => {
+ setDeleting(true);
+ try {
+ await deleteDoc("Project Status Update", note.name);
+ toast.success("Note deleted");
+ await refresh();
+ } catch (err) {
+ toast.error(parseFrappeErrorMsg(err as FrappeError));
+ } finally {
+ setDeleting(false);
+ }
+ };
return (
@@ -25,10 +53,30 @@ export function NoteCard({ note }: NoteCardProps) {
{note.title}
- {/* TODO: Add actions after requirement clarification */}
-
+ navigate(
+ `${ROUTES.project}/${projectId}/notes/${note.name}/edit`,
+ ),
+ },
+ {
+ label: "Delete",
+ key: "delete",
+ theme: "red",
+ disabled: deleting,
+ onClick: handleDelete,
+ },
+ ]}
/>
diff --git a/frontend/packages/app/src/pages/project-details/tabs/notes/subHeader.tsx b/frontend/packages/app/src/pages/project-details/tabs/notes/subHeader.tsx
index 421a4c153..6b4231d6d 100644
--- a/frontend/packages/app/src/pages/project-details/tabs/notes/subHeader.tsx
+++ b/frontend/packages/app/src/pages/project-details/tabs/notes/subHeader.tsx
@@ -21,8 +21,8 @@ export function NotesSubHeader({
filters,
onFiltersChange,
}: NotesSubHeaderProps) {
- const { projectId = "" } = useParams<{ projectId: string }>();
const navigate = useNavigate();
+ const { projectId = "" } = useParams<{ projectId: string }>();
return (
diff --git a/frontend/packages/app/src/pages/project-details/tabs/notes/types.ts b/frontend/packages/app/src/pages/project-details/tabs/notes/types.ts
index 23fae84bb..35ac0787a 100644
--- a/frontend/packages/app/src/pages/project-details/tabs/notes/types.ts
+++ b/frontend/packages/app/src/pages/project-details/tabs/notes/types.ts
@@ -10,11 +10,14 @@ export type NoteComment = {
modified_by: string;
};
+export const NOTE_STATUS = ["Draft", "Review", "Publish"] as const;
+export type NoteStatus = (typeof NOTE_STATUS)[number];
+
export type Note = {
name: string;
title: string;
description: string;
- status: string;
+ status: NoteStatus;
project: string;
owner: string;
owner_full_name: string;
diff --git a/frontend/packages/app/src/route.tsx b/frontend/packages/app/src/route.tsx
index 4f38cbcbb..1883d3949 100644
--- a/frontend/packages/app/src/route.tsx
+++ b/frontend/packages/app/src/route.tsx
@@ -6,7 +6,6 @@ import { Route, Outlet } from "react-router-dom";
/**
* Internal dependencies.
*/
-import { UnderConstruction } from "@/components/under-construction";
import { ROUTES } from "@/lib/constant";
import LayoutWithSidebar from "./layout";
import { useUser } from "./providers/user";
@@ -18,6 +17,11 @@ const Task = lazy(() => import("@/pages/task"));
const ProjectList = lazy(() => import("@/pages/projects/list"));
const ProjectKanban = lazy(() => import("@/pages/projects/kanban"));
const ProjectDetail = lazy(() => import("@/pages/project-details"));
+const NoteEditor = lazy(() =>
+ import("@/pages/project-details/tabs/notes/editor").then((m) => ({
+ default: m.NoteEditor,
+ })),
+);
const PersonalTimesheetLayout = lazy(
() => import("@/pages/timesheet/personal/layout"),
);
@@ -52,11 +56,10 @@ export function Router() {
}
- />
- }
- />
+ >
+ } />
+ } />
+
}>