-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1468a44
commit e27d460
Showing
14 changed files
with
252 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
@import "../assets/custom.scss"; | ||
|
||
.lds-ring { | ||
display: inline-block; | ||
position: relative; | ||
width: 80px; | ||
height: 80px; | ||
} | ||
|
||
.lds-ring div { | ||
box-sizing: border-box; | ||
display: block; | ||
position: absolute; | ||
width: 64px; | ||
height: 64px; | ||
margin: 8px; | ||
border: 8px solid $primary; | ||
border-radius: 50%; | ||
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite; | ||
border-color: $primary transparent transparent transparent; | ||
} | ||
|
||
.lds-ring div:nth-child(1) { | ||
animation-delay: -0.45s; | ||
} | ||
|
||
.lds-ring div:nth-child(2) { | ||
animation-delay: -0.3s; | ||
} | ||
|
||
.lds-ring div:nth-child(3) { | ||
animation-delay: -0.15s; | ||
} | ||
|
||
@keyframes lds-ring { | ||
0% { | ||
transform: rotate(0deg); | ||
} | ||
|
||
100% { | ||
transform: rotate(360deg); | ||
} | ||
} |
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,9 @@ | ||
import "./Spinner.scss"; | ||
|
||
export const Spinner = () => { | ||
return ( | ||
<div className="d-flex justify-content-center"> | ||
<div className="lds-ring"><div></div><div></div><div></div><div></div></div> | ||
</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,9 @@ | ||
export interface Donation { | ||
id: number; | ||
eventID: number; | ||
teamID: number; | ||
personID: number; | ||
date: string; | ||
amount: number; | ||
isPending: boolean; | ||
} |
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,11 @@ | ||
|
||
export interface Event { | ||
date: Date; | ||
title?: string; | ||
location?: string; | ||
description?: string; | ||
mainImage?: string; | ||
donationTarget: number; | ||
isArchived?: boolean; | ||
id: number; | ||
} |
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,33 @@ | ||
import { FC } from "react" | ||
import { Event } from "../../models/Event" | ||
import { useGetEventDonationQuery } from "./homeHooks"; | ||
import { Spinner } from "../../components/Spinner"; | ||
|
||
export const DonationProgess: FC<{ | ||
event?: Event | ||
}> = ({ event }) => { | ||
const getEventDonationQuery = useGetEventDonationQuery(event?.id); | ||
|
||
if (getEventDonationQuery.isLoading) return <Spinner /> | ||
if (!event) return <div className="fs-5">No Event Donations</div> | ||
|
||
const donated = getEventDonationQuery.data ? Math.round(getEventDonationQuery.data / event?.donationTarget * 100) : 0 | ||
|
||
return ( | ||
<> | ||
<div className="fs-5"><span className="fw-bold">{donated}%</span> of our ${event.donationTarget} goal</div> | ||
<div className="row"> | ||
<div className="col-6 offset-3"> | ||
<div className="progress bg-success-subtle"> | ||
<div className="progress-bar bg-success" | ||
style={{ width: (donated / event.donationTarget * 100) + "%" }} | ||
role="progressbar" | ||
aria-valuenow={donated} | ||
aria-valuemin={1} | ||
aria-valuemax={event.donationTarget} /> | ||
</div> | ||
</div> | ||
</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
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,24 @@ | ||
import { useQuery } from "@tanstack/react-query" | ||
import { homeService } from "./homeService" | ||
|
||
export const eventsKey = { | ||
eventsKey: ["events"] as const, | ||
eventDonationKey: (id?: number) => ["eventDonation", id] as const, | ||
} | ||
|
||
export const useGetEventsQuery = () => { | ||
return useQuery({ | ||
queryKey: eventsKey.eventsKey, | ||
queryFn: async () => await homeService.getEvents(), | ||
}); | ||
} | ||
|
||
export const useGetEventDonationQuery = (id?: number) => { | ||
return useQuery({ | ||
queryKey: eventsKey.eventDonationKey(id), | ||
queryFn: async () => { | ||
if (!id) return; | ||
return await homeService.getEventDonation(id) | ||
}, | ||
}); | ||
} |
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,16 @@ | ||
import axios from "axios" | ||
import { Event } from "../../models/Event"; | ||
import { Donation } from "../../models/Donation"; | ||
|
||
export const homeService = { | ||
async getEvents(): Promise<Event[]> { | ||
const url = "/api/events" | ||
const response = await axios.get(url); | ||
return response.data | ||
}, | ||
async getEventDonation(id: number): Promise<number> { | ||
const url = `/api/donations/event/${id}` | ||
const response = await axios.get(url); | ||
return response.data | ||
}, | ||
} |
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,10 @@ | ||
const { createProxyMiddleware } = require("http-proxy-middleware"); | ||
|
||
module.exports = function (app) { | ||
app.use( | ||
["/swagger", "/api/"], | ||
createProxyMiddleware({ | ||
target: "http://localhost:5238", | ||
}) | ||
) | ||
} |
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 |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
"jsx": "react-jsx" | ||
}, | ||
"include": [ | ||
"src" | ||
"src", | ||
"setupProxy.js" | ||
] | ||
} | ||
} |