Skip to content
Merged
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
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
5 changes: 5 additions & 0 deletions apps/X/app/(pages)/post/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"use client"
function page() {
return <div>This is the Post page</div>
}
export default page
23 changes: 17 additions & 6 deletions apps/X/app/api/post/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ export const POST = async (req: NextRequest) => {
};

export async function DELETE(req: NextRequest) {
try {
try {
const session = await getServerSession(authOptions);

if (!session?.user?.id) {
return NextResponse.json(
{ error: "Unauthorized - User not authenticated" },
Expand All @@ -91,17 +92,27 @@ export async function DELETE(req: NextRequest) {
{ status: 400 }
);
}
const tweet = await prisma.tweet.findUnique({
where: { id: Number(id) },
});
if (!tweet) {
return NextResponse.json(
{ message: "Tweet not found" },
{ status: 404 }
);
}
if (tweet.userID !== Number(userDel)) {
return NextResponse.json({message:"Unauthorized"})
}
const tweetId = Number(id);
const deleteTweet = await prisma.tweet.update({
where: { id: tweetId, userID: userDel },
where: { id: tweetId},
data: {
IsDelete: true,
},
});
if (!deleteTweet) {
return NextResponse.json({ message: "Tweet not found" }, { status: 404 });
}

console.log("This is the response", deleteTweet);

return NextResponse.json({ message: "Done with delete" }, { status: 200 });
} catch (error) {
console.log("Getting error in Delete", error);
Expand Down
3 changes: 1 addition & 2 deletions apps/X/src/components/ui/TweetComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
PopoverTrigger,
} from "@/components/ui/popover";
import axios from "axios";
import { NextResponse } from "next/server";
import { BiRepost } from "react-icons/bi";
import { FaRegBookmark, FaRegComment } from "react-icons/fa6";
import { FiHeart } from "react-icons/fi";
Expand All @@ -29,7 +28,7 @@ export const TweetComp = ({ tweet }: TweetProps) => {
try {
const response = await axios.delete(`/api/post?id=${tweet.id}`);
console.log("Tweet Deleted", response);
return NextResponse.json({ status: 200 });
return response.data;
} catch (error) {
console.log("Error while Deleting Tweet", error);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/X/src/components/ui/home/HomeComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CenterComp, HomeLeft, HomeRight } from "@/components/ui";
export const HomeComp = () => {
return (
<div className="flex h-screen overflow-y-auto">
<div className="custom:w-96 w-10 custom:ml-24 ml-24 h-screen sticky top-0 flex-shrink-0 mr-7 custom:mr-10">
<div className="custom:w-96 w-10 custom:ml-24 ml-2 h-screen sticky top-0 flex-shrink-0 mr-7 custom:mr-10">
<HomeLeft />
</div>
<div className="flex flex-grow">
Expand Down
20 changes: 14 additions & 6 deletions apps/X/src/components/ui/home/HomeLeft.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
"use client";

import { getSession } from "next-auth/react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { AiOutlineThunderbolt } from "react-icons/ai";
import { CgMoreO } from "react-icons/cg";
import { FaRegBookmark } from "react-icons/fa";
import { FaRegUser } from "react-icons/fa6";
import { GoHome } from "react-icons/go";
import { IoMdSearch } from "react-icons/io";
import { TbOctagonPlus } from "react-icons/tb";
import { MdOutlineMail } from "react-icons/md";
import { RiGroupLine, RiNotification2Line } from "react-icons/ri";
import { TbOctagonPlus } from "react-icons/tb";
import { Button, UserAvatar, X_logo } from "..";
import GrokIcon from "../Grok";
import X_Icon from "../X_Icon";
import Link from "next/link";
import { useState } from "react";

export const HomeLeft = () => {
const [isOpen, setIsOpen] = useState(false);
const router = useRouter();
const session = getSession();

const onPostClick = () => {
console.log("Click");
setIsOpen(!isOpen);
router.push("/post");
console.log(session, "This is the session");
};
return (
<div>
Expand Down Expand Up @@ -138,8 +142,12 @@ export const HomeLeft = () => {
</div>
</div>
<div className="mt-28">
<div>
<div className="flex gap-2">
<UserAvatar />
<div>
<p className="font-bold">mscode</p>
<p className="text-slate-600 font-semibold">@mscode07</p>
</div>
</div>
</div>
</div>
Expand Down