-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'npo-funds' into FB-fundraisers
- Loading branch information
Showing
8 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import ContentLoader from "components/ContentLoader"; | ||
import Image from "components/Image"; | ||
import QueryLoader from "components/QueryLoader"; | ||
import { appRoutes } from "constants/routes"; | ||
import { useAuthenticatedUser } from "contexts/Auth"; | ||
import { Link } from "react-router-dom"; | ||
import { useFundsEndowMemberOfQuery } from "services/aws/aws"; | ||
import type { Fund } from "types/aws"; | ||
import { useAdminContext } from "../../Context"; | ||
|
||
export function Funds() { | ||
const { id } = useAdminContext(); | ||
const query = useFundsEndowMemberOfQuery({ endowId: id }); | ||
return ( | ||
<div className="grid gap-y-4 grid-cols-[auto_auto_1fr_auto_auto] justify-items-start"> | ||
<h3 className="text-3xl mb-2 col-span-full">My Fundraisers</h3> | ||
|
||
<QueryLoader | ||
messages={{ | ||
loading: ( | ||
<> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
</> | ||
), | ||
error: "Failed to get fundraisers", | ||
empty: "No fundraisers found.", | ||
}} | ||
queryState={query} | ||
> | ||
{(funds) => ( | ||
<> | ||
{funds.map((fund) => ( | ||
<FundItem key={fund.id} {...fund} /> | ||
))} | ||
</> | ||
)} | ||
</QueryLoader> | ||
</div> | ||
); | ||
} | ||
|
||
const FundItem = (props: Fund.Card) => { | ||
const user = useAuthenticatedUser(); | ||
const isActive = new Date().toISOString() <= props.expiration && props.active; | ||
const isEditor = user.funds.includes(props.id); | ||
|
||
return ( | ||
<div className="grid grid-cols-subgrid col-span-5 items-center gap-3 rounded border border-gray-l4"> | ||
<Image src={props.logo} className="object-cover h-full w-10" /> | ||
<span className="mr-4 p-1.5 font-medium text-navy-l1">{props.name}</span> | ||
<p | ||
className={`uppercase justify-self-start text-2xs rounded-full px-3 py-0.5 ${ | ||
isActive ? "text-green bg-green-l4" : "text-red bg-red-l4" | ||
}`} | ||
> | ||
{isActive ? "active" : "closed"} | ||
</p> | ||
<Link | ||
aria-disabled={!isActive || !isEditor} | ||
className={`text-sm hover:text-blue-d1 text-blue uppercase p-3 aria-disabled:pointer-events-none aria-disabled:text-gray ${ | ||
isEditor ? "" : "invisible" | ||
}`} | ||
to={`${appRoutes.funds}/${props.id}/edit`} | ||
> | ||
edit | ||
</Link> | ||
<Link | ||
className="text-sm hover:text-blue-d1 text-blue uppercase p-3" | ||
to={`${appRoutes.funds}/${props.id}`} | ||
> | ||
view | ||
</Link> | ||
</div> | ||
); | ||
}; | ||
|
||
export function Skeleton() { | ||
return ( | ||
<div | ||
className="flex items-center gap-x-2 w-full col-span-full" | ||
aria-disabled={true} | ||
> | ||
<ContentLoader className="size-10 rounded-full" /> | ||
<ContentLoader className="w-full h-10 rounded" /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Funds as Component } from "./Funds"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters