Skip to content

Commit 2986c21

Browse files
committed
building componets for tweets
1 parent cba605b commit 2986c21

File tree

16 files changed

+131
-21
lines changed

16 files changed

+131
-21
lines changed

apps/X/app/favicon.ico

-171 KB
Binary file not shown.

apps/X/app/icon.svg

Lines changed: 6 additions & 0 deletions
Loading

apps/X/app/layout.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Metadata } from "next";
22
import localFont from "next/font/local";
33
import "./globals.css";
4+
import { Provieder } from "./provider";
45

56
const geistSans = localFont({
67
src: "./fonts/GeistVF.woff",
@@ -23,9 +24,11 @@ export default function RootLayout({
2324
}>) {
2425
return (
2526
<html lang="en" className="dark">
26-
<body className={`${geistSans.variable} ${geistMono.variable} m-0`}>
27-
{children}
28-
</body>
27+
<Provieder>
28+
<body className={`${geistSans.variable} ${geistMono.variable} m-0`}>
29+
{children}
30+
</body>
31+
</Provieder>
2932
</html>
3033
);
3134
}

apps/X/app/lib/auth.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,26 +116,25 @@ export const authOptions = {
116116
Secret: process.env.NEXTAUTH_SECRET || "secr3t",
117117

118118
callbacks: {
119-
async jwt({ token }: { token: JWT }) {
119+
async jwt({ token, user }: any) {
120+
if (user) {
121+
token.id = user.id;
122+
}
120123
return token;
121124
},
122-
123125
async session({ session, token }: any) {
124-
const user = await db.user.findUnique({
125-
where: { id: token.sub },
126-
});
127-
console.log(user, "Thsi is the user");
126+
// const user = await db.user.findUnique({
127+
// where: { id: token.sub },
128+
// });
128129

129130
if (token) {
130-
session.accessToken = token.accessToken;
131-
console.log(session.accessToken, " This is from the sesson function 1");
132131
session.user.id = token.sub;
133-
console.log(session.userid, " This is from the sesson function 2");
134132
}
133+
135134
return session;
136135
},
137136
},
138137
pages: {
139-
signIn: "/",
138+
signIn: "/signin",
140139
},
141140
};

apps/X/app/page.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import { redirect } from "next/navigation";
55
const Page = async () => {
66
const session = await getServerSession(authOptions);
77

8-
if (!session?.user) {
9-
console.log("This is the User session >>>>>>>>>>>>>>>>>", session?.user);
10-
8+
if (!session) {
9+
console.log("No session,redirecting to SIGNIN");
1110
redirect("/signin");
12-
} else {
11+
}
12+
if (session.user && session.user.id) {
1313
redirect("/home");
1414
}
15+
return <div>Loading......</div>;
1516
};
1617

1718
export default Page;

apps/X/app/provider.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"use client";
2+
import { SessionProvider } from "next-auth/react";
3+
4+
export const Provieder = ({ children }: { children: React.ReactNode }) => {
5+
return <SessionProvider>{children}</SessionProvider>;
6+
};

apps/X/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"check-types": "tsc --noEmit"
1212
},
1313
"dependencies": {
14+
"@radix-ui/react-avatar": "^1.1.2",
1415
"@radix-ui/react-dialog": "^1.1.4",
1516
"@radix-ui/react-slot": "^1.1.1",
1617
"@repo/ui": "*",

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

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { TweetComp } from "../ui";
2+
3+
4+
export const CenterComp = () => {
5+
return (
6+
<div>
7+
Center Home
8+
<TweetComp />
9+
</div>
10+
);
11+
};

apps/X/src/components/ui/LoginComp.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export const LoginComp = () => {
3838
const result = await signIn("credentials", {
3939
username: formData.username,
4040
password: formData.password,
41+
redirect: true,
42+
callbackUrl: "/home",
4143
});
4244
} catch (error) {
4345
console.log(error, "Error with Credentials");

0 commit comments

Comments
 (0)