From 0603c9523859cf958538b74543eab491a0f904d7 Mon Sep 17 00:00:00 2001 From: lissavxo Date: Tue, 22 Apr 2025 11:30:30 -0300 Subject: [PATCH 1/3] feat: new props generator --- components/ButtonGenerator/data.js | 19 +++++++++++++++++++ components/ButtonGenerator/index.tsx | 10 +++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/components/ButtonGenerator/data.js b/components/ButtonGenerator/data.js index 45a70e1a3..60d19a7b6 100644 --- a/components/ButtonGenerator/data.js +++ b/components/ButtonGenerator/data.js @@ -89,6 +89,16 @@ export const generatorFormFields = [ onChange: 'handleChange', helpText: 'The text displayed upon successful payment' }, + { + name: 'Contribution Offset', + placeholder: 'Contribution Offset', + key: 'contributionOffset', + className: 'col_lg', + type: 'input', + onChange: 'handleChange', + helpText: 'Adjusts the total contributions displayed, simulating prior contributions or subtracting from the total.', + advanced: true + }, { name: 'Widget', key: 'widget', @@ -180,4 +190,13 @@ export const generatorFormFields = [ helpText: 'Removes the random ID generated for the payment that is used to prevent the onSuccess callback to be triggered by a person who has the payment screen open at the same time as another', advanced: true }, + { + name: 'Disable Altpayment', + key: 'disableAltpayment', + className: 'col_sm_center', + type: 'boolean', + default: false, + helpText: 'Disables altpayment logic', + advanced: true + }, ] \ No newline at end of file diff --git a/components/ButtonGenerator/index.tsx b/components/ButtonGenerator/index.tsx index 766ff99f9..e74fdad19 100644 --- a/components/ButtonGenerator/index.tsx +++ b/components/ButtonGenerator/index.tsx @@ -36,6 +36,8 @@ interface ButtonState { editable: boolean widget: boolean disablePaymentId: boolean + contributionOffset: number + disableAltpayment: boolean opReturn: string [key: string]: any } @@ -74,7 +76,9 @@ export const initialButtonState: ButtonState = { editable: false, widget: false, disablePaymentId: false, - opReturn: '' + opReturn: '', + contributionOffset: 0, + disableAltpayment: false } export default function ButtonGenerator (): JSX.Element { @@ -379,6 +383,8 @@ export default function ButtonGenerator (): JSX.Element { randomSatoshis={button.randomSatoshis} hideToasts={button.hideToasts} disableEnforceFocus={button.disableEnforceFocus} + contributionOffset={button.contributionOffset} + disableAltpayment={button.disableAltpayment} disabled={button.disabled} editable={button.editable} /> @@ -412,6 +418,8 @@ export default function ButtonGenerator (): JSX.Element { randomSatoshis={button.randomSatoshis} hideToasts={button.hideToasts} disableEnforceFocus={button.disableEnforceFocus} + contributionOffset={button.contributionOffset} + disableAltpayment={button.disableAltpayment} disabled={button.disabled} editable={button.editable} /> From e1bc5d45a7cdf00f87c127fbaa6b87b31d75de52 Mon Sep 17 00:00:00 2001 From: lissavxo Date: Fri, 25 Apr 2025 15:21:11 -0300 Subject: [PATCH 2/3] feat: generator missing props --- components/ButtonGenerator/CodeBlock.tsx | 16 +++++++- components/ButtonGenerator/data.js | 50 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/components/ButtonGenerator/CodeBlock.tsx b/components/ButtonGenerator/CodeBlock.tsx index 2a0f4a8a8..a3224dae3 100644 --- a/components/ButtonGenerator/CodeBlock.tsx +++ b/components/ButtonGenerator/CodeBlock.tsx @@ -55,7 +55,13 @@ export default function CodeBlock ({ button }): JSX.Element { return camelToKebabCase(key) + `="${value as string}"` } } else if (codeType === 'js') { - if (key === 'amount' || key === 'goalAmount' || key === 'onSuccess' || key === 'onTransaction' || typeof value === 'boolean') { + if (key === 'amount' || + key === 'goalAmount' || + key === 'onSuccess' || + key === 'onTransaction' || + key === 'onClose' || + key === 'onOpen' || + typeof value === 'boolean') { if (key === 'randomSatoshis' && button.amount <= 0) { return '' } else return ` ${key}: ${value as string}` @@ -67,7 +73,13 @@ export default function CodeBlock ({ button }): JSX.Element { return ` ${key}: '${value as string}'` } } else { - if (key === 'amount' || key === 'goalAmount' || key === 'onSuccess' || key === 'onTransaction' || typeof value === 'boolean') { + if (key === 'amount' || + key === 'goalAmount' || + key === 'onSuccess' || + key === 'onTransaction' || + key === 'onClose' || + key === 'onOpen' || + typeof value === 'boolean') { if (key === 'randomSatoshis' && button.amount <= 0) { return '' } else return `const ${key} = ${value as string}` diff --git a/components/ButtonGenerator/data.js b/components/ButtonGenerator/data.js index 60d19a7b6..36e720418 100644 --- a/components/ButtonGenerator/data.js +++ b/components/ButtonGenerator/data.js @@ -199,4 +199,54 @@ export const generatorFormFields = [ helpText: 'Disables altpayment logic', advanced: true }, + { + name: 'On-close', + placeholder: 'Callback function', + key: 'onClose', + className: 'col_lg', + type: 'input', + onChange: 'handleChange', + helpText: 'Callback function that runs when the button dialog closes', + advanced: true + }, + { + name: 'Auto close', + key: 'autoClose', + className: 'col_sm_center', + type: 'boolean', + default: false, + helpText: 'Enables auto-close of the button dialog after a successful payment', + advanced: true + }, + { + name: 'On-open', + placeholder: 'Callback function', + key: 'onOpen', + className: 'col_lg', + type: 'input', + onChange: 'handleChange', + helpText: 'Callback function that runs when the button dialog opens', + advanced: true + }, + { + name: 'Ws base url', + placeholder: 'Your websocket server', + key: 'wsBaseUrl', + className: 'col_lg', + type: 'input', + onChange: 'handleChange', + helpText: 'Link to the websocket server that will be used', + advanced: true + }, + { + name: 'Api base url', + placeholder: 'Your api server', + key: 'apiBaseUrl', + className: 'col_lg', + type: 'input', + onChange: 'handleChange', + helpText: 'Link to the api server that will be used', + advanced: true + }, + ] \ No newline at end of file From 00fed44e303bf38eb0c082c2593de763c70f1b51 Mon Sep 17 00:00:00 2001 From: lissavxo Date: Mon, 28 Apr 2025 15:39:32 -0300 Subject: [PATCH 3/3] feat: add missing props --- components/ButtonGenerator/data.js | 2 +- components/ButtonGenerator/index.tsx | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/components/ButtonGenerator/data.js b/components/ButtonGenerator/data.js index 36e720418..4886bfb19 100644 --- a/components/ButtonGenerator/data.js +++ b/components/ButtonGenerator/data.js @@ -214,7 +214,7 @@ export const generatorFormFields = [ key: 'autoClose', className: 'col_sm_center', type: 'boolean', - default: false, + default: true, helpText: 'Enables auto-close of the button dialog after a successful payment', advanced: true }, diff --git a/components/ButtonGenerator/index.tsx b/components/ButtonGenerator/index.tsx index e74fdad19..45592f33a 100644 --- a/components/ButtonGenerator/index.tsx +++ b/components/ButtonGenerator/index.tsx @@ -78,7 +78,12 @@ export const initialButtonState: ButtonState = { disablePaymentId: false, opReturn: '', contributionOffset: 0, - disableAltpayment: false + disableAltpayment: false, + autoClose: true, + onOpen: '', + onClose: '', + wsBaseURL: '', + apiBaseURL: '', } export default function ButtonGenerator (): JSX.Element { @@ -422,6 +427,11 @@ export default function ButtonGenerator (): JSX.Element { disableAltpayment={button.disableAltpayment} disabled={button.disabled} editable={button.editable} + autoClose={button.autoClose} + onOpen={button.onOpen} + onClose={button.onClose} + wsBaseURL={button.wsBaseURL} + apiBaseURL={button.apiBaseURL} /> ) )