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 45a70e1a3..4886bfb19 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,63 @@ 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 + }, + { + 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: true, + 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 diff --git a/components/ButtonGenerator/index.tsx b/components/ButtonGenerator/index.tsx index 766ff99f9..45592f33a 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,14 @@ export const initialButtonState: ButtonState = { editable: false, widget: false, disablePaymentId: false, - opReturn: '' + opReturn: '', + contributionOffset: 0, + disableAltpayment: false, + autoClose: true, + onOpen: '', + onClose: '', + wsBaseURL: '', + apiBaseURL: '', } export default function ButtonGenerator (): JSX.Element { @@ -379,6 +388,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,8 +423,15 @@ 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} + autoClose={button.autoClose} + onOpen={button.onOpen} + onClose={button.onClose} + wsBaseURL={button.wsBaseURL} + apiBaseURL={button.apiBaseURL} /> ) )