Skip to content

Commit 7b1db54

Browse files
committed
CRUD of the blog is completed
1 parent df51455 commit 7b1db54

File tree

8 files changed

+8
-46
lines changed

8 files changed

+8
-46
lines changed

app/(profile)/dashboard/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export const dynamic = 'force-dynamic';
2+
13
import { FetchBlog } from '@/utils/profileActions';
24
import { format } from 'date-fns';
35
import DeleteBlogBtn from '@/components/DeleteBlogBtn';

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

utils/actions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import prisma from "./db";
55
import bcrypt from "bcryptjs"
66
import jwt from 'jsonwebtoken'
77
import { cookies } from 'next/headers';
8-
import { revalidatePath } from "next/cache";
98

109
type RegisterResponse = {
1110
message: string;

utils/blogActions.ts

Whitespace-only changes.

utils/cloudinary.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use server'
2+
13
import {v2 as cloudinary} from "cloudinary";
24

35
cloudinary.config({

utils/deleteBlog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import jwt, { JwtPayload } from "jsonwebtoken";
44
import { cookies } from "next/headers";
55
import prisma from "./db";
66
import { revalidatePath } from "next/cache";
7-
import cloudinary from "./cloudinary.js";
7+
import cloudinary from "@/utils/cloudinary";
88

99
export const DeleteBlog = async (formData: FormData): Promise<void> => {
1010
const id: string = formData.get("id") as string;

utils/getBlog.ts

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
'use server'
22

3-
import { cookies } from "next/headers";
43
import prisma from "./db";
5-
import jwt, {JwtPayload} from "jsonwebtoken";
64

75
export const getBlog = async(id:string) => {
86

@@ -38,44 +36,4 @@ export const getBlog = async(id:string) => {
3836
status: false
3937
}
4038
}
41-
};
42-
43-
// export const getBlog = async(id:string) => {
44-
// const cookiesStore = await cookies()
45-
// const accessToken = cookiesStore.get('accessToken')?.value
46-
47-
// if(accessToken && id){
48-
// try{
49-
// if(process.env.ACCESS_TOKEN){
50-
// const decoded = jwt.verify(accessToken,process.env.ACCESS_TOKEN) as JwtPayload
51-
// if(decoded?.id){
52-
// const fetchedBlog = await prisma.blog.findFirst({
53-
// where: { id },
54-
// include: {
55-
// user: true,
56-
// tags: true,
57-
// },
58-
// });
59-
60-
61-
// console.log(fetchedBlog);
62-
63-
64-
// }
65-
66-
// }
67-
// }catch(error){
68-
69-
// }
70-
71-
// }else{
72-
// return {
73-
// message: "Please Login First",
74-
// status: false
75-
// }
76-
// }
77-
78-
// return {
79-
80-
// }
81-
// };
39+
};

utils/profileActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use server';
22
import z, { ZodError } from 'zod';
3-
import cloudinary from './cloudinary.js';
3+
import cloudinary from '@/utils/cloudinary';
44
import prisma from './db';
55
import { cookies } from 'next/headers';
66
import jwt, { JwtPayload } from 'jsonwebtoken';

0 commit comments

Comments
 (0)