From adc3d58ac1e6a8376e052309b163770f77444316 Mon Sep 17 00:00:00 2001 From: kumsuzCode Date: Wed, 20 Sep 2023 16:22:32 +1000 Subject: [PATCH 1/2] fix(fe): Redirect campaign card link to correct page --- .../src/components/CampaignCard/index.tsx | 12 +++--- .../AdminContent/AdminCampaignContent.tsx | 2 +- .../src/pages/admin/AdminContent/index.tsx | 37 ++++++++++++------- .../pages/dashboard/CampaignGrid/index.tsx | 2 +- 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/frontend/src/components/CampaignCard/index.tsx b/frontend/src/components/CampaignCard/index.tsx index 813398d0..f22e38e7 100644 --- a/frontend/src/components/CampaignCard/index.tsx +++ b/frontend/src/components/CampaignCard/index.tsx @@ -81,13 +81,15 @@ const CampaignCard = ({ /> ); + const linkComponent = isAdmin ? ( + {content} + ) : ( + {content} + ); + return ( <> - {campaignId === undefined ? ( - content - ) : ( - {content} - )} + {campaignId === undefined ? content : linkComponent} {popup} ); diff --git a/frontend/src/pages/admin/AdminContent/AdminCampaignContent.tsx b/frontend/src/pages/admin/AdminContent/AdminCampaignContent.tsx index 05f28ee7..e5ca4208 100644 --- a/frontend/src/pages/admin/AdminContent/AdminCampaignContent.tsx +++ b/frontend/src/pages/admin/AdminContent/AdminCampaignContent.tsx @@ -13,7 +13,7 @@ type Props = { }; const AdminCampaignContent = ({ campaigns, setCampaigns, orgLogo }: Props) => ( -
+
{campaigns.map((c) => ( { if (orgLogo === undefined) { // have to be consistent in returning a function to make eslint happy - return () => { }; + return () => {}; } const reader = new FileReader(); @@ -185,6 +185,15 @@ const AdminContent = ({ > + + {/* have to add addition button here to create campaigns, + or maybe it should go in a more obvious spot? */}
- - {windowSelected === "campaigns" && ( - - )} - {windowSelected === "members" && ( + {windowSelected === "campaigns" && ( + + )} + {windowSelected === "members" && ( + - )} - + + )} ))} -
+ ); }; From 9c0153e1da779d04241c016e4ec423e05efd2882 Mon Sep 17 00:00:00 2001 From: m4ch374 Date: Tue, 26 Sep 2023 13:54:46 +1000 Subject: [PATCH 2/2] hotfix(create_campagin): users could now create campaign --- frontend/src/pages/admin/AdminContent/index.tsx | 6 +++++- frontend/src/pages/create_campaign/index.tsx | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/admin/AdminContent/index.tsx b/frontend/src/pages/admin/AdminContent/index.tsx index 37d36c9f..7ae479b0 100644 --- a/frontend/src/pages/admin/AdminContent/index.tsx +++ b/frontend/src/pages/admin/AdminContent/index.tsx @@ -4,6 +4,8 @@ import { Button, ToggleButton, ToggleButtonGroup } from "@mui/material"; import { useContext, useEffect, useState } from "react"; import "twin.macro"; +import { useNavigate } from "react-router-dom"; + import { doDeleteOrg, putOrgLogo } from "api"; import { FetchError } from "api/api"; import { Modal } from "components"; @@ -54,6 +56,8 @@ const AdminContent = ({ orgName = "..."; } + const navigate = useNavigate(); + const [windowSelected, setWindowSelected] = useState("campaigns"); const [showDeleteDialog, setShowDeleteDialog] = useState(false); const [showEditDialog, setShowEditDialog] = useState(false); @@ -188,7 +192,7 @@ const AdminContent = ({ diff --git a/frontend/src/pages/create_campaign/index.tsx b/frontend/src/pages/create_campaign/index.tsx index 5adfb637..7f31f666 100644 --- a/frontend/src/pages/create_campaign/index.tsx +++ b/frontend/src/pages/create_campaign/index.tsx @@ -234,6 +234,7 @@ const CreateCampaign = () => { questionsSend ); await setCampaignCoverImage(campaignId, cover); + navigate("/admin"); } catch (err) { if (err instanceof FetchError) { try {