Skip to content

Commit

Permalink
fix(components): Maximum resale value prop for BidCreate
Browse files Browse the repository at this point in the history
* Added maximum resale error message

* Removed error message
  • Loading branch information
AshenI99 authored Apr 1, 2022
1 parent da528c6 commit 035f870
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
26 changes: 22 additions & 4 deletions packages/components/src/BidCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import { Box, Select, Label, Input, Button, Text } from 'theme-ui'

export function BidCreate({
onBid,
maxResale
}: {
onBid: (amount: string, resale: string) => void
onBid: (amount: string, resale: string) => void,
maxResale?: number
}) {
const [amount, setAmount] = useState(null)
const [resale, setResale] = useState('0')
Expand Down Expand Up @@ -69,20 +71,36 @@ export function BidCreate({
/>
</Box>
<Box sx={{ variant: 'forms.primary.row' }}>
<Label htmlFor="resale">RESALE FEE</Label>
<Label htmlFor="resale">
RESALE FEE
<Text
sx={{
marginTop:'3px',
marginLeft:1,
fontSize:14
}}
>
{`(MAX ${maxResale ? maxResale : '100'}%)`}
</Text>
</Label>
<Input
type="number"
step="1"
name="resale"
id="resale"
value={resale}
min={0}
max={maxResale || 100}
autoComplete="off"
onChange={(e) => setResale(e.target.value)}
onChange={(e) => {
if(maxResale ? e.target.value <= Number(maxResale) : e.target.value <= 100){
setResale(e.target.value)
}
}}
/>
</Box>
<Button
disabled={!amount}
disabled={!amount || Number(resale) > maxResale}
mt={24}
sx={{
width: ['100%', '100%', '100%', 'unset'],
Expand Down
4 changes: 3 additions & 1 deletion packages/components/src/stories/BidCreate.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ const Template: ComponentStory<typeof BidCreate> = (args) => (
)

export const Zero = Template.bind({})
Zero.args = {}
Zero.args = {
maxResale: 40,
}

1 comment on commit 035f870

@vercel
Copy link

@vercel vercel bot commented on 035f870 Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.