Skip to content

Commit 78d8a10

Browse files
authored
Merge pull request #27 from mscode07/dev
working on pages
2 parents 83e09a9 + 0948546 commit 78d8a10

File tree

5 files changed

+36
-43
lines changed

5 files changed

+36
-43
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"use client";
2+
const explore = () => {
3+
return <div>This is New page Explore</div>;
4+
};
5+
export default explore;

apps/X/app/api/post/route.ts

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { authOptions } from "app/lib/auth";
33
import { getServerSession } from "next-auth";
44
//? https://github.com/code100x/cms/blob/main/src/app/api/admin/content/route.ts
55
import { NextRequest, NextResponse } from "next/server";
6-
import { AiOutlineConsoleSql } from "react-icons/ai";
76

87
const prisma = new PrismaClient();
98

@@ -66,54 +65,38 @@ export const POST = async (req: NextRequest) => {
6665
const tweet = await prisma.tweet.create({
6766
data: { content, userID: userId },
6867
});
68+
// router.push("")
6969
console.log("This is the response", tweet);
70+
7071
return NextResponse.json(tweet, { status: 201 });
7172
} catch (error) {
7273
console.log("Getting error in Creating", error);
7374
}
7475
};
75-
interface RouteContext {
76-
params: {
77-
id: string;
78-
};
79-
}
80-
// export const DELETE = async (
81-
// req: NextRequest,
82-
// params: { param: { id: string } }
83-
// ) => {
84-
// console.log(params.param.id);
85-
86-
// try {
87-
// console.log("Hitting the Delete");
88-
// const tweetId = Number(params.param.id);
89-
// const deleteTweet = await prisma.tweet.delete({
90-
// where: {
91-
// id: tweetId,
92-
// },
93-
// });
94-
// console.log("Deleting the Tweet", deleteTweet);
95-
// return NextResponse.json({ mess: "Done with Delete", status: 200 });
96-
// } catch (error) {
97-
// console.log("Getting this error while deleting", error);
98-
// return NextResponse.json(
99-
// { error: "Failed to delete tweet" },
100-
// { status: 500 }
101-
// );
102-
// }
103-
// };
10476

10577
export async function DELETE(req: NextRequest) {
10678
try {
107-
console.log("Hitting the delete");
79+
const session = await getServerSession(authOptions);
80+
if (!session?.user?.id) {
81+
return NextResponse.json(
82+
{ error: "Unauthorized - User not authenticated" },
83+
{ status: 401 }
84+
);
85+
}
86+
const userDel = session?.user?.id;
10887
const id = req.nextUrl.searchParams.get("id");
10988
if (!id) {
11089
return NextResponse.json(
11190
{ message: "Todi ID is required" },
11291
{ status: 400 }
11392
);
11493
}
115-
const deleteTweet = await prisma.tweet.delete({
116-
where: { id: Number(id) },
94+
const tweetId = Number(id);
95+
const deleteTweet = await prisma.tweet.update({
96+
where: { id: tweetId, userID: userDel },
97+
data: {
98+
IsDelete: true,
99+
},
117100
});
118101
if (!deleteTweet) {
119102
return NextResponse.json({ message: "Tweet not found" }, { status: 404 });

apps/X/src/components/ui/Post/TopPost.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ import { Button } from "../button";
1414
import { Input } from "../input";
1515
import { UserAvatar } from "../usrAvatar";
1616
import X_Icon from "../X_Icon";
17-
// interface TweetInput {
18-
// content: string;
19-
// userId: number;
20-
// }
2117

2218
export const TopPost = () => {
2319
const [postInput, setPostInput] = useState("");
@@ -35,6 +31,7 @@ export const TopPost = () => {
3531
try {
3632
const res = await axios.post("/api/post", { content: postInput });
3733
console.log("Post saved successfully:", res.data);
34+
3835
setPostInput("");
3936
} catch (error) {
4037
console.log("Errro while Posting", error);

apps/X/src/components/ui/home/CenterComp.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const CenterComp = () => {
2020
setLoading(true);
2121
const response = await axios.get("api/post");
2222
const tweetData = response.data.data;
23-
console.log(">>>>>>>>>>>>>>>>>>>>>>>>", tweetData);
23+
// console.log(">>>>>>>>>>>>>>>>>>>>>>>>", tweetData);
2424

2525
if (Array.isArray(tweetData) && response.data.data.length > 0) {
2626
setTweets(tweetData);
@@ -35,8 +35,14 @@ export const CenterComp = () => {
3535
const response = await axios.get("api/post");
3636
console.log("This is from the Centercomp", response);
3737
};
38+
3839
useEffect(() => {
3940
fetchTweets();
41+
42+
// const intervalPolling = setInterval(() => {
43+
// fetchTweets();
44+
// }, 5000);
45+
// return () => clearInterval(intervalPolling);
4046
}, []);
4147
return (
4248
<div className="">

apps/X/src/components/ui/home/HomeLeft.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ export const HomeLeft = () => {
4343
</Link>
4444
</div>
4545
<div className="flex items-center text-xl mb-3">
46-
<div className="custom:hover:bg-neutral-900 flex gap-4 custom:hover:bg-opacity-40 transition duration-200 custom:hover:rounded-2xl px-4 py-2 items-center">
47-
<div className="hover:bg-neutral-900 flex gap-4 hover:bg-opacity-40 transition duration-200 hover:rounded-2xl text-2xl">
48-
<IoMdSearch />
46+
<Link href={"/explore"}>
47+
<div className="custom:hover:bg-neutral-900 flex gap-4 custom:hover:bg-opacity-40 transition duration-200 custom:hover:rounded-2xl px-4 py-2 items-center">
48+
<div className="hover:bg-neutral-900 flex gap-4 hover:bg-opacity-40 transition duration-200 hover:rounded-2xl text-2xl">
49+
<IoMdSearch />
50+
</div>
51+
<div className="custom:visible invisible">Explore</div>
4952
</div>
50-
<div className="custom:visible invisible">Explore</div>
51-
</div>
53+
</Link>
5254
</div>
5355
<div className="flex items-center text-xl mb-3">
5456
<div className="custom:hover:bg-neutral-900 flex gap-4 custom:hover:bg-opacity-40 transition duration-200 custom:hover:rounded-2xl px-4 py-2">

0 commit comments

Comments
 (0)