Skip to content

Commit

Permalink
style 💎: apply hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
melMass committed Sep 24, 2023
1 parent 323484f commit 88bfe19
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ export const UKRAINE_FUNDING_CONTRACT = 'KT1DWnLiUkNtAQDErXxudFEH63JC6mqg3HEx'
export const PAKISTAN_FUNDING_CONTRACT = 'KT1Jpf2TAcZS7QfBraQMBeCxjFhH6kAdDL4z'
export const IRAN_FUNDING_CONTRACT = 'KT1KYfj97fpdomqyKsZSBdSVvh9afh93b4Ge'
export const QUAKE_FUNDING_CONTRACT = 'KT1X1jyohFrZyDYWvCPXw9KvWxk2VDwxyg2g'
export const MOROCCO_QUAKE_FUNDING_CONTRACT = 'KT1RwXEP8Sj1UQDHPG4oEjRohBdzG2R7FCpA'
export const MOROCCO_QUAKE_FUNDING_CONTRACT =
'KT1RwXEP8Sj1UQDHPG4oEjRohBdzG2R7FCpA'

export const DAO_TOKEN_CONTRACT = 'KT1QrtA753MSv8VGxkDrKKyJniG5JtuHHbtV'
export const DAO_TOKEN_CLAIM_CONTRACT = 'KT1NrfV4e2qWqFrnrKyPTJth5wq2KP9VyBei'
Expand Down
29 changes: 20 additions & 9 deletions src/data/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { HEN_CONTRACT_FA2, DAO_TOKEN_CONTRACT, CLAIMED_DAO_TOKENS_BIGMAP_ID } from '@constants'
import {
HEN_CONTRACT_FA2,
DAO_TOKEN_CONTRACT,
CLAIMED_DAO_TOKENS_BIGMAP_ID,
} from '@constants'
import axios from 'axios'
export const BaseTokenFieldsFragment = `
fragment baseTokenFields on tokens {
Expand Down Expand Up @@ -329,21 +333,28 @@ export async function getDaoTokenBalance(walletAddr: string) {
const parameters = {
'token.contract': DAO_TOKEN_CONTRACT,
'token.tokenId': '0',
'account': walletAddr,
"select": 'balance'}
const response = await axios.get(import.meta.env.VITE_TZKT_API + '/v1/tokens/balances', {
params: parameters
}).catch(error => console.log('Error while querying the account token balance:', error))
account: walletAddr,
select: 'balance',
}
const response = await axios
.get(import.meta.env.VITE_TZKT_API + '/v1/tokens/balances', {
params: parameters,
})
.catch((error) =>
console.log('Error while querying the account token balance:', error)
)

return response?.data[0]? parseInt(response.data[0]) / 1e6 : 0
return response?.data[0] ? parseInt(response.data[0]) / 1e6 : 0
}

/**
* Get User claimed tokens
*/
export async function getClaimedDaoTokens(walletAddr: string) {
const response = await axios.get(
import.meta.env.VITE_TZKT_API + `/v1/bigmaps/${CLAIMED_DAO_TOKENS_BIGMAP_ID}/keys/${walletAddr}`)
import.meta.env.VITE_TZKT_API +
`/v1/bigmaps/${CLAIMED_DAO_TOKENS_BIGMAP_ID}/keys/${walletAddr}`
)

return response? parseInt(response.data.value) : 0
return response ? parseInt(response.data.value) : 0
}
5 changes: 4 additions & 1 deletion src/pages/profile/profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ export default function Profile({ user }) {
</div>

{user.daoTokenBalance >= 0 && (
<p>{Math.round(user.daoTokenBalance * 10) / 10} <a href="claim">TEIA</a></p>
<p>
{Math.round(user.daoTokenBalance * 10) / 10}{' '}
<a href="claim">TEIA</a>
</p>
)}

<div className={styles.socials}>
Expand Down

0 comments on commit 88bfe19

Please sign in to comment.