Skip to content
Draft
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
19 changes: 3 additions & 16 deletions actions/documents/create-folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ export async function createFolder(
if (!parentFolder) {
return {
success: false,
error: {
form: 'Parent folder not found or access denied',
id: '',
name: '',
},
error: 'Parent folder not found or access denied',
};
}
}
Expand Down Expand Up @@ -100,22 +96,13 @@ export async function createFolder(
if (error instanceof z.ZodError) {
return {
success: false,
error: {
form: 'Invalid input data',
id: '',
name: '',
_errors: [],
},
error: 'Invalid input data',
};
}

return {
success: false,
error: {
form: 'Failed to create folder',
id: '',
name: '',
},
error: 'Failed to create folder',
};
}
}
1 change: 0 additions & 1 deletion actions/documents/delete-folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ export async function deleteFolder(
return {
success: false,
error: 'Invalid input data',
fieldErrors: error.flatten().fieldErrors,
};
}

Expand Down
1 change: 0 additions & 1 deletion actions/documents/move-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export async function moveDocument(
return {
success: false,
error: 'Invalid input data',
fieldErrors: error.flatten().fieldErrors,
};
}

Expand Down
2 changes: 1 addition & 1 deletion actions/github/fetch-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function fetchRepository(
const validationResult = fetchRepositorySchema.safeParse(input);
if (!validationResult.success) {
const errorMessage =
validationResult.error.errors[0]?.message || 'Invalid input';
validationResult.error.issues[0]?.message || 'Invalid input';
return {
success: false,
error: errorMessage,
Expand Down
1 change: 0 additions & 1 deletion actions/github/github-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ export async function createProjectFromGitHub(
additionalData?.description ||
repository.description ||
`A project from ${repository.name}`,
summary: Prisma.JsonNull, // Can be populated later with rich content
shortDesc:
additionalData?.shortDesc ||
repository.description ||
Expand Down
15 changes: 9 additions & 6 deletions actions/projects/create-document-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,13 @@ export async function createDocumentComment(
// Create the document comment
const comment = await prisma.documentComment.create({
data: {
content: validatedInput.content as Prisma.InputJsonValue,
contentRich: validatedInput.content as Prisma.InputJsonValue,
discussionId: validatedInput.discussionId,
documentId: validatedInput.documentId,
authorId: user.id,
userId: user.id,
parentId: validatedInput.parentId,
documentContent: validatedInput.documentContent,
},
include: {
author: {
user: {
select: {
id: true,
name: true,
Expand Down Expand Up @@ -130,6 +128,11 @@ export async function createDocumentComment(
};
}

return handlePrismaError(error);
return {
success: false,
error: error instanceof Prisma.PrismaClientKnownRequestError
? handlePrismaError(error)
: 'An unexpected error occurred',
};
}
}
20 changes: 9 additions & 11 deletions actions/projects/create-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { revalidatePath } from 'next/cache';

import { Prisma } from '@prisma/client';
import { type Value } from 'platejs';
// import { type Value } from 'platejs';
import { z } from 'zod';

import { getCurrentUser } from '@/lib/auth/auth-utils';
Expand Down Expand Up @@ -88,15 +88,8 @@ export async function createDocument(
},
});

// If this is a project summary document, update the project
if (validatedInput.projectId && validatedInput.documentType === 'project_summary') {
await prisma.project.update({
where: { id: validatedInput.projectId },
data: {
summaryDocumentId: document.id,
},
});
}
// Note: Project model doesn't have a summaryDocumentId field
// The relationship is handled through the Document model's projectId field

// Revalidate relevant pages
if (validatedInput.projectId) {
Expand Down Expand Up @@ -127,6 +120,11 @@ export async function createDocument(
};
}

return handlePrismaError(error);
return {
success: false,
error: error instanceof Prisma.PrismaClientKnownRequestError
? handlePrismaError(error)
: 'An unexpected error occurred',
};
}
}
1 change: 0 additions & 1 deletion actions/projects/create-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export async function createProject(
data: {
title: data.title,
description: data.description,
summary: data.summary,
shortDesc: data.shortDesc,
images: formattedImages,
demoUrl: data.demoUrl || null,
Expand Down
16 changes: 11 additions & 5 deletions actions/projects/delete-document-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { revalidatePath } from 'next/cache';

import { z } from 'zod';
import { Prisma } from '@prisma/client';

import { getCurrentUser } from '@/lib/auth/auth-utils';
import { prisma } from '@/lib/db';
Expand Down Expand Up @@ -38,7 +39,7 @@ export async function deleteDocumentComment(
const existingComment = await prisma.documentComment.findFirst({
where: {
id: validatedInput.id,
authorId: user.id,
userId: user.id,
},
});

Expand All @@ -60,7 +61,7 @@ export async function deleteDocumentComment(
});

// Revalidate relevant pages
revalidatePath(`/projects/${existingComment.documentId}`);
// Note: DocumentComment doesn't have direct documentId, revalidate general pages
revalidatePath('/projects');

logger.info('Document comment deleted successfully', {
Expand All @@ -69,8 +70,8 @@ export async function deleteDocumentComment(
resourceId: validatedInput.id,
metadata: {
userId: user.id,
documentType: existingComment.documentType,
documentId: existingComment.documentId,
commentId: validatedInput.id,
discussionId: existingComment.discussionId,
},
});

Expand All @@ -86,6 +87,11 @@ export async function deleteDocumentComment(
};
}

return handlePrismaError(error);
return {
success: false,
error: error instanceof Prisma.PrismaClientKnownRequestError
? handlePrismaError(error)
: 'An unexpected error occurred',
};
}
}
2 changes: 1 addition & 1 deletion app/(dashboard)/docs/[docId]/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { VerticalToolbarSkeleton } from '@/components/skeleton/vertical-toolbar-skeletob';
import {
ResizablePanelGroup,
ResizablePanel,
ResizableHandle,
} from '@/components/ui/resizable';
import { Skeleton } from '@/components/ui/skeleton';
import { VerticalToolbarSkeleton } from '@/components/skeleton/vertical-toolbar-skeletob';

const SIDE_PANEL_DEFAULT_SIZE = 15;
const MAIN_PANEL_DEFAULT_SIZE = 100 - SIDE_PANEL_DEFAULT_SIZE;
Expand Down
2 changes: 1 addition & 1 deletion app/(dashboard)/docs/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Suspense } from 'react';

import { DocumentList } from '@/components/documents/document-list';
import { FolderNavigation } from '@/components/documents/folder-navigation';
import { VerticalToolbarSkeleton } from '@/components/skeleton/vertical-toolbar-skeletob';
import {
ResizablePanelGroup,
ResizablePanel,
Expand All @@ -12,7 +13,6 @@ import {
getFolderTreeWithDocuments,
} from '@/data/documents/get-folders';
import { requireServerAuth } from '@/lib/auth/auth-server';
import { VerticalToolbarSkeleton } from '@/components/skeleton/vertical-toolbar-skeletob';

interface DocumentsPageProps {
searchParams: Promise<{
Expand Down
4 changes: 2 additions & 2 deletions app/(dashboard)/projects/[id]/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { updateProjectSummary } from '../../../../../actions/projects/update-pro


interface ProjectPageProps {
params: {
params: Promise<{
id: string;
};
}>;
}

export default async function ProjectEditPage({ params }: ProjectPageProps) {
Expand Down
2 changes: 1 addition & 1 deletion app/auth/error/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AlertTriangle } from 'lucide-react';
import Link from 'next/link';

import { Alert, AlertDescription } from '@/components/ui/alert';
import { CodacLogo } from '@/components/codac-brand/codac-logo';
import { Alert, AlertDescription } from '@/components/ui/alert';
import { Button } from '@/components/ui/button';
import {
Card,
Expand Down
2 changes: 1 addition & 1 deletion app/auth/verify-request/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Mail } from 'lucide-react';
import Link from 'next/link';

import { Button } from '@/components/ui/button';
import { CodacLogo } from '@/components/codac-brand/codac-logo';
import { Button } from '@/components/ui/button';
import {
Card,
CardContent,
Expand Down
2 changes: 1 addition & 1 deletion components/auth/signin-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { useRouter, useSearchParams } from "next/navigation"
import { signIn, useSession } from "next-auth/react"
import { useState, useEffect } from "react"

import { CodacLogo } from "@/components/codac-brand/codac-logo"
import { Alert, AlertDescription } from "@/components/ui/alert"
import { Button } from "@/components/ui/button"
import { CodacLogo } from "@/components/codac-brand/codac-logo"
import { Icons } from "@/components/ui/icons"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
Expand Down
2 changes: 1 addition & 1 deletion components/auth/signup-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { useRouter } from "next/navigation";
import { useState } from "react";

import { oAuthSignIn } from "@/actions/auth/oauth-signin";
import { CodacLogo } from "@/components/codac-brand/codac-logo";
import { Alert, AlertDescription } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
import { CodacLogo } from "@/components/codac-brand/codac-logo";
import {
Card,
CardContent,
Expand Down
1 change: 1 addition & 0 deletions components/documents/folder-navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import type { FolderTreeItem } from '@/data/documents/get-folders';
import { cn } from '@/lib/utils';

import { VerticalToolbarSkeleton } from '../skeleton/vertical-toolbar-skeletob';

interface FolderNavigationProps {
Expand Down
55 changes: 55 additions & 0 deletions components/editor/project-summary-editor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
'use client';

import React from 'react';
import { Card, CardContent } from '@/components/ui/card';

interface ProjectSummaryEditorProps {
projectId: string;
initialValue?: string;
onContentChange?: (content: string) => void;
canEdit?: boolean;
showStatusBar?: boolean;
}

export function ProjectSummaryEditor({
projectId,
initialValue = '',
onContentChange,
canEdit = true,
showStatusBar = false,
}: ProjectSummaryEditorProps) {
const [content, setContent] = React.useState(initialValue);

const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
const newContent = e.target.value;
setContent(newContent);
onContentChange?.(newContent);
};

return (
<Card>
<CardContent className="p-4">
<div className="space-y-4">
<div>
<label htmlFor="summary" className="block text-sm font-medium mb-2">
Project Summary
</label>
<textarea
id="summary"
value={content}
onChange={handleChange}
disabled={!canEdit}
placeholder="Describe your project..."
className="w-full min-h-[200px] p-3 border rounded-md resize-vertical"
/>
</div>
{showStatusBar && (
<div className="text-sm text-muted-foreground">
Project ID: {projectId}
</div>
)}
</div>
</CardContent>
</Card>
);
}
2 changes: 1 addition & 1 deletion components/editor/use-chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type MessageDataPart = {

export type Chat = UseChatHelpers<ChatMessage>;

export type ChatMessage = UIMessage<{}, MessageDataPart>;
export type ChatMessage = UIMessage<Record<string, unknown>, MessageDataPart>;

export const useChat = () => {
const editor = useEditorRef();
Expand Down
2 changes: 2 additions & 0 deletions components/error/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { ErrorBoundary as PageErrorBoundary } from './error-boundary';
export { SectionErrorBoundary } from './section-error-boundary';
11 changes: 5 additions & 6 deletions components/ui/comment-database.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
TrashIcon,
XIcon,
} from 'lucide-react';
import { type Value, KEYS, nanoid, NodeApi } from 'platejs';
import { type Value, KEYS, NodeApi } from 'platejs';
import type { CreatePlateEditorOptions } from 'platejs/react';
import {
Plate,
Expand All @@ -43,10 +43,9 @@ import { cn } from '@/lib/utils';

import { Editor, EditorContainer } from './editor';

import {
discussionDatabasePlugin,
discussionDatabaseHelpers,
} from '@/components/editor/plugins/discussion-database-simple';
// TODO: Implement discussion database plugin
const discussionDatabasePlugin = null;
const discussionDatabaseHelpers = null;


export interface TComment {
Expand Down Expand Up @@ -410,7 +409,7 @@ export function CommentCreateFormDatabase({
discussionId?: string;
focusOnMount?: boolean;
}) {
const discussions = usePluginOption(discussionDatabasePlugin, 'discussions');
// const discussions = usePluginOption(discussionDatabasePlugin, 'discussions');

const editor = useEditorRef();
const commentId = useCommentId();
Expand Down
Loading