Skip to content

Commit

Permalink
EditWalletRules: Integer quorum percent (#1856)
Browse files Browse the repository at this point in the history
  • Loading branch information
asktree authored Oct 9, 2023
1 parent 1a07037 commit dc30183
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion hub/components/EditWalletRules/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ interface Props
}

function Form(props: Props & { title: string; description: string }) {
console.log('form props', props);
const [showCouncilOptions, setShowCouncilOptions] = useState(
props.initialCouncilRules?.canVote || false,
);
Expand Down
2 changes: 2 additions & 0 deletions hub/components/EditWalletRules/RulesDetailsInputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export function QuorumPercent(props: Props) {
});
props.onRulesChange?.(newRules);
}}
integer
/>
<Slider
min={1}
Expand All @@ -239,6 +240,7 @@ export function QuorumPercent(props: Props) {
props.onRulesChange?.(newRules);
}}
onRenderValue={(val) => `${val}%`}
step={1}
/>
</div>
</ValueBlock>
Expand Down
10 changes: 8 additions & 2 deletions hub/components/EditWalletRules/SliderValue/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface Props {
value: number;
units: React.ReactNode;
onChange?(value: number): void;
integer?: boolean;
}

export function SliderValue(props: Props) {
Expand All @@ -32,9 +33,14 @@ export function SliderValue(props: Props) {
/.*?(([0-9]*\.)?[0-9]+).*/g,
'$1',
);
const parsed = parseFloat(text);
const parsed = props.integer
? Math.floor(parseFloat(text))
: parseFloat(text);
const value = Number.isNaN(parsed) ? props.min : parsed;
props.onChange?.(Math.max(props.min, value));
const newValue = Math.max(props.min, value);
setValue(String(props.value)); // this is to force the input to update to the correct value
// even if the user enters an invalid value that doesnt actually change props.value
props.onChange?.(newValue);
}}
/>
<div
Expand Down

1 comment on commit dc30183

@vercel
Copy link

@vercel vercel bot commented on dc30183 Oct 9, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

governance-ui – ./

governance-ui-git-main-solana-labs.vercel.app
app.realms.today
governance-ui-solana-labs.vercel.app

Please sign in to comment.