mirror of
https://github.com/System-End/site.git
synced 2026-04-19 19:45:07 +00:00
remove need for hcb stats page for deploy
This commit is contained in:
parent
5e8e3c0dd1
commit
ebb22163ab
4 changed files with 47 additions and 24 deletions
|
|
@ -43,6 +43,9 @@ function formatMoney(amount) {
|
|||
}
|
||||
|
||||
const Stats = ({ stats }) => {
|
||||
if (stats.transactions_volume === undefined) {
|
||||
return null
|
||||
}
|
||||
const [balance, setBalance] = useState(0) // A formatted balance string, split by decimal
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -64,7 +67,6 @@ const Stats = ({ stats }) => {
|
|||
|
||||
return () => observer.disconnect()
|
||||
}, [stats.transactions_volume])
|
||||
|
||||
return (
|
||||
<Box id="parent">
|
||||
<Flex sx={{ flexDirection: 'column', alignItems: 'center' }}>
|
||||
|
|
@ -103,11 +105,20 @@ const Stats = ({ stats }) => {
|
|||
|
||||
export async function getStaticProps(context) {
|
||||
const res = await fetch(`https://hcb.hackclub.com/stats`)
|
||||
const stats = await res.json()
|
||||
|
||||
return {
|
||||
props: {
|
||||
stats
|
||||
try {
|
||||
const stats = await res.json()
|
||||
return {
|
||||
props: {
|
||||
stats
|
||||
},
|
||||
revalidate: 10
|
||||
}
|
||||
} catch (e) {
|
||||
return {
|
||||
props: {
|
||||
stats: {}
|
||||
},
|
||||
revalidate: 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ export default function Bank({ data }) {
|
|||
color: 'snow'
|
||||
}}
|
||||
badge
|
||||
text={data[0]}
|
||||
text={data[0] === 'error' ? 'The coolest money thing' : data[0]}
|
||||
>
|
||||
<Heading
|
||||
variant="title"
|
||||
|
|
|
|||
|
|
@ -184,12 +184,21 @@ export default function First({ stats }) {
|
|||
|
||||
export async function getStaticProps(context) {
|
||||
const res = await fetch(`https://hcb.hackclub.com/stats`)
|
||||
const stats = await res.json()
|
||||
|
||||
return {
|
||||
props: {
|
||||
stats
|
||||
},
|
||||
revalidate: 10
|
||||
try {
|
||||
const stats = await res.json()
|
||||
return {
|
||||
props: {
|
||||
stats
|
||||
},
|
||||
revalidate: 10
|
||||
}
|
||||
} catch (e) {
|
||||
return {
|
||||
props: {
|
||||
stats: {}
|
||||
},
|
||||
revalidate: 10
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1221,17 +1221,20 @@ export async function getStaticProps() {
|
|||
|
||||
// HCB: get total raised
|
||||
let bankData = []
|
||||
let initialBankData = await fetch('https://hcb.hackclub.com/stats').then(r =>
|
||||
r.json()
|
||||
)
|
||||
let raised = initialBankData.raised / 100
|
||||
let initialBankData = await fetch('https://hcb.hackclub.com/stats')
|
||||
try {
|
||||
const bd = await initialBankData.json()
|
||||
let raised = bd.raised / 100
|
||||
|
||||
bankData.push(
|
||||
`💰 ${raised.toLocaleString('en-US', {
|
||||
style: 'currency',
|
||||
currency: 'USD'
|
||||
})} raised`
|
||||
)
|
||||
bankData.push(
|
||||
`💰 ${raised.toLocaleString('en-US', {
|
||||
style: 'currency',
|
||||
currency: 'USD'
|
||||
})} raised`
|
||||
)
|
||||
} catch {
|
||||
bankData.push('error')
|
||||
}
|
||||
|
||||
// Slack: get total raised
|
||||
const { Slack: Slacky } = require('./api/slack')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue