Skip to content

Commit

Permalink
Merge pull request #103 from CudoVentures/cudos-dev
Browse files Browse the repository at this point in the history
Cudos dev merge for release 1.0.3
  • Loading branch information
maptuhec authored Oct 7, 2022
2 parents 8806726 + cd6f921 commit e7e0427
Show file tree
Hide file tree
Showing 23 changed files with 402 additions and 200 deletions.
3 changes: 3 additions & 0 deletions src/assets/vectors/facebook.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/vectors/linkedin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/vectors/medium.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions src/assets/vectors/reddit.svg

This file was deleted.

3 changes: 3 additions & 0 deletions src/assets/vectors/spotify.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/vectors/youtube.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions src/components/Dialog/components/DelegationModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ const DelegationModal: React.FC = () => {
const { open, status } = modal

const handleClose = () => {
handleModal({
...initialDelegationModalState
})
if (status !== ModalStatus.LOADING) {
handleModal({
...initialDelegationModalState
})
}
}

const handleTryAgain = () => {
Expand Down
27 changes: 15 additions & 12 deletions src/components/Layout/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
import { Box, Grid, Typography } from '@mui/material'
import FooterLogo from 'assets/vectors/logo-footer.svg'
import RedditIcon from 'assets/vectors/reddit.svg?component'
import moment from 'moment'
import TwitterIcon from 'assets/vectors/twitter.svg?component'
import TelegramIcon from 'assets/vectors/telegram.svg?component'
import DiscordIcon from 'assets/vectors/discord.svg?component'

import LinkedInIcon from 'assets/vectors/linkedin.svg?component'
import MediumIcon from 'assets/vectors/medium.svg?component'
import YouTubeIcon from 'assets/vectors/youtube.svg?component'
import FacebookIcon from 'assets/vectors/facebook.svg?component'
import SpotifyIcon from 'assets/vectors/spotify.svg?component'
import { styles } from './styles'

const linksLeft = [
{ text: 'FAQ', url: 'https://www.cudos.org/' },
{ text: 'Terms & Conditions', url: 'https://www.cudos.org/' },
{ text: 'Privacy Policy', url: 'https://www.cudos.org/' },
{ text: 'Terms & Conditions', url: 'https://www.cudos.org/terms-and-conditions/' },
{ text: 'Privacy Policy', url: 'https://www.cudos.org/privacy-policy' },
{ text: 'cudos.org', url: 'https://www.cudos.org/' },
{ text: 'License © 2018 - 2022', url: 'https://www.cudos.org/' }
{ text: `License © 2018 - ${moment().year()}`, url: 'https://www.cudos.org/' }
]

const linksRight = [
// { icon: <RedditIcon />, url: 'https://www.cudos.org/' },
{ icon: <TwitterIcon />, url: 'https://twitter.com/CUDOS_' },
{ icon: <TelegramIcon />, url: 'https://t.me/cudostelegram' },
{ icon: <DiscordIcon />, url: 'https://discord.com/invite/t397SKqf4u' }
{ icon: <DiscordIcon />, url: 'https://discord.com/invite/t397SKqf4u' },
{ icon: <LinkedInIcon />, url: 'https://www.linkedin.com/company/cudos1' },
{ icon: <MediumIcon />, url: 'https://medium.com/cudos' },
{ icon: <YouTubeIcon />, url: 'https://www.youtube.com/c/CUDOS' },
{ icon: <FacebookIcon />, url: 'https://www.facebook.com/cudos.org' },
{ icon: <SpotifyIcon />, url: 'https://open.spotify.com/show/2lZuBXJ270g7taK06tnK35' }
]

const Footer = () => {
return (
<Box sx={styles.footerContainer} gap={6}>
<Grid item>
<img src={FooterLogo} alt="logo" />
</Grid>
<Box display="flex" alignItems="center">
{linksLeft.map((link) => (
<Grid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ const RewardsClaimModal: React.FC = () => {
const { open, status } = modal

const handleClose = () => {
handleModal({
...initialRewardsModalProps
})
if (status !== ModalStatus.LOADING) {
handleModal({
...initialRewardsModalProps
})
}
}

const handleTryAgain = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Faucet/components/Activity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Activity = () => {
),
timestamp: (
<Typography variant="body2" color="text.secondary">
{moment(new Date(item.timestamp.parseZone().fromNow(true)))}
{moment(new Date(item.timestamp)).parseZone().fromNow(true)}
</Typography>
)
}))
Expand Down
8 changes: 5 additions & 3 deletions src/containers/Faucet/components/FaucetModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ const FaucetModal = () => {
const { open, status } = modal

const handleClose = () => {
handleModal({
...initialFaucetModalProps
})
if (status !== ModalStatus.LOADING) {
handleModal({
...initialFaucetModalProps
})
}
}

const renderComponent = () => {
Expand Down
49 changes: 29 additions & 20 deletions src/containers/Faucet/components/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,30 @@ import CosmosNetworkConfig from 'ledgers/CosmosNetworkConfig'
import { ModalStatus } from 'store/modal'
import useModal from '../FaucetModal/hooks'
import { styles } from './styles'
import { isValidCudosAddress } from 'utils/projectUtils'

const Form = () => {
const captchaRef = useRef<any>(null)
const [address, setAddress] = useState<string>('')
const [amount, setAmount] = useState<string>('')
const [showTransferBtn, setShowTransferBtn] = useState<boolean>(false)
const { setWarning } = useNotifications()
const maxAmountAllowed: number = 100

const { handleModal } = useModal()

const validInput = () => {

if (
Number(amount) > maxAmountAllowed || Number(amount) <= 0 ||
!amount || !address
) {
return false
}

return true
}

const handleAddress = (
ev: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
) => {
Expand All @@ -34,15 +48,19 @@ const Form = () => {

const checkCaptcha = async () => {
const token = captchaRef.current.getValue()
const validatedInput = validInput()

if (!amount) {
captchaRef.current.reset()
}
if (token) {
if (token && validatedInput) {
setShowTransferBtn(true)
} else {
setShowTransferBtn(false)
return
}

if (!validatedInput) {
setWarning('Please fill the required fields first')
}

captchaRef.current.reset()
setShowTransferBtn(false)
}

const handleReceiveTokens = async () => {
Expand All @@ -52,10 +70,7 @@ const Form = () => {
.multipliedBy(CosmosNetworkConfig.CURRENCY_1_CUDO)
.toString(10)

const re = /^cudos[0-9a-z]{39}$/
const correctCudosAddress = address.match(re)

if (!correctCudosAddress) {
if (!isValidCudosAddress(address)) {
setWarning('Wrong CUDOS Address Format')
return
}
Expand All @@ -77,7 +92,7 @@ const Form = () => {
status: ModalStatus.FAILURE,
failureMessage: {
title: 'Transaction failed!',
subtitle: 'Maximum amount of 10 CUDOS reached for this account.'
subtitle: 'Maximum amount of 100 CUDOS reached for this account.'
}
})
} else {
Expand All @@ -103,7 +118,7 @@ const Form = () => {
<Card sx={{ padding: 0, flex: 1 }}>
<Box sx={styles.formContainer}>
<Typography variant="h5" fontWeight={900}>
Receive 10 Testnet CUDOS tokens
Receive Testnet CUDOS tokens
</Typography>
<Stack sx={{ width: '100%' }}>
<Typography variant="body2" fontWeight={700}>
Expand Down Expand Up @@ -132,7 +147,7 @@ const Form = () => {
</Stack>
<Stack sx={{ width: '100%' }}>
<Typography variant="body2" fontWeight={700}>
Amount (Maximum 10 CUDOS)
Amount (Maximum 100 CUDOS)
</Typography>
<StyledTextField
variant="standard"
Expand Down Expand Up @@ -175,13 +190,7 @@ const Form = () => {
width: '50%'
})}
onClick={handleReceiveTokens}
disabled={
Number(amount) > 10 ||
!amount ||
Number(amount) <= 0 ||
!showTransferBtn ||
!address
}
disabled={!showTransferBtn || !validInput()}
>
Receive Tokens
</Button>
Expand Down
8 changes: 5 additions & 3 deletions src/containers/Proposals/components/DepositModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ const DepositModal = () => {
const { open, status } = modal

const handleClose = () => {
handleModal({
...initialDepositModalState
})
if (status !== ModalStatus.LOADING) {
handleModal({
...initialDepositModalState
})
}
}

const handleTryAgain = () => {
Expand Down
8 changes: 5 additions & 3 deletions src/containers/Proposals/components/ProposalModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ const ProposalModal = () => {
const { open, status } = modal

const handleClose = () => {
handleModal({
...initialProposalModalState
})
if (status !== ModalStatus.LOADING) {
handleModal({
...initialProposalModalState
})
}
}

const handleTryAgain = () => {
Expand Down
4 changes: 3 additions & 1 deletion src/containers/Proposals/components/VotingModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const VotingModal = () => {
const { open, status } = modal

const handleClose = () => {
handleModal({ ...initialVotingModalState })
if (status !== ModalStatus.LOADING) {
handleModal({ ...initialVotingModalState })
}
}

const handleTryAgain = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ const DelegationModal: React.FC = () => {
const { open, status } = modal

const handleClose = () => {
handleModal({
...initialRedelegationModalState
})
if (status !== ModalStatus.LOADING) {
handleModal({
...initialRedelegationModalState
})
}
}

const handleTryAgain = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ const DelegationModal: React.FC = () => {
const { open, status } = modal

const handleClose = () => {
handleModal({
...initialUndelegationModalState
})
if (status !== ModalStatus.LOADING) {
handleModal({
...initialUndelegationModalState
})
}
}

const handleTryAgain = () => {
Expand Down
Loading

0 comments on commit e7e0427

Please sign in to comment.