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
Binary file removed apps/X/app/favicon.ico
Binary file not shown.
6 changes: 6 additions & 0 deletions apps/X/app/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions apps/X/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Metadata } from "next";
import localFont from "next/font/local";
import "./globals.css";
import { Provieder } from "./provider";

const geistSans = localFont({
src: "./fonts/GeistVF.woff",
Expand All @@ -23,9 +24,11 @@ export default function RootLayout({
}>) {
return (
<html lang="en" className="dark">
<body className={`${geistSans.variable} ${geistMono.variable} m-0`}>
{children}
</body>
<Provieder>
<body className={`${geistSans.variable} ${geistMono.variable} m-0`}>
{children}
</body>
</Provieder>
</html>
);
}
19 changes: 9 additions & 10 deletions apps/X/app/lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,26 +116,25 @@ export const authOptions = {
Secret: process.env.NEXTAUTH_SECRET || "secr3t",

callbacks: {
async jwt({ token }: { token: JWT }) {
async jwt({ token, user }: any) {
if (user) {
token.id = user.id;
}
return token;
},

async session({ session, token }: any) {
const user = await db.user.findUnique({
where: { id: token.sub },
});
console.log(user, "Thsi is the user");
// const user = await db.user.findUnique({
// where: { id: token.sub },
// });

if (token) {
session.accessToken = token.accessToken;
console.log(session.accessToken, " This is from the sesson function 1");
session.user.id = token.sub;
console.log(session.userid, " This is from the sesson function 2");
}

return session;
},
},
pages: {
signIn: "/",
signIn: "/signin",
},
};
9 changes: 5 additions & 4 deletions apps/X/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { redirect } from "next/navigation";
const Page = async () => {
const session = await getServerSession(authOptions);

if (!session?.user) {
console.log("This is the User session >>>>>>>>>>>>>>>>>", session?.user);

if (!session) {
console.log("No session,redirecting to SIGNIN");
redirect("/signin");
} else {
}
if (session.user && session.user.id) {
redirect("/home");
}
return <div>Loading......</div>;
};

export default Page;
6 changes: 6 additions & 0 deletions apps/X/app/provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"use client";
import { SessionProvider } from "next-auth/react";

export const Provieder = ({ children }: { children: React.ReactNode }) => {
return <SessionProvider>{children}</SessionProvider>;
};
1 change: 1 addition & 0 deletions apps/X/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"check-types": "tsc --noEmit"
},
"dependencies": {
"@radix-ui/react-avatar": "^1.1.2",
"@radix-ui/react-dialog": "^1.1.4",
"@radix-ui/react-slot": "^1.1.1",
"@repo/ui": "*",
Expand Down
3 changes: 0 additions & 3 deletions apps/X/src/components/home/CenterComp.tsx

This file was deleted.

11 changes: 11 additions & 0 deletions apps/X/src/components/home/HomeCenterComp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { TweetComp } from "../ui";


export const CenterComp = () => {
return (
<div>
Center Home
<TweetComp />
</div>
);
};
2 changes: 2 additions & 0 deletions apps/X/src/components/ui/LoginComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export const LoginComp = () => {
const result = await signIn("credentials", {
username: formData.username,
password: formData.password,
redirect: true,
callbackUrl: "/home",
});
} catch (error) {
console.log(error, "Error with Credentials");
Expand Down
9 changes: 9 additions & 0 deletions apps/X/src/components/ui/TweetComp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { UserAvatar } from "./usrAvatar";

export const TweetComp = () => {
return (
<div>
<UserAvatar />
</div>
);
};
2 changes: 2 additions & 0 deletions apps/X/src/components/ui/UserCredentials.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export const UserCredentials = () => {
email: formData.email,
name: formData.name,
password: formData.password,
redirect: true,
callbackUrl: "/home",
});
} catch (error) {
console.log(error, "Error with Credentials");
Expand Down
47 changes: 47 additions & 0 deletions apps/X/src/components/ui/avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as React from "react";
import * as AvatarPrimitive from "@radix-ui/react-avatar";
import { cn } from "@/lib/utils";

const Avatar = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Root
ref={ref}
className={cn(
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
className
)}
{...props}
/>
));
Avatar.displayName = AvatarPrimitive.Root.displayName;

const AvatarImage = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Image>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Image
ref={ref}
className={cn("aspect-square h-full w-full", className)}
{...props}
/>
));
AvatarImage.displayName = AvatarPrimitive.Image.displayName;

const AvatarFallback = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Fallback>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Fallback
ref={ref}
className={cn(
"flex h-full w-full items-center justify-center rounded-full bg-muted",
className
)}
{...props}
/>
));
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;

export { Avatar, AvatarImage, AvatarFallback };
6 changes: 5 additions & 1 deletion apps/X/src/components/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ import { LoginComp } from "./LoginComp";
import { UserCredentials } from "./UserCredentials";
import { HomeRight } from "../home/HomeRight";
import { HomeLeft } from "../home/HomeLeft";
import { CenterComp } from "../home/CenterComp";
import { CenterComp } from "../home/HomeCenterComp";
import { TweetComp } from "./TweetComp";
import { UserAvatar } from "./usrAvatar";

export {
SigninComp,
UserAvatar,
SigninRightCom,
Button,
X_logoBIG,
Dialog,
TweetComp,
X_logo,
Input,
HomeRight,
Expand Down
12 changes: 12 additions & 0 deletions apps/X/src/components/ui/usrAvatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";

export function UserAvatar() {
return (
<div>
<Avatar>
<AvatarImage src="https://github.com/mscode07.png" />
<AvatarFallback>ON</AvatarFallback>
</Avatar>
</div>
);
}
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,16 @@
resolved "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.1.1.tgz"
integrity sha512-SJ31y+Q/zAyShtXJc8x83i9TYdbAfHZ++tUZnvjJJqFjzsdUnKsxPL6IEtBlxKkU7yzer//GQtZSV4GbldL3YA==

"@radix-ui/react-avatar@^1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@radix-ui/react-avatar/-/react-avatar-1.1.2.tgz#24af4c66bb5271460a4a6b74c4f4f9d4789d3d90"
integrity sha512-GaC7bXQZ5VgZvVvsJ5mu/AEbjYLnhhkoidOboC50Z6FFlLA03wG2ianUoH+zgDQ31/9gCF59bE4+2bBgTyMiig==
dependencies:
"@radix-ui/react-context" "1.1.1"
"@radix-ui/react-primitive" "2.0.1"
"@radix-ui/react-use-callback-ref" "1.1.0"
"@radix-ui/react-use-layout-effect" "1.1.0"

"@radix-ui/[email protected]":
version "1.1.1"
resolved "https://registry.npmjs.org/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.1.tgz"
Expand Down
Loading