Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/dashboard/[slug]/[noteSlug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default function NotePage() {
notesTableId: getNote?.notesTableId,
title: getNote?.title,
body: JSON.stringify(updatedContent),
workingSpacesSlug:getNote?.workingSpacesSlug,
createdAt: getNote?.createdAt,
});
}, 500);
Expand Down
1 change: 0 additions & 1 deletion app/dashboard/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import CreateNoteBtn from "@/components/dashboard-components/CreateNoteBtn";
import ADiv from "@/components/dashboard-components/ADiv";
import TableSettings from "@/components/dashboard-components/TableSettings";
import NoteSettings from "@/components/dashboard-components/NoteSettings";
import { useRouter } from "next/navigation";
import TablesNotFound from "@/components/dashboard-components/TablesNotFound";
import { useState } from "react";
import FloatingNavbar from "@/components/dashboard-components/FloatingNavbar";
Expand Down
1 change: 1 addition & 0 deletions components/dashboard-components/NoteSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function NoteSettings({noteId}:NoteSettingsProps) {
notesTableId:getNote?.notesTableId,
title:inputValue,
body: getNote?.body,
workingSpacesSlug:getNote?.workingSpacesSlug,
createdAt:getNote?.createdAt
});
}
Expand Down
11 changes: 3 additions & 8 deletions components/dashboard-components/SearchDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import { Button } from "../ui/button"
import { Search } from "lucide-react"
import { useQuery } from "convex/react"
import { api } from "@/convex/_generated/api"
import { useState } from "react"
import { useRouter } from "next/navigation"
import Link from "next/link";
interface SearchDialogProps{
Variant:"SidebarMenuButton" | "Trigger",
WithTheTitle:boolean,
Expand All @@ -32,10 +31,6 @@ interface SearchDialogProps{
export default function SearchDialog({Variant,WithTheTitle,IconSize}:SearchDialogProps) {
const viwer = useQuery(api.users.viewer);
const getNotes = useQuery(api.mutations.notes.getNoteByUserId,{userid:viwer?._id});
const router = useRouter()
const handleRouting = (noteId: any,noteSlug: any,workingSpacesSlug:any)=>{
router.push(`/dashboard/${workingSpacesSlug}/${noteSlug}?id=${noteId}`);
}
return (
<Dialog>
<DialogTrigger asChild>
Expand All @@ -60,15 +55,15 @@ export default function SearchDialog({Variant,WithTheTitle,IconSize}:SearchDialo
{
getNotes.map((note) => (
<CommandItem key={note._id} className=" group hover:bg-brand_tertiary/5 aria-selected:bg-brand_tertiary/5">
<button onClick={() => note.slug && handleRouting(note._id, note.slug,note.workingSpacesSlug)} className="w-full h-full flex flex-shrink-0 flex-grow-0 justify-between items-start gap-1">
<Link href={`/dashboard/${note.workingSpacesSlug}/${note.slug}?id=${note._id}`} className="w-full h-full flex flex-shrink-0 flex-grow-0 justify-between items-start gap-1">
<h1 className="text-lg font-medium text-nowrap">
{note.title ? (note.title.length > 20 ? `${note.title.substring(0, 20)}...` : note.title) : 'Untitled'}
</h1>
<span className="flex justify-center items-center gap-1 transition-all duration-200 ease-in-out opacity-10 group-hover:opacity-80">
<Calendar size="16"/>
<p className=" font-normal text-sm">{new Date(note.createdAt).toLocaleDateString()}</p>
</span>
</button>
</Link>
</CommandItem>
))
}
Expand Down
4 changes: 3 additions & 1 deletion convex/mutations/notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ export const updateNote = mutation({
notesTableId:v.any(),
title: v.optional(v.string()),
body: v.optional(v.string()),
workingSpacesSlug:v.any(),
createdAt:v.any()
},
handler: async (ctx, args)=>{
const userId = getAuthUserId(ctx);
if (!userId) {
throw new Error("Not authenticated");
}
const { _id,userid,notesTableId, title, body,createdAt } = args;
const { _id,userid,notesTableId, title, body,workingSpacesSlug,createdAt } = args;
const note = await ctx.db.get(_id);
if (!note) {
throw new Error("Note not found");
Expand All @@ -75,6 +76,7 @@ export const updateNote = mutation({
notesTableId: notesTableId,
slug:slug??"untitled",
createdAt: createdAt,
workingSpacesSlug:workingSpacesSlug,
updatedAt: Date.now(),
};
const updatedNote = await ctx.db.replace(_id, update);
Expand Down