Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/create incentives page #541

Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions components/Pages/Trade/Incentivize/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { Controller, useForm } from 'react-hook-form'
import {
Box,
Input as ChakraInput,
Divider,
HStack,
InputGroup,
Stack,
Text,
useMediaQuery,
} from '@chakra-ui/react'
import { useChain } from '@cosmos-kit/react-lite'
Expand All @@ -15,6 +17,7 @@ import { useOpenFlow } from 'components/Pages/Trade/Incentivize/hooks/useOpenFlo
import SubmitButton from 'components/SubmitButton'
import { TooltipWithChildren } from 'components/TooltipWithChildren'
import { WHALE_TOKEN_SYMBOL } from 'constants/index'
import dayjs from 'dayjs'
import { useRecoilValue } from 'recoil'
import { chainState } from 'state/chainState'
import { txRecoilState } from 'state/txRecoilState'
Expand Down Expand Up @@ -54,6 +57,10 @@ const Create = ({ poolId }: Props) => {
const { simulate, submit } = useOpenFlow({ poolId,
...formData })

const startDate = formData.startDate === '' ? dayjs() : dayjs(formData.startDate)
const endDateMinimum = startDate.add(1, 'day')
const startDateInvalid = startDate.isBefore(dayjs(), 'day')

return (
<Stack as="form" gap="5" onSubmit={handleSubmit(() => submit())}>
<Input
Expand Down Expand Up @@ -91,8 +98,7 @@ const Create = ({ poolId }: Props) => {
h="50px"
type="date"
paddingEnd={'2px'}
min={new Date().toISOString().
slice(0, 16)}
min={dayjs().format('YYYY-MM-DD')}
focusBorderColor="brand.500"
/>
</InputGroup>
Expand Down Expand Up @@ -120,25 +126,38 @@ const Create = ({ poolId }: Props) => {
h="50px"
type="date"
paddingEnd={'2px'}
min={new Date().toISOString().
slice(0, 16)}
min={endDateMinimum.
format('YYYY-MM-DD')}
focusBorderColor="brand.500"
/>
</InputGroup>
)}
/>
</HStack>

<Divider opacity="0.2" />

<HStack justifyContent="space-between" minWidth={['280', '340']}>
<Text color="whiteAlpha.600">Fee</Text>
<HStack spacing="1" direction="row" alignItems={'baseline'}>
<Text >
1000</Text>
jijicodes marked this conversation as resolved.
Show resolved Hide resolved
<Text fontSize={12} >
WHALE
</Text>
</HStack>
</HStack>

<SubmitButton
label={simulate.buttonLabel || 'Submit'}
label={(startDateInvalid && 'Start date invalid') || simulate.buttonLabel || 'Submit'}
isConnected={true}
txStep={TxStep?.Ready}
isLoading={
txStep === TxStep.Estimating ||
txStep === TxStep.Posting ||
txStep === TxStep.Broadcasting
}
isDisabled={!isValid || txStep !== TxStep.Ready || !isWalletConnected}
isDisabled={!isValid || txStep !== TxStep.Ready || !isWalletConnected || startDateInvalid}
/>
</Stack>
)
Expand Down
4 changes: 4 additions & 0 deletions util/parseError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const parseError = (error: Error) => {
regex: /flow start timestamp is too far into the future/u,
message: 'Start date is too far in future',
},
{ regex: /flow start timestamp is after the end timestamp/u,
message: 'Start date is after the end date' },
{ regex: /the flow you are intending to create doesn't meet the minimum/u,
message: '1000 WHALE minimum incentives' },
{
regex: /account sequence mismatch/u,
message: 'You have pending transaction',
Expand Down
Loading