diff --git a/example/screens/PresentActionScreen.tsx b/example/screens/PresentActionScreen.tsx index f0ac700..36310d9 100644 --- a/example/screens/PresentActionScreen.tsx +++ b/example/screens/PresentActionScreen.tsx @@ -26,7 +26,8 @@ const PresentActionScreen: React.FC = () => { const [actionId, setActionId] = useState(''); const [selectedEnvironment, setSelectedEnvironment] = useState('sandbox'); - const [customUrl, setCustomUrl] = useState(''); + const [customTransactPath, setCustomTransactPath] = useState(''); + const [customApiPath, setCustomApiPath] = useState(''); const [isLoading, setIsLoading] = useState(false); const [presentationStyleIOS, setPresentationStyleIOS] = useState(PresentationStyles.formSheet); @@ -52,12 +53,9 @@ const PresentActionScreen: React.FC = () => { case 'production': return Environment.production; case 'custom': { - // Use the custom URL as transactPath and derive apiPath from it - const baseUrl = customUrl.trim(); - const apiPath = baseUrl - .replace('/transact', '/api') - .replace('transact.', 'api.'); - return Environment.custom(baseUrl, apiPath); + const transactPath = customTransactPath.trim(); + const apiPath = customApiPath.trim(); + return Environment.custom(transactPath, apiPath); } default: return Environment.sandbox; @@ -70,8 +68,14 @@ const PresentActionScreen: React.FC = () => { return; } - if (selectedEnvironment === 'custom' && !customUrl.trim()) { - Alert.alert('Error', 'Please enter a valid custom URL'); + if ( + selectedEnvironment === 'custom' && + (!customTransactPath.trim() || !customApiPath.trim()) + ) { + Alert.alert( + 'Error', + 'Please enter both transact path and API path for custom environment' + ); return; } @@ -83,17 +87,15 @@ const PresentActionScreen: React.FC = () => { presentationStyleIOS, onLaunch: () => { console.log('Action launched'); - Alert.alert('Info', 'Action launched successfully!'); + setIsLoading(false); }, onFinish: (result: any) => { setIsLoading(false); console.log('Action finished:', result); - Alert.alert('Success', 'Action completed successfully!'); }, onClose: () => { setIsLoading(false); console.log('Action closed'); - Alert.alert('Info', 'Action was closed by user'); }, onAuthStatusUpdate: (status: any) => { console.log('Auth Status Update:', status); @@ -150,13 +152,22 @@ const PresentActionScreen: React.FC = () => { ))} {selectedEnvironment === 'custom' && ( - + <> + + + )} diff --git a/example/screens/TransactScreen.tsx b/example/screens/TransactScreen.tsx index 06e4644..b4cafef 100644 --- a/example/screens/TransactScreen.tsx +++ b/example/screens/TransactScreen.tsx @@ -29,7 +29,8 @@ const TransactScreen: React.FC = () => { const [publicToken, setPublicToken] = useState(''); const [selectedEnvironment, setSelectedEnvironment] = useState('sandbox'); - const [customUrl, setCustomUrl] = useState(''); + const [customTransactPath, setCustomTransactPath] = useState(''); + const [customApiPath, setCustomApiPath] = useState(''); const [selectedProduct, setSelectedProduct] = useState(Product.DEPOSIT); const [darkMode, setDarkMode] = useState(false); const [isLoading, setIsLoading] = useState(false); @@ -68,12 +69,9 @@ const TransactScreen: React.FC = () => { case 'production': return Environment.production; case 'custom': { - // Use the custom URL as transactPath and derive apiPath from it - const baseUrl = customUrl.trim(); - const apiPath = baseUrl - .replace('/transact', '/api') - .replace('transact.', 'api.'); - return Environment.custom(baseUrl, apiPath); + const transactPath = customTransactPath.trim(); + const apiPath = customApiPath.trim(); + return Environment.custom(transactPath, apiPath); } default: return Environment.sandbox; @@ -86,8 +84,14 @@ const TransactScreen: React.FC = () => { return; } - if (selectedEnvironment === 'custom' && !customUrl.trim()) { - Alert.alert('Error', 'Please enter a valid custom URL'); + if ( + selectedEnvironment === 'custom' && + (!customTransactPath.trim() || !customApiPath.trim()) + ) { + Alert.alert( + 'Error', + 'Please enter both transact path and API path for custom environment' + ); return; } @@ -171,13 +175,22 @@ const TransactScreen: React.FC = () => { ))} {selectedEnvironment === 'custom' && ( - + <> + + + )}