Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix(create_campaign): users could now create campaign #455

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions frontend/src/components/CampaignCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ const CampaignCard = ({
/>
);

const linkComponent = isAdmin ? (
<Link to={`/admin/review/${campaignId}`}>{content}</Link>
) : (
<Link to={`/application/${campaignId}`}>{content}</Link>
);

return (
<>
{campaignId === undefined ? (
content
) : (
<Link to={`/application/${campaignId}`}>{content}</Link>
)}
{campaignId === undefined ? content : linkComponent}
{popup}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Props = {
};

const AdminCampaignContent = ({ campaigns, setCampaigns, orgLogo }: Props) => (
<div tw="flex flex-wrap gap-4">
<div tw="flex flex-wrap gap-4 ml-20">
{campaigns.map((c) => (
<CampaignCard
key={c.id}
Expand Down
41 changes: 27 additions & 14 deletions frontend/src/pages/admin/AdminContent/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { PencilIcon } from "@heroicons/react/24/solid";
import { PencilIcon, PlusIcon } from "@heroicons/react/24/solid";
import { DeleteForeverRounded } from "@mui/icons-material";
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";
Expand Down Expand Up @@ -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);
Expand All @@ -65,7 +69,7 @@ const AdminContent = ({
useEffect(() => {
if (orgLogo === undefined) {
// have to be consistent in returning a function to make eslint happy
return () => { };
return () => {};
}

const reader = new FileReader();
Expand Down Expand Up @@ -185,6 +189,15 @@ const AdminContent = ({
>
<PencilIcon tw="w-8 h-8" />
</button>
<button
tw="text-gray-500 hover:text-gray-800 transition-colors"
type="button"
onClick={() => navigate(`/campaign/create/${id}`)}
>
<PlusIcon tw="w-12 h-12" />
</button>
{/* have to add addition button here to create campaigns,
or maybe it should go in a more obvious spot? */}
<ToggleButtonContainer>
<ToggleButtonGroup
color="primary"
Expand All @@ -207,23 +220,23 @@ const AdminContent = ({
</ToggleButtonContainer>
</div>
</ContentHeader>
<ContentBody>
{windowSelected === "campaigns" && (
<AdminCampaignContent
campaigns={campaigns}
setCampaigns={setCampaigns}
orgId={id}
orgLogo={icon}
/>
)}
{windowSelected === "members" && (
{windowSelected === "campaigns" && (
<AdminCampaignContent
campaigns={campaigns}
setCampaigns={setCampaigns}
orgId={id}
orgLogo={icon}
/>
)}
{windowSelected === "members" && (
<ContentBody>
<AdminMembersContent
orgId={id}
members={members}
setMembers={setMembers}
/>
)}
</ContentBody>
</ContentBody>
)}

<Modal
open={showEditDialog}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/create_campaign/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ const CreateCampaign = () => {
questionsSend
);
await setCampaignCoverImage(campaignId, cover);
navigate("/admin");
} catch (err) {
if (err instanceof FetchError) {
try {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/dashboard/CampaignGrid/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const CampaignGrid = ({
/>
</Transition>
))}
</div >
</div>
);
};

Expand Down
Loading