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

refactor: disable receive and send not toggleable #3467

Merged
merged 3 commits into from
Dec 17, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ export function SectionWalletFeatures() {
updateFeatures({ swaps: !config.features.swaps })
return
case 'Receive':
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove case check here if it's no longer used ?

updateFeatures({ receive: !config.features.receive })
return
case 'Send':
updateFeatures({ send: !config.features.send })
return
default:
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ export const WalletFeatureItem = React.memo(
Send: sendEnabled
}

const featureCanBeToggledMap = {
Buy: true,
Swap: true,
Receive: false,
Send: false
}

useEffect(() => {
if (!dragOverlay) {
return
Expand Down Expand Up @@ -124,7 +131,9 @@ export const WalletFeatureItem = React.memo(
>
{handle ? <Handle {...handleProps} {...listeners} /> : null}
<span className="text-sm flex-1">{value}</span>
<Checkbox checked={featureEnabledMap[value as WalletFeatureName]} />
{featureCanBeToggledMap[value as WalletFeatureName] ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe better to do this ?

const featureCanBeToggledMap = {
  Buy: true,
  Swap: true,
  Receive: false,
  Send: false
} as WalletFeatureName

Copy link
Collaborator

@tomiir tomiir Dec 16, 2024

Choose a reason for hiding this comment

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

I think you can do

const featureCanBeToggledMap = {
    Buy: true,
    Swap: true,
    Receive: false,
    Send: false
} as const

and it will work

<Checkbox checked={featureEnabledMap[value as WalletFeatureName]} />
) : null}
</div>
</li>
</div>
Expand Down
Loading