stargaze-studio/components/collections/creation/RoyaltyDetails.tsx
Arda Nakışçı 4ba58eca6d
Refactoring collection creation logic (#20)
* Split collection info component

* Fix texts

* Refactor components

* Create upload details component

* Add on change method to collection details

* Add on change method to minting details

* Add on change method to whitelist details

* Add on change method to royalty details

* Update create page name

* Refactor code for collection creation logic
2022-08-04 12:16:42 +03:00

51 lines
1.5 KiB
TypeScript

import { FormGroup } from 'components/FormGroup'
import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks'
import React, { useEffect } from 'react'
import { NumberInput, TextInput } from '../../forms/FormInput'
interface RoyaltyDetailsProps {
onChange: (data: RoyaltyDetailsDataProps) => void
}
export interface RoyaltyDetailsDataProps {
paymentAddress: string
share: number
}
export const RoyaltyDetails = ({ onChange }: RoyaltyDetailsProps) => {
const royaltyPaymentAddressState = useInputState({
id: 'royalty-payment-address',
name: 'royaltyPaymentAddress',
title: 'Payment Address',
subtitle: 'Address to receive royalties',
placeholder: 'stars1234567890abcdefghijklmnopqrstuvwxyz...',
})
const royaltyShareState = useNumberInputState({
id: 'royalty-share',
name: 'royaltyShare',
title: 'Share Percentage',
subtitle: 'Percentage of royalties to be paid',
placeholder: '8',
})
useEffect(() => {
const data: RoyaltyDetailsDataProps = {
paymentAddress: royaltyPaymentAddressState.value,
share: royaltyShareState.value,
}
onChange(data)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [royaltyPaymentAddressState.value, royaltyShareState.value])
return (
<div>
<FormGroup subtitle="Information about royalty" title="Royalty Details">
<TextInput {...royaltyPaymentAddressState} />
<NumberInput {...royaltyShareState} />
</FormGroup>
</div>
)
}