diff --git a/src/actions/addcomment.action.ts b/src/actions/addcomment.action.ts index e62dff1..b669cbe 100644 --- a/src/actions/addcomment.action.ts +++ b/src/actions/addcomment.action.ts @@ -1,41 +1,23 @@ -"use server"; -import { userAction } from "@/lib/next-safe-action"; -import repositoryService from "@/services/repository.service"; -import { pusherServer } from "@/lib/pusherServer"; -import * as z from "zod"; +// "use server"; +// import { userAction } from "@/lib/next-safe-action"; +// import { postRepositoryComment } from "@/services/repository.service"; +// import * as z from "zod"; -const schema = z.object({ - repositoryId: z.number(), - picture: z.string().optional().nullable(), - name: z.string().optional().nullable(), - username: z.string().optional().nullable(), - content: z.string().min(1, "Comment must be at least 1 character long"), -}); +// const schema = z.object({ +// repositoryId: z.number(), +// picture: z.string().optional().nullable(), +// name: z.string().optional().nullable(), +// username: z.string().optional().nullable(), +// content: z.string().min(1, "Comment must be at least 1 character long"), +// }); -export const addComment = userAction(schema, async (data, ctx) => { - try { - await pusherServer.trigger(`repo-${data.repositoryId}`, "new-comment", { - // content: data.content, - // picture: data.picture, - // name: data.name, - // username: data.username, - // userId: ctx.session.user.id, - content: data.content, - createdBy: { - image: data.picture, - name: data.name, - username: data.username, - }, - createdAt: new Date(), - userId: ctx.session.user.id, - }); - - await repositoryService.addCommentToRepository( - data.repositoryId, - data.content, - ctx.session.user.id, - ); - } catch (error) { - if (error instanceof Error) return { error: error.message }; - } -}); +// export const addComment = userAction(schema, async (data, ctx) => { +// try { +// await postRepositoryComment({ +// repositoryId: data.repositoryId, +// content: data.content, +// }); +// } catch (error) { +// if (error instanceof Error) return { error: error.message }; +// } +// }); diff --git a/src/actions/addrepository.action.ts b/src/actions/addrepository.action.ts deleted file mode 100644 index 1df1250..0000000 --- a/src/actions/addrepository.action.ts +++ /dev/null @@ -1,22 +0,0 @@ -"use server"; - -import { userAction } from "@/lib/next-safe-action"; -import repositoryService from "@/services/repository.service"; - -import * as z from "zod"; - -const schema = z.object({ - url: z.string().url(), - description: z.string(), -}); - -export const addRepository = userAction(schema, async (data, ctx) => { - try { - await repositoryService.postRepository({ - ...data, - createdBy: ctx.session.user.id, - }); - } catch (error) { - if (error instanceof Error) return { error: error.message }; - } -}); diff --git a/src/actions/admin/hiderepository.action.ts b/src/actions/admin/hiderepository.action.ts deleted file mode 100644 index f92fe35..0000000 --- a/src/actions/admin/hiderepository.action.ts +++ /dev/null @@ -1,19 +0,0 @@ -"use server"; -import { revalidatePath } from "next/cache"; -import { adminAction } from "@/lib/next-safe-action"; -import repositoryService from "@/services/repository.service"; -import * as z from "zod"; - -const schema = z.object({ - id: z.number(), -}); - -export const hideRepository = adminAction(schema, async (data) => { - try { - await repositoryService.hideRepository(data.id); - } catch (error) { - if (error instanceof Error) return { error: error.message }; - } - - revalidatePath("/"); -}); diff --git a/src/actions/getRepositories.action.ts b/src/actions/getRepositories.action.ts deleted file mode 100644 index e974741..0000000 --- a/src/actions/getRepositories.action.ts +++ /dev/null @@ -1,30 +0,0 @@ -"use server"; -import repositoryService from "@/services/repository.service"; - -type Props = { - query?: string; - language?: string; - offset?: number; - limit?: number; - cursor?: number; -}; - -export const getRepositoriesOnScroll = async ({ - query, - language, - offset = 0, - limit = 20, - cursor, -}: Props) => { - return await repositoryService.getRepositoriesOnScroll({ - query, - language, - offset, - limit, - cursor, - }); -}; - -export const getRepositories = async () => { - return await repositoryService.getRepositories(); -}; diff --git a/src/actions/syncrepositories.action.ts b/src/actions/syncrepositories.action.ts deleted file mode 100644 index 2d08fd5..0000000 --- a/src/actions/syncrepositories.action.ts +++ /dev/null @@ -1,13 +0,0 @@ -"use server"; -import { revalidatePath } from "next/cache"; -import repositoryService from "@/services/repository.service"; - -export const syncRepositories = async () => { - try { - await repositoryService.syncRepositories(); - } catch (error) { - if (error instanceof Error) return { error: error.message }; - } - - revalidatePath("/"); -}; diff --git a/src/app/(app)/repositories/[repositoryId]/page.tsx b/src/app/(app)/repositories/[repositoryId]/page.tsx index cb99680..61f865f 100644 --- a/src/app/(app)/repositories/[repositoryId]/page.tsx +++ b/src/app/(app)/repositories/[repositoryId]/page.tsx @@ -9,7 +9,7 @@ export default async function RepositoryCommentPage({ }: { params: { repositoryId: number }; }) { - const { repository, comments, session, user } = await useFetchCommentsPage( + const { repository, comments, session } = await useFetchCommentsPage( Number(params.repositoryId), ); @@ -21,31 +21,27 @@ export default async function RepositoryCommentPage({
- {repository?.repositoryName} + {repository.data?.repositoryName} Published by{" "} - {repository.createdBy.username ?? repository.createdBy.name} + {repository.data?.createdBy.username ?? + repository.data?.createdBy.name}
- - {session && ( - - )} + + {session && }
); } diff --git a/src/app/(app)/repositories/page.tsx b/src/app/(app)/repositories/page.tsx index 6031372..8f9f73c 100644 --- a/src/app/(app)/repositories/page.tsx +++ b/src/app/(app)/repositories/page.tsx @@ -6,13 +6,12 @@ import { DataSharingAgreementForm } from "@/components/organisms/_forms/dataShar import { AddRepositoryForm } from "@/components/organisms/_forms/addrepository.form"; import { useQueryParser } from "@/hooks/useQueryParser"; import { QueryParamsProvider } from "@/context/queryParamsContext"; -import { ParamsType } from "@/types"; type Props = { searchParams?: { query?: string; language?: string; - params?: ParamsType; + params?: string; }; }; diff --git a/src/app/api/cron/route.ts b/src/app/api/cron/route.ts index de33658..eb49946 100644 --- a/src/app/api/cron/route.ts +++ b/src/app/api/cron/route.ts @@ -1,7 +1,7 @@ import { type NextRequest, NextResponse } from "next/server"; -import repositoryService from "@/services/repository.service"; -import { env } from "@/env"; +import { syncRepositories } from "@/services/repository.service"; import adminService from "@/services/admin.service"; +import { env } from "@/env"; export async function GET(request: NextRequest) { const authHeader = request.headers.get("authorization"); @@ -9,7 +9,7 @@ export async function GET(request: NextRequest) { return new Response("Unauthorized", { status: 401 }); } - await repositoryService.syncRepositories(); + await syncRepositories(); await adminService.updateCronLastRun(); return NextResponse.json({ ok: "Cron OK" }); diff --git a/src/app/socketio/page.tsx b/src/app/socketio/page.tsx deleted file mode 100644 index 3d9721a..0000000 --- a/src/app/socketio/page.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { getRepository } from "@/services/actions/repository.service"; - -export default async function SocketIOPage() { - const repository = await getRepository({ repositoryId: 1 }); - console.log(repository); - - return
test
; -} diff --git a/src/components/molecules/PrefetchLink.tsx b/src/components/molecules/PrefetchLink.tsx index a19372b..eaf6dd3 100644 --- a/src/components/molecules/PrefetchLink.tsx +++ b/src/components/molecules/PrefetchLink.tsx @@ -1,7 +1,7 @@ "use client"; import Link from "next/link"; import { useQueryClient } from "@tanstack/react-query"; -import { getRepositoriesByFilter } from "@/services/actions/repository.service"; +import { getRepositoriesByFilter } from "@/services/repository.service"; import { URL } from "@/constants"; export const PrefetchLink = () => { diff --git a/src/components/molecules/SelectParams.tsx b/src/components/molecules/SelectParams.tsx index 4399334..c86d435 100644 --- a/src/components/molecules/SelectParams.tsx +++ b/src/components/molecules/SelectParams.tsx @@ -12,6 +12,7 @@ export const SelectParams = () => { const { params, setParams: setParams } = useQueryParams({ key: "params", }); + const handleChange = async (value: string) => { value === "all" ? await setParams("") : await setParams(value); }; diff --git a/src/components/organisms/Comment/CommentCard.tsx b/src/components/organisms/Comment/CommentCard.tsx index 0fd5e2d..08ac66b 100644 --- a/src/components/organisms/Comment/CommentCard.tsx +++ b/src/components/organisms/Comment/CommentCard.tsx @@ -1,7 +1,6 @@ import Link from "next/link"; import { ProfileAvatar } from "@/components/molecules/Avatar"; import { calculateCommentCreatedRange } from "@/lib/utils"; -import type { Comment } from "@/types/prisma.type"; type Props = { avatar: string | null; diff --git a/src/components/organisms/Comment/CommentList.tsx b/src/components/organisms/Comment/CommentList.tsx index aa74484..4309614 100644 --- a/src/components/organisms/Comment/CommentList.tsx +++ b/src/components/organisms/Comment/CommentList.tsx @@ -2,13 +2,13 @@ import { CommentCard } from "@/components/organisms/Comment/CommentCard"; import type { Comment } from "@/types/prisma.type"; type Props = { - comments: Comment[]; + comments: Comment[] | undefined; }; export const CommentList = ({ comments }: Props) => { return (
- {comments.map((comment) => ( + {comments?.map((comment) => ( { const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); - await hideRepository({ id: repository.id }); + await hideRepository({ repositoryId: repository.id }); }; return ( diff --git a/src/components/organisms/Sidebar/SidebarSyncRepositories.tsx b/src/components/organisms/Sidebar/SidebarSyncRepositories.tsx index 94bf37b..bd019cd 100644 --- a/src/components/organisms/Sidebar/SidebarSyncRepositories.tsx +++ b/src/components/organisms/Sidebar/SidebarSyncRepositories.tsx @@ -1,6 +1,6 @@ "use client"; import { useTransition } from "react"; -import { syncRepositories } from "@/actions/syncrepositories.action"; +import { syncRepositories } from "@/services/repository.service"; import { SyncIcon } from "@primer/octicons-react"; export const SidebarSyncRepositories = () => { @@ -19,7 +19,7 @@ export const SidebarSyncRepositories = () => { return (