File tree Expand file tree Collapse file tree 4 files changed +59
-5
lines changed
app/dashboard/_components Expand file tree Collapse file tree 4 files changed +59
-5
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { Card, CardContent } from "@/components/ui/card";
55import { useTranslation } from "@/i18n/use-translation" ;
66import { useQuery } from "@tanstack/react-query" ;
77import { LoaderIcon } from "lucide-react" ;
8- import React from "react" ;
8+ import React , { useEffect } from "react" ;
99
1010const MatrixReport = ( ) => {
1111 const { _t } = useTranslation ( ) ;
Original file line number Diff line number Diff line change 1+ import z from "zod" ;
2+ import { CommentActionInput } from "./inputs/comment.input" ;
3+
4+ export const getComments = async (
5+ resourceId : string ,
6+ resourceType : "ARTICLE" | "COMMENT"
7+ ) => {
8+ // Fetch comments from the database based on resourceId and resourceType
9+ // const comments = await db
10+ // .select()
11+ // .from(commentsTable)
12+ // .where(commentsTable.resource_id.eq(resourceId))
13+ // .and(commentsTable.resource_type.eq(resourceType))
14+ // .orderBy(commentsTable.created_at.desc());
15+ // return comments;
16+ return [ ] ; // Placeholder for actual database query
17+ } ;
18+
19+ export const createComment = async (
20+ input : z . infer < typeof CommentActionInput . create >
21+ ) => {
22+ const { resource_id, resource_type, body } = input ;
23+
24+ // Create the comment in the database
25+
26+ // return newComment[0];
27+ } ;
28+
29+ export const deleteComment = async (
30+ input : z . infer < typeof CommentActionInput . delete >
31+ ) => {
32+ const { id } = input ;
33+
34+ // Delete the comment from the database
35+ // await db.delete(commentsTable).where(commentsTable.id.eq(id));
36+
37+ // return { success: true };
38+ } ;
Original file line number Diff line number Diff line change 11"use server" ;
22
3- import * as sessionActions from "@/backend/services/session.actions" ;
43import { pgClient } from "@/backend/persistence/clients" ;
4+ import { authID } from "@/backend/services/session.actions" ;
55
66const sql = String . raw ;
77
@@ -12,15 +12,15 @@ SELECT (SELECT Count(*)
1212 AS total_articles,
1313 (SELECT Count(*)
1414 FROM comments
15- WHERE comments.commentable_type = 'ARTICLE'
16- AND comments.commentable_id IN (SELECT id
15+ WHERE comments.resource_type = 'ARTICLE'
16+ AND comments.resource_id IN (SELECT id
1717 FROM articles
1818 WHERE articles.author_id = $1))
1919 AS total_comments
2020` ;
2121
2222export async function myArticleMatrix ( ) {
23- const sessionUserId = await sessionActions . authID ( ) ;
23+ const sessionUserId = await authID ( ) ;
2424
2525 const totalPostsQuery = await pgClient ?. executeSQL < any > ( query , [
2626 sessionUserId ! ,
Original file line number Diff line number Diff line change 1+ import z from "zod" ;
2+
3+ export const CommentActionInput = {
4+ create : z . object ( {
5+ resource_id : z . string ( ) . uuid ( ) ,
6+ resource_type : z . enum ( [ "ARTICLE" , "COMMENT" ] ) ,
7+ body : z . string ( ) . min ( 1 ) . max ( 500 ) ,
8+ } ) ,
9+ update : z . object ( {
10+ id : z . string ( ) . uuid ( ) ,
11+ body : z . string ( ) . min ( 1 ) . max ( 500 ) ,
12+ } ) ,
13+ delete : z . object ( {
14+ id : z . string ( ) . uuid ( ) ,
15+ } ) ,
16+ } ;
You can’t perform that action at this time.
0 commit comments