welcome new subscription type fix

pull/174/head
Tim Pechersky 2021-08-25 15:11:48 +02:00
rodzic 2594fcdfed
commit 896febfe01
1 zmienionych plików z 12 dodań i 3 usunięć

Wyświetl plik

@ -21,12 +21,20 @@ import { CirclePicker } from "react-color";
import { BiRefresh } from "react-icons/bi";
import { makeColor } from "../core/utils/makeColor";
import { useForm } from "react-hook-form";
const _NewSubscription = ({ isFreeOption, onClose, setIsLoading }) => {
const _NewSubscription = ({
isFreeOption,
onClose,
setIsLoading,
initialAddress,
initialType,
}) => {
const [color, setColor] = useState(makeColor());
const { handleSubmit, errors, register } = useForm({});
const { typesCache, createSubscription } = useSubscriptions();
// const { handleSubmit, errors, register } = useForm({});
const [radioState, setRadioState] = useState("ethereum_blockchain");
const [radioState, setRadioState] = useState(
initialType ?? "ethereum_blockchain"
);
let { getRootProps, getRadioProps } = useRadioGroup({
name: "type",
defaultValue: radioState,
@ -52,7 +60,7 @@ const _NewSubscription = ({ isFreeOption, onClose, setIsLoading }) => {
createSubscription.mutate({
...props,
color: color,
type: isFreeOption ? 0 : radioState,
type: isFreeOption ? "ethereum_blockchain" : radioState,
});
},
[createSubscription, isFreeOption, color, radioState]
@ -107,6 +115,7 @@ const _NewSubscription = ({ isFreeOption, onClose, setIsLoading }) => {
const radio = getRadioProps({
value: type.id,
isDisabled:
(initialAddress && initialType) ||
!type.active ||
(isFreeOption && type.id !== "ethereum_blockchain"),
});