Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/button generator revision #932

Merged
merged 4 commits into from
Jan 31, 2025
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
13 changes: 10 additions & 3 deletions components/ButtonGenerator/CodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`
}
Expand All @@ -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`
}
Expand Down
4 changes: 2 additions & 2 deletions components/ButtonGenerator/data.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -54,7 +54,7 @@ export const generatorFormFields = [
},
{
name: 'Hover Text',
placeholder: 'Send XEC',
placeholder: 'Send payment',
key: 'hoverText',
className: 'col_lg',
type: 'input',
Expand Down