From 1ccf010f539d9cd9a259522963e5d89bcbbfae51 Mon Sep 17 00:00:00 2001 From: Mudit Mahajan Date: Thu, 21 Dec 2023 12:43:12 +0530 Subject: [PATCH 1/3] Fix typo in AnalyticsContainer component --- src/ui/app/components/analyticsContainer/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/app/components/analyticsContainer/index.tsx b/src/ui/app/components/analyticsContainer/index.tsx index a8960641..7e0cb24f 100644 --- a/src/ui/app/components/analyticsContainer/index.tsx +++ b/src/ui/app/components/analyticsContainer/index.tsx @@ -46,8 +46,8 @@ const AnalyticsContainer = () => ( }} > - - + + 15 M From 8546134a3f486738b5b264e187550c48188a7866 Mon Sep 17 00:00:00 2001 From: Mudit Mahajan Date: Thu, 21 Dec 2023 13:02:38 +0530 Subject: [PATCH 2/3] Update views and components --- src/api/marketplace/marketplace/views.py | 2 +- src/ui/app/components/navbar/index.tsx | 13 +- src/ui/app/layout.tsx | 7 + .../categorySelectionModal/index.tsx | 155 ++++++++++++++++++ src/ui/src/hooks/useTwitterAuth.ts | 1 + 5 files changed, 175 insertions(+), 3 deletions(-) create mode 100644 src/ui/src/components/categorySelectionModal/index.tsx diff --git a/src/api/marketplace/marketplace/views.py b/src/api/marketplace/marketplace/views.py index 5006ebfd..060d8922 100644 --- a/src/api/marketplace/marketplace/views.py +++ b/src/api/marketplace/marketplace/views.py @@ -57,7 +57,7 @@ def twitterLoginCallback(request): except Exception as e: print("Error in twitterLoginCallback -", e) return HttpResponseRedirect( - config("FRONT_END_URL") + "business/?authenticationStatus=error" + config("FRONT_END_URL") + "influencer/?authenticationStatus=error" ) diff --git a/src/ui/app/components/navbar/index.tsx b/src/ui/app/components/navbar/index.tsx index f4a573b4..5881cf1e 100644 --- a/src/ui/app/components/navbar/index.tsx +++ b/src/ui/app/components/navbar/index.tsx @@ -80,7 +80,7 @@ export default function Navbar({ diff --git a/src/ui/app/layout.tsx b/src/ui/app/layout.tsx index 4f3a9931..02026405 100644 --- a/src/ui/app/layout.tsx +++ b/src/ui/app/layout.tsx @@ -13,6 +13,7 @@ import SnackbarComp from "@/src/components/shared/snackBarComp"; import useTwitterAuth from "@/src/hooks/useTwitterAuth"; import { LOGIN_STATUS_FAILED, LOGIN_STATUS_SUCCESS } from "@/src/utils/consts"; import EmailLoginModal from "@/src/components/emailLoginModal"; +import CategorySelectionModal from "@/src/components/categorySelectionModal"; const inter = Inter({ subsets: ["latin"] }); @@ -34,6 +35,7 @@ export default function RootLayout({ }); const [emailOpen, setEmailOpen] = useState(false); + const [categoryOpen, setCategoryOpen] = useState(false); // Twitter authentication hook const { @@ -51,6 +53,7 @@ export default function RootLayout({ message: status == "success" ? LOGIN_STATUS_SUCCESS : LOGIN_STATUS_FAILED, }); + setCategoryOpen(true); } }, [isTwitterUserLoggedIn]); @@ -93,6 +96,10 @@ export default function RootLayout({ /> ) : null} + diff --git a/src/ui/src/components/categorySelectionModal/index.tsx b/src/ui/src/components/categorySelectionModal/index.tsx new file mode 100644 index 00000000..d84a201a --- /dev/null +++ b/src/ui/src/components/categorySelectionModal/index.tsx @@ -0,0 +1,155 @@ +"use client"; + +import Star_Coloured from "@/public/svg/Star_Coloured.svg"; +import { getService } from "@/src/services/httpServices"; +import { + Box, + Button, + Chip, + FormLabel, + Grid, + TextField, + Typography, +} from "@mui/material"; +import Image from "next/image"; +import React, { useEffect } from "react"; +import CustomModal from "../shared/customModal"; +import { notification } from "../shared/notification"; + +type CategorySelectionModalProps = { + open: boolean; + setOpen: React.Dispatch>; +}; + +const steps = ["Add Categories", "Connect Wallet"]; + +export default function CategorySelectionModal({ + open, + setOpen, +}: CategorySelectionModalProps) { + const [search, setSearch] = React.useState(""); + const [categoryMasters, setCategoryMasters] = React.useState< + CategoryMasterType[] + >([]); + const [selectedCategories, setSelectedCategories] = React.useState< + CategoryMasterType[] + >([]); + const [activeStep, setActiveStep] = React.useState(0); + + const getCategoryMasters = async () => { + const { isSuccess, data, message } = await getService( + "/account/category-master/", + { + page_size: 100, + page_number: 1, + } + ); + if (isSuccess) { + setCategoryMasters(data?.data); + } else { + notification(message ? message : "Something went wrong", "error"); + } + }; + + const onSubmit = () => { + setOpen(false); + }; + + useEffect(() => { + getCategoryMasters(); + }, []); + + return ( + + + + + {"Coloured + + {"Let's set up your Account"} + + + + + + I create content about... + + { + setSearch(e.target.value); + }} + /> + {categoryMasters.map((categoryMaster) => { + return ( + <> + {categoryMaster?.name?.includes(search) && ( + { + if (selectedCategories.includes(categoryMaster)) { + setSelectedCategories( + selectedCategories.filter( + (category) => category.id !== categoryMaster.id + ) + ); + } else { + setSelectedCategories([ + ...selectedCategories, + categoryMaster, + ]); + } + }} + /> + )} + + ); + })} + + + + + + + ); +} diff --git a/src/ui/src/hooks/useTwitterAuth.ts b/src/ui/src/hooks/useTwitterAuth.ts index 73ad58c1..d4f3e183 100644 --- a/src/ui/src/hooks/useTwitterAuth.ts +++ b/src/ui/src/hooks/useTwitterAuth.ts @@ -29,6 +29,7 @@ export default function useTwitterAuth() { await axios.get(`${BACKEND_URL}logout/`, { withCredentials: true }); notification("Logged out successfully"); setTwitterUserLoggedIn(false); + localStorage.clear(); } catch (error) { console.error("Error during logout:", error); } From f6ee0ec96e49a78a5c5087ced8cb8b00277060ff Mon Sep 17 00:00:00 2001 From: Mudit Mahajan Date: Thu, 21 Dec 2023 13:14:49 +0530 Subject: [PATCH 3/3] Update authentication redirect URLs for influencer --- src/api/marketplace/marketplace/views.py | 8 ++++---- src/ui/app/layout.tsx | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/api/marketplace/marketplace/views.py b/src/api/marketplace/marketplace/views.py index 060d8922..aff43674 100644 --- a/src/api/marketplace/marketplace/views.py +++ b/src/api/marketplace/marketplace/views.py @@ -87,7 +87,7 @@ def authenticateUser(authorization_response_url): except Exception as e: print("Error authenticating User -", e) return HttpResponseRedirect( - config("FRONT_END_URL") + "business/?authenticationStatus=error" + config("FRONT_END_URL") + "influencer/?authenticationStatus=error" ) @@ -158,7 +158,7 @@ def createUser(userData, access_token): except Exception as e: print("Error creating/updating user account -", e) return HttpResponseRedirect( - config("FRONT_END_URL") + "business/?authenticationStatus=error" + config("FRONT_END_URL") + "influencer/?authenticationStatus=error" ) @@ -169,7 +169,7 @@ def createJWT(userData, access_token): # Creating a response object with JWT cookie response = redirect( - f"{config('FRONT_END_URL')}business/?authenticationStatus=success" + f"{config('FRONT_END_URL')}influencer/?authenticationStatus=success" ) # Convert the UUID to string @@ -189,5 +189,5 @@ def createJWT(userData, access_token): except Exception as e: print("Error while creating jwt - ", e) return redirect( - f"{config('FRONT_END_URL')}business/?authenticationStatus=error" + f"{config('FRONT_END_URL')}influencer/?authenticationStatus=error" ) diff --git a/src/ui/app/layout.tsx b/src/ui/app/layout.tsx index 02026405..088fedbf 100644 --- a/src/ui/app/layout.tsx +++ b/src/ui/app/layout.tsx @@ -53,6 +53,8 @@ export default function RootLayout({ message: status == "success" ? LOGIN_STATUS_SUCCESS : LOGIN_STATUS_FAILED, }); + } + if (isTwitterUserLoggedIn && status == "success") { setCategoryOpen(true); } }, [isTwitterUserLoggedIn]);