From 9ab76ade98f85f2770f21e34fc53d36d9db14677 Mon Sep 17 00:00:00 2001 From: lissavxo Date: Thu, 30 Jan 2025 16:45:05 -0300 Subject: [PATCH 1/4] feat: remove unecessary currencies generator --- components/ButtonGenerator/index.tsx | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/components/ButtonGenerator/index.tsx b/components/ButtonGenerator/index.tsx index 766ff99f..57b0f43e 100644 --- a/components/ButtonGenerator/index.tsx +++ b/components/ButtonGenerator/index.tsx @@ -43,7 +43,7 @@ interface ButtonState { export const initialButtonState: ButtonState = { to: '', amount: '', - currency: 'XEC', + currency: '', text: '', hoverText: '', successText: '', @@ -63,7 +63,7 @@ export const initialButtonState: ButtonState = { } }, validAddress: '', - currencies: ['XEC', 'USD', 'CAD'], + currencies: ['', 'USD', 'CAD'], goalAmount: '', onSuccess: '', onTransaction: '', @@ -155,17 +155,6 @@ export default function ButtonGenerator (): JSX.Element { ...prevButton, [name]: value, validAddress: isValidAddress(value), - currency: (!['XEC', 'BCH'].includes( - prevButton.currency - )) - ? prevButton.currency - : isValidAddress(value) === 'bitcoincash' - ? 'BCH' - : 'XEC', - currencies: [ - isValidAddress(value) === 'bitcoincash' ? 'BCH' : 'XEC', - ...prevButton.currencies.slice(1) // Keep the rest of the array unchanged - ], theme: { ...prevButton.theme, // Keep the existing theme values palette: { From 699860fac4f0472f56188902a57db2240149b30b Mon Sep 17 00:00:00 2001 From: lissavxo Date: Thu, 30 Jan 2025 16:46:27 -0300 Subject: [PATCH 2/4] feat: update hover-text generator --- components/ButtonGenerator/data.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ButtonGenerator/data.js b/components/ButtonGenerator/data.js index df6180f8..1a5ef34e 100644 --- a/components/ButtonGenerator/data.js +++ b/components/ButtonGenerator/data.js @@ -54,7 +54,7 @@ export const generatorFormFields = [ }, { name: 'Hover Text', - placeholder: 'Send XEC', + placeholder: 'Send payment', key: 'hoverText', className: 'col_lg', type: 'input', From 46967e8b63de2f369c0dc9715daf0395a7e2fc13 Mon Sep 17 00:00:00 2001 From: lissavxo Date: Thu, 30 Jan 2025 16:47:42 -0300 Subject: [PATCH 3/4] feat: update to generator --- components/ButtonGenerator/data.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ButtonGenerator/data.js b/components/ButtonGenerator/data.js index 1a5ef34e..45a70e1a 100644 --- a/components/ButtonGenerator/data.js +++ b/components/ButtonGenerator/data.js @@ -1,7 +1,7 @@ export const generatorFormFields = [ { name: 'To', - placeholder: 'Your Address', + placeholder: 'Your Address (XEC or BCH)', key: 'to', className: 'col_lg', type: 'input', From a44495a04e0f6a34f347ea5572aac15f17ad1ddf Mon Sep 17 00:00:00 2001 From: lissavxo Date: Fri, 31 Jan 2025 12:56:38 -0300 Subject: [PATCH 4/4] fix: remove unecessary currencies generator --- components/ButtonGenerator/CodeBlock.tsx | 13 ++++++++++--- components/ButtonGenerator/index.tsx | 15 +++++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/components/ButtonGenerator/CodeBlock.tsx b/components/ButtonGenerator/CodeBlock.tsx index ab5f0188..42f02cdb 100644 --- a/components/ButtonGenerator/CodeBlock.tsx +++ b/components/ButtonGenerator/CodeBlock.tsx @@ -82,11 +82,15 @@ export default function CodeBlock ({ button }): JSX.Element { } const propertiesToSkip = ['to', 'currencies', 'validAddress', 'bchtheme', 'widget'] - + const currenciesToSkip = ['XEC', 'BCH'] const generateReactProps = (button: any): string => { let result = '' for (const [key, value] of Object.entries(button)) { - if (propertiesToSkip.includes(key) || JSON.stringify(initialButtonState[key]) === JSON.stringify(value) || JSON.stringify(initialButtonState.bchtheme) === JSON.stringify(value) || (key === 'randomSatoshis' && button.amount <= 0)) { + if (propertiesToSkip.includes(key) || + JSON.stringify(initialButtonState[key]) === JSON.stringify(value) || + JSON.stringify(initialButtonState.bchtheme) === JSON.stringify(value) || + (key === 'randomSatoshis' && button.amount <= 0) || + currenciesToSkip.includes(value as string)) { continue } else result += ` ${key}={${key}}\n` } @@ -96,7 +100,10 @@ export default function CodeBlock ({ button }): JSX.Element { const generateCode = (button: any, codeType: string): string => { let result = '' for (const [key, value] of Object.entries(button)) { - if (propertiesToSkip.includes(key) || JSON.stringify(initialButtonState[key]) === JSON.stringify(value) || JSON.stringify(initialButtonState.bchtheme) === JSON.stringify(value)) { + if (propertiesToSkip.includes(key) || + JSON.stringify(initialButtonState[key]) === JSON.stringify(value) || + JSON.stringify(initialButtonState.bchtheme) === JSON.stringify(value) || + currenciesToSkip.includes(value as string)) { continue } else result += ` ${makeCodeString(key, value, codeType)}\n` } diff --git a/components/ButtonGenerator/index.tsx b/components/ButtonGenerator/index.tsx index 57b0f43e..766ff99f 100644 --- a/components/ButtonGenerator/index.tsx +++ b/components/ButtonGenerator/index.tsx @@ -43,7 +43,7 @@ interface ButtonState { export const initialButtonState: ButtonState = { to: '', amount: '', - currency: '', + currency: 'XEC', text: '', hoverText: '', successText: '', @@ -63,7 +63,7 @@ export const initialButtonState: ButtonState = { } }, validAddress: '', - currencies: ['', 'USD', 'CAD'], + currencies: ['XEC', 'USD', 'CAD'], goalAmount: '', onSuccess: '', onTransaction: '', @@ -155,6 +155,17 @@ export default function ButtonGenerator (): JSX.Element { ...prevButton, [name]: value, validAddress: isValidAddress(value), + currency: (!['XEC', 'BCH'].includes( + prevButton.currency + )) + ? prevButton.currency + : isValidAddress(value) === 'bitcoincash' + ? 'BCH' + : 'XEC', + currencies: [ + isValidAddress(value) === 'bitcoincash' ? 'BCH' : 'XEC', + ...prevButton.currencies.slice(1) // Keep the rest of the array unchanged + ], theme: { ...prevButton.theme, // Keep the existing theme values palette: {