Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions components/ButtonGenerator/CodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand All @@ -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}`
Expand Down
69 changes: 69 additions & 0 deletions components/ButtonGenerator/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
},

]
20 changes: 19 additions & 1 deletion components/ButtonGenerator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ interface ButtonState {
editable: boolean
widget: boolean
disablePaymentId: boolean
contributionOffset: number
disableAltpayment: boolean
opReturn: string
[key: string]: any
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here. lets make sure we're adding all the new props here so the preview button has the intended functionality. Its unlikely anyone would actually test a different Api base url here, or the auto close, but should add it anyway

disabled={button.disabled}
editable={button.editable}
/>
Expand Down Expand Up @@ -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}
/>
)
)
Expand Down