From 71e4f0fed6c0024fe53fbb6ea10bfac249e4c4b8 Mon Sep 17 00:00:00 2001 From: Rohit Date: Thu, 13 Jun 2024 22:58:53 +0530 Subject: [PATCH] feature/google-login --- app/(auth)/layout.tsx | 7 +- app/oauth2/redirect/page.tsx | 4 +- components/custom/blog/BlogActionButton.tsx | 115 +++++++++++++++--- .../custom/buttons/SocialAuthButtons.tsx | 35 ++++-- components/custom/cards/BlogCard.tsx | 2 +- components/custom/details/BlogDetails.tsx | 24 ++-- .../custom/drawers/BlogCommentDrawer.tsx | 94 ++++++++++++++ .../drawers/BlogCommentMobileDrawer.tsx | 41 +++++++ components/custom/forms/LoginForm.tsx | 2 +- constants/ApiEndpointConstants.tsx | 1 + package-lock.json | 25 +++- package.json | 4 +- rest/AuthProviderApplication.tsx | 13 +- 13 files changed, 320 insertions(+), 47 deletions(-) create mode 100644 components/custom/drawers/BlogCommentDrawer.tsx create mode 100644 components/custom/drawers/BlogCommentMobileDrawer.tsx diff --git a/app/(auth)/layout.tsx b/app/(auth)/layout.tsx index b532e22..b4157e9 100644 --- a/app/(auth)/layout.tsx +++ b/app/(auth)/layout.tsx @@ -9,6 +9,7 @@ import {ApplicationProvider} from "@/providers/ApplicationProvider"; import BloggiosToast from "@/components/custom/BloggiosToast"; import {RefreshTokenProvider} from "@/providers/RefreshTokenProvider"; import IsAuthenticated from "@/components/functional/IsAuthenticated"; +import {GoogleOAuthProvider} from "@react-oauth/google"; const poppins = Poppins({ subsets: ["latin"], @@ -39,10 +40,11 @@ export default function RootLayout({ className={`${poppins.variable} relative flex flex-col min-h-screen bg-auth-bg bg-cover bg-no-repeat bg-fixed`}> - + +
- + @@ -65,6 +67,7 @@ export default function RootLayout({ + diff --git a/app/oauth2/redirect/page.tsx b/app/oauth2/redirect/page.tsx index 78fa196..0bd81ff 100644 --- a/app/oauth2/redirect/page.tsx +++ b/app/oauth2/redirect/page.tsx @@ -1,8 +1,7 @@ "use client"; -import {useRouter, useSearchParams} from "next/navigation"; +import {redirect, useRouter, useSearchParams} from "next/navigation"; import {useEffect} from "react"; -import axios from "axios"; import {refreshTokenSocial} from "@/rest/AuthProviderApplication"; const OAuthRedirectHandler = () => { @@ -26,6 +25,7 @@ const OAuthRedirectHandler = () => { refreshTokenSocial(token) .then(response => { window.location.reload(); + redirect("/") }) } else { router.push('/login'); diff --git a/components/custom/blog/BlogActionButton.tsx b/components/custom/blog/BlogActionButton.tsx index cd2c2dd..cbca14d 100644 --- a/components/custom/blog/BlogActionButton.tsx +++ b/components/custom/blog/BlogActionButton.tsx @@ -1,12 +1,26 @@ +"use client"; + import React from 'react'; -import {Button, Divider} from "@nextui-org/react"; +import { + Button, + Divider, + Dropdown, + DropdownItem, + DropdownMenu, + DropdownSection, + DropdownTrigger +} from "@nextui-org/react"; import {SlOptions} from "react-icons/sl"; import {AiOutlineLike} from "react-icons/ai"; -import {HiOutlineChatBubbleOvalLeftEllipsis} from "react-icons/hi2"; import {GoBookmark} from "react-icons/go"; import {IoShareOutline} from "react-icons/io5"; +import {IoIosLink} from "react-icons/io"; +import {FaXTwitter} from "react-icons/fa6"; +import {FaInstagram, FaLinkedin} from "react-icons/fa"; +import BlogCommentDrawer from "@/components/custom/drawers/BlogCommentDrawer"; +import BlogCommentMobileDrawer from "@/components/custom/drawers/BlogCommentMobileDrawer"; -const BlogActionButton = ({isDividerShown = true}: { isDividerShown?: boolean }) => { +const BlogActionButton = ({data, isDividerShown = true}: {data: any, isDividerShown?: boolean }) => { return (
{isDividerShown && } @@ -32,14 +46,14 @@ const BlogActionButton = ({isDividerShown = true}: { isDividerShown?: boolean }) 10 - + +
+ +
+ + 10 + +
@@ -52,14 +66,79 @@ const BlogActionButton = ({isDividerShown = true}: { isDividerShown?: boolean }) > - + + + + + + + + +
+ + Copy Link +
+
+
+ + + +
+ + Share on LinkedIn +
+
+ + +
+ + Share on X +
+
+ + +
+ + Share on Instagram +
+
+
+
+ - - - + ) } \ No newline at end of file diff --git a/components/custom/cards/BlogCard.tsx b/components/custom/cards/BlogCard.tsx index d4ca127..128529e 100644 --- a/components/custom/cards/BlogCard.tsx +++ b/components/custom/cards/BlogCard.tsx @@ -34,7 +34,7 @@ const BlogCard = React.forwardRef((props: BlogCar /> )} - router.push(`/blog/${props.data.blogId}`)}> { - console.log(data); - return (
-
- {data.title} -
+ {data.coverImage && ( +
+ {data.title} +
+ )}

diff --git a/components/custom/drawers/BlogCommentDrawer.tsx b/components/custom/drawers/BlogCommentDrawer.tsx new file mode 100644 index 0000000..4346f12 --- /dev/null +++ b/components/custom/drawers/BlogCommentDrawer.tsx @@ -0,0 +1,94 @@ +import React from 'react'; +import {Sheet, SheetContent, SheetFooter, SheetHeader, SheetTitle, SheetTrigger} from "@/components/ui/sheet"; +import {Avatar, Button, Dropdown, DropdownItem, DropdownMenu, DropdownTrigger} from "@nextui-org/react"; +import {HiOutlineChatBubbleOvalLeftEllipsis} from "react-icons/hi2"; +import {useSelector} from "react-redux"; +import {RootState} from "@/state/store"; +import {Card, CardContent, CardFooter, CardHeader} from "@/components/ui/card"; + +const BlogCommentDrawer = ({data}: { data: any }) => { + + const {isAuthenticated} = useSelector((state: RootState) => state.auth); + const {name, profileImage} = useSelector((state: RootState) => state.profile); + const [selectedKeys, setSelectedKeys] = React.useState(new Set(["relevant"])); + + const selectedValue = React.useMemo( + () => Array.from(selectedKeys).join(", ").replaceAll("_", " "), + [selectedKeys] + ); + + return ( + + + + + + + Discussions + +
+ {isAuthenticated && ( + + +
+ + {name} +
+
+ + +