diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 2f986b7..008b298 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -108,7 +108,6 @@ function App() { if (event.origin === window.origin) { const message = event.data; if (message?.selectedLocale && message.selectedLocale !== appStore.locale) { - console.log('selected locale', message.selectedLocale); dispatch(setLocale(message.selectedLocale)); } } diff --git a/src/renderer/components/blocks/forms/ConnectForm.tsx b/src/renderer/components/blocks/forms/ConnectForm.tsx index d70dfc2..755021f 100644 --- a/src/renderer/components/blocks/forms/ConnectForm.tsx +++ b/src/renderer/components/blocks/forms/ConnectForm.tsx @@ -16,7 +16,7 @@ const validationSchema = yup.object({ .required('Server Address is required') .matches( // eslint-disable-next-line no-useless-escape - /^(https?:\/\/(www\.)?)?([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}|localhost|[a-z0-9]+)(:[0-9]{1,5})?(\/.*)?$/, + /^(https?:\/\/(www\.)?)?([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}|localhost|[a-z0-9]+|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?$/, 'Please enter a valid server address', ), apiKey: yup.string(), diff --git a/src/renderer/components/blocks/forms/CreateTokenForm.tsx b/src/renderer/components/blocks/forms/CreateTokenForm.tsx index e355bc9..cb20d61 100644 --- a/src/renderer/components/blocks/forms/CreateTokenForm.tsx +++ b/src/renderer/components/blocks/forms/CreateTokenForm.tsx @@ -10,7 +10,7 @@ interface FormProps extends React.RefAttributes { } export interface CreateTokenFormRef { - submitForm: () => Promise; + submitForm: () => Promise; } const CreateTokenForm: React.FC = forwardRef(({ data }, ref) => { @@ -28,8 +28,9 @@ const CreateTokenForm: React.FC = forwardRef ({ ...acc, [key]: true }), {})); - - return [errors, formik.values]; + if (formik.values?.walletAddress) { + return formik.values.walletAddress; + } } } }, @@ -48,9 +49,9 @@ const CreateTokenForm: React.FC = forwardRef ({ - label: d.name || '', - value: d.walletAddress || '', + data?.map((addressData) => ({ + label: addressData.name || '', + value: addressData.walletAddress || '', })) || [] } freeform={true} diff --git a/src/renderer/components/blocks/modals/CreateTokenModal.tsx b/src/renderer/components/blocks/modals/CreateTokenModal.tsx index a7814e9..7364738 100644 --- a/src/renderer/components/blocks/modals/CreateTokenModal.tsx +++ b/src/renderer/components/blocks/modals/CreateTokenModal.tsx @@ -5,7 +5,6 @@ import { useGetAddressBookQuery, useGetProjectQuery, useGetUnitQuery, useTokeniz import { Alert } from 'flowbite-react'; import { HiInformationCircle } from 'react-icons/hi'; import { useWildCardUrlHash } from '@/hooks'; -import { isEmpty } from 'lodash'; interface UpsertModalProps { onTokenizationSuccess: () => void; @@ -17,6 +16,7 @@ const CreateTokenModal: React.FC = ({ onClose, onTokenizationS const urlHashValues: string[] = tokenizeUrlFragment?.replace('tokenize-', '')?.split('^'); const warehouseUnitId = urlHashValues?.length >= 1 ? urlHashValues[0] : ''; const warehouseProjectId = urlHashValues?.length >= 2 ? urlHashValues[1] : ''; + const [tokenizationProcessing, setTokenizationProcessing] = useState(false); const [showTokenizationFailure, setShowTokenizationFailure] = useState(false); const { data: unit, isLoading: unitLoading } = useGetUnitQuery( @@ -42,8 +42,15 @@ const CreateTokenModal: React.FC = ({ onClose, onTokenizationS unit?.unitBlockEnd && unit?.unitCount; - const onSubmitTokenization = async (walletAddress: string) => { + const onSubmitTokenization = async () => { setShowTokenizationFailure(false); + setTokenizationProcessing(true); + + const walletAddress = await createTokenFormRef.current?.submitForm(); + if (!walletAddress) { + setTokenizationProcessing(false); + return; + } if (unit && project && requiredFieldsPresent) { const submitData = { @@ -66,24 +73,8 @@ const CreateTokenModal: React.FC = ({ onClose, onTokenizationS } else { setShowTokenizationFailure(true); } - }; - const handleSubmit = () => { - createTokenFormRef.current - ?.submitForm() - .then(async ([errors, values]) => { - if (!isEmpty(errors)) { - console.error('Form submission error:', errors); - return; - } - - if (values) { - onSubmitTokenization(values.walletAddress); - } - }) - .catch((error) => { - console.error('Form submission error:', error); - }); + setTokenizationProcessing(false); }; const modalBody = () => { @@ -194,7 +185,11 @@ const CreateTokenModal: React.FC = ({ onClose, onTokenizationS
- +
); diff --git a/src/renderer/translations/tokens/en-US.json b/src/renderer/translations/tokens/en-US.json index 1c23ae8..e372fe3 100644 --- a/src/renderer/translations/tokens/en-US.json +++ b/src/renderer/translations/tokens/en-US.json @@ -104,7 +104,6 @@ "not-available-in-core-registry-mode": "not available in core registry mode", "cannot-connect-to-registry-api-with-current-settings": "Cannot connect to registry API with current settings", "please-disconnect-to-edit-the-api-url-and-api-key": "Please disconnect to edit the API URL and API key", - "address-book": "address book", "add-address": "add address", "project-developer": "Project Developer",