Skip to content

Commit

Permalink
Merge pull request #56 from Build-Squad/GEN-95-Influencer-Profile-Page
Browse files Browse the repository at this point in the history
Gen 95 influencer profile page
  • Loading branch information
muditmahajan authored Dec 28, 2023
2 parents 87fa5e7 + 1be4f61 commit d2be0a9
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 157 deletions.
8 changes: 8 additions & 0 deletions src/api/marketplace/marketplace/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@
"http://127.0.0.1:3000",
]

CSRF_TRUSTED_ORIGINS = [
"http://localhost:3000",
"https://dev.xfluencer.io",
"https://xfluencer.io",
"https://13.41.134.64",
"http://127.0.0.1:3000",
]

CORS_ALLOW_CREDENTIALS = True

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
Expand Down
6 changes: 5 additions & 1 deletion src/api/marketplace/packages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ def delete(self, request, pk):

# Service
class ServiceList(APIView):
def get_authenticators(self):
if self.request.method == 'POST':
return [JWTAuthentication()]
return super().get_authenticators()

def get(self, request):
try:
search = request.GET.get("search", "")
Expand Down Expand Up @@ -186,7 +191,6 @@ def get(self, request):
except Exception as e:
return handleServerException(e)

authentication_classes = [JWTAuthentication]
@swagger_auto_schema(request_body=CreateServicesSerializer)
def post(self, request):
try:
Expand Down
2 changes: 1 addition & 1 deletion src/ui/app/components/navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default function Navbar({
color="inherit"
sx={{ fontSize: "16px" }}
onClick={() => {
window.location.href = `/influencer/profile/${currentUser?.id}}/services`;
window.location.href = `/influencer/profile/${currentUser?.id}`;
}}
>
Profile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Packages = ({
{
page_number: pagination.current_page_number,
page_size: pagination.current_page_size,
influencer: decodeURIComponent(params.id),
influencer: params.id,
}
);
if (isSuccess) {
Expand Down Expand Up @@ -124,9 +124,7 @@ const Packages = ({
<Grid container spacing={2}>
{loading ? null : (
<>
{decodeURIComponent(params.id).includes(
currentUser?.id ? currentUser?.id : ""
) && (
{params?.id === currentUser?.id && (
<Grid item xs={12} sm={6} md={4} lg={4}>
<Card
sx={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ import {
import Image from "next/image";
import React, { useEffect } from "react";

const Services = ({
params,
}: {
params: {
id: string;
};
}) => {
type ServiceProps = {
currentUser: UserType | null;
id: string;
};

const Services = ({ currentUser, id }: ServiceProps) => {
const [loggedInUser, setLoggedInUser] = React.useState<UserType | null>(null);
const [type, setType] = React.useState<string | null>(null);
const [currentUser, setCurrentUser] = React.useState<UserType | null>(null);
const [checkedOutServices, setCheckedOutServices] = React.useState<
ServiceType[]
>([]);
Expand All @@ -57,8 +56,8 @@ const Services = ({
{
page_number: pagination.current_page_number,
page_size: pagination.current_page_size,
influencer: decodeURIComponent(params.id),
status: type,
influencer: id,
status: id === loggedInUser?.id ? type : "published",
}
);
if (isSuccess) {
Expand Down Expand Up @@ -127,9 +126,8 @@ const Services = ({
}, [openModal]);

useEffect(() => {
if (localStorage.getItem("user")) {
setCurrentUser(JSON.parse(localStorage.getItem("user") || "{}"));
}
const user = JSON.parse(localStorage.getItem("user") || "{}");
setLoggedInUser(user);
}, []);

return (
Expand All @@ -140,57 +138,57 @@ const Services = ({
}}
>
<Grid container>
<Grid item xs={12}>
<ButtonGroup
aria-label="outlined primary button group"
sx={{
mb: 2,
borderRadius: 8,
display: "flex",
justifyContent: "center",
}}
>
<Button
variant={type === null ? "contained" : "outlined"}
color="secondary"
onClick={() => {
setType(null);
}}
sx={{
borderRadius: "20px 0px 0px 20px",
}}
>
All
</Button>
<Button
variant={type === "published" ? "contained" : "outlined"}
color="secondary"
onClick={() => {
setType("published");
}}
>
Published
</Button>
<Button
variant={type === "draft" ? "contained" : "outlined"}
color="secondary"
onClick={() => {
setType("draft");
}}
{id === loggedInUser?.id && (
<Grid item xs={12}>
<ButtonGroup
aria-label="outlined primary button group"
sx={{
borderRadius: "0px 20px 20px 0px",
mb: 2,
borderRadius: 8,
display: "flex",
justifyContent: "center",
}}
>
Draft
</Button>
</ButtonGroup>
</Grid>
<Button
variant={type === null ? "contained" : "outlined"}
color="secondary"
onClick={() => {
setType(null);
}}
sx={{
borderRadius: "20px 0px 0px 20px",
}}
>
All
</Button>
<Button
variant={type === "published" ? "contained" : "outlined"}
color="secondary"
onClick={() => {
setType("published");
}}
>
Published
</Button>
<Button
variant={type === "draft" ? "contained" : "outlined"}
color="secondary"
onClick={() => {
setType("draft");
}}
sx={{
borderRadius: "0px 20px 20px 0px",
}}
>
Draft
</Button>
</ButtonGroup>
</Grid>
)}
<Grid container spacing={2}>
{loading ? null : (
<>
{decodeURIComponent(params.id).includes(
currentUser?.id ? currentUser?.id : ""
) && (
{id === loggedInUser?.id && (
<Grid item xs={12} sm={6} md={4} lg={4}>
<Card
sx={{
Expand Down Expand Up @@ -277,7 +275,7 @@ const Services = ({
>
{service?.package?.name}
</Typography>
{service.package.influencer === currentUser?.id && (
{service.package.influencer === loggedInUser?.id && (
<Chip
sx={{
mr: 2,
Expand All @@ -303,7 +301,7 @@ const Services = ({
alignItems: "center",
}}
>
{service.package.influencer === currentUser?.id && (
{service.package.influencer === loggedInUser?.id ? (
<Box
sx={{
display: "flex",
Expand Down Expand Up @@ -350,6 +348,23 @@ const Services = ({
}
/>
</Box>
) : (
<Box
sx={{
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
<Typography
sx={{ fontWeight: "bold" }}
variant="h6"
>
{service?.platform_price +
" " +
service?.currency?.symbol}
</Typography>
</Box>
)}
</Box>
</Box>
Expand All @@ -376,7 +391,7 @@ const Services = ({
justifyContent: "space-between",
}}
>
{service.package.influencer === currentUser?.id ? (
{service.package.influencer === loggedInUser?.id ? (
<Box
sx={{
display: "flex",
Expand Down Expand Up @@ -451,7 +466,7 @@ const Services = ({
]);
}}
disabled={
service.package.influencer === currentUser?.id
service.package.influencer === loggedInUser?.id
}
>
Add to Cart
Expand All @@ -472,7 +487,7 @@ const Services = ({
]);
}}
disabled={
service.package.influencer === currentUser?.id
service.package.influencer === loggedInUser?.id
}
>
Buy Now
Expand Down
Loading

0 comments on commit d2be0a9

Please sign in to comment.