From 896febfe01d55da80a42bab1c3df5e0265c737d8 Mon Sep 17 00:00:00 2001 From: Tim Pechersky Date: Wed, 25 Aug 2021 15:11:48 +0200 Subject: [PATCH] welcome new subscription type fix --- frontend/src/components/NewSubscription.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/NewSubscription.js b/frontend/src/components/NewSubscription.js index 8acd08b2..230ea755 100644 --- a/frontend/src/components/NewSubscription.js +++ b/frontend/src/components/NewSubscription.js @@ -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"), });