Skip to content

Commit

Permalink
Merge pull request #48 from Build-Squad/GEN-93-UI-Account-Category
Browse files Browse the repository at this point in the history
Gen 93 UI account category
  • Loading branch information
muditmahajan authored Dec 21, 2023
2 parents b24f324 + f6ee0ec commit 2580e71
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/api/marketplace/marketplace/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)


Expand Down Expand Up @@ -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"
)


Expand Down Expand Up @@ -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"
)


Expand All @@ -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
Expand All @@ -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"
)
4 changes: 2 additions & 2 deletions src/ui/app/components/analyticsContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const AnalyticsContainer = () => (
}}
>
<AnalyticsItem value="15 M" subtitle="Total Influencer’s on X" />
<AnalyticsItem value="500 K" subtitle="Influencers Database on Xfluence" />
<AnalyticsItem value="2 M" subtitle="Avg. following of a XInfluencer" />
<AnalyticsItem value="500 K" subtitle="Influencers Database on Xfluencer" />
<AnalyticsItem value="2 M" subtitle="Avg. following of a Xfluencer" />
<Grid item xs={12} sm={12} md={3} lg={3}>
<Typography variant="h4" fontWeight="bold">
15 M
Expand Down
13 changes: 11 additions & 2 deletions src/ui/app/components/navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function Navbar({
</Box>
<Box sx={{ width: "33%", textAlign: "right" }}>
<Button color="inherit" sx={{ fontSize: "16px" }}>
Why XFluence
Why XFluencer
</Button>
<Button
color="inherit"
Expand Down Expand Up @@ -120,7 +120,16 @@ export default function Navbar({
border: "1px solid black",
},
}}
onClick={logout}
onClick={() => {
logout();
if (pathname.includes("influencer")) {
router.push("/influencer");
} else if (pathname.includes("business")) {
router.push("/business");
} else {
router.push("/");
}
}}
>
Logout
</Button>
Expand Down
9 changes: 9 additions & 0 deletions src/ui/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"] });

Expand All @@ -34,6 +35,7 @@ export default function RootLayout({
});

const [emailOpen, setEmailOpen] = useState<boolean>(false);
const [categoryOpen, setCategoryOpen] = useState<boolean>(false);

// Twitter authentication hook
const {
Expand All @@ -52,6 +54,9 @@ export default function RootLayout({
status == "success" ? LOGIN_STATUS_SUCCESS : LOGIN_STATUS_FAILED,
});
}
if (isTwitterUserLoggedIn && status == "success") {
setCategoryOpen(true);
}
}, [isTwitterUserLoggedIn]);

useEffect(() => {
Expand Down Expand Up @@ -93,6 +98,10 @@ export default function RootLayout({
/>
) : null}
<EmailLoginModal open={emailOpen} setOpen={setEmailOpen} />
<CategorySelectionModal
open={categoryOpen}
setOpen={setCategoryOpen}
/>
</ThemeRegistry>
</SnackbarProvider>
</body>
Expand Down
155 changes: 155 additions & 0 deletions src/ui/src/components/categorySelectionModal/index.tsx
Original file line number Diff line number Diff line change
@@ -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<React.SetStateAction<boolean>>;
};

const steps = ["Add Categories", "Connect Wallet"];

export default function CategorySelectionModal({
open,
setOpen,
}: CategorySelectionModalProps) {
const [search, setSearch] = React.useState<string>("");
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 (
<CustomModal
open={open}
setOpen={setOpen}
sx={{
p: 2,
border: "1px solid black",
minHeight: "40vh",
}}
>
<Grid container sx={{ p: 2 }}>
<Grid item xs={12} sx={{ mb: 2 }}>
<Box sx={{ display: "flex", justifyContent: "center" }}>
<Image src={Star_Coloured} alt={"Coloured Start"} height={30} />
<Typography variant="h5" sx={{ ml: 2, fontWeight: "bold" }}>
{"Let's set up your Account"}
</Typography>
</Box>
</Grid>
<Grid item xs={12}>
<FormLabel
sx={{
fontWeight: "bold",
my: 2,
}}
>
I create content about...
</FormLabel>
<TextField
fullWidth
placeholder="Search category"
variant="outlined"
size="small"
sx={{
my: 2,
"& .MuiOutlinedInput-root": {
borderRadius: 8,
},
}}
value={search}
onChange={(e) => {
setSearch(e.target.value);
}}
/>
{categoryMasters.map((categoryMaster) => {
return (
<>
{categoryMaster?.name?.includes(search) && (
<Chip
key={categoryMaster.id}
label={categoryMaster.name}
sx={{ m: 1 }}
color="secondary"
variant={
selectedCategories.includes(categoryMaster)
? "filled"
: "outlined"
}
onClick={() => {
if (selectedCategories.includes(categoryMaster)) {
setSelectedCategories(
selectedCategories.filter(
(category) => category.id !== categoryMaster.id
)
);
} else {
setSelectedCategories([
...selectedCategories,
categoryMaster,
]);
}
}}
/>
)}
</>
);
})}
</Grid>
<Grid item xs={12} sx={{ mt: 2 }}>
<Button
variant="contained"
color="secondary"
fullWidth
sx={{ borderRadius: 8 }}
disabled={selectedCategories.length === 0}
onClick={onSubmit}
>
Save
</Button>
</Grid>
</Grid>
</CustomModal>
);
}
1 change: 1 addition & 0 deletions src/ui/src/hooks/useTwitterAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 2580e71

Please sign in to comment.