File tree Expand file tree Collapse file tree 1 file changed +43
-15
lines changed
Expand file tree Collapse file tree 1 file changed +43
-15
lines changed Original file line number Diff line number Diff line change 2727 name: string ;
2828 description? : string ;
2929 share? : number ;
30+ percentage? : number ;
3031 reason? : string ;
3132 reasons? : string [];
3233 }[];
4445 confirmed: boolean ;
4546 } | null = null ;
4647
47- let stakeDistributed = false ;
48-
4948 $ : totalAllocatedShares =
5049 currentSession ?.participants .reduce ((sum , p ) => sum + (p .share || 0 ), 0 ) ||
5150 0 ;
413412 </ul >
414413 {/if }
415414 {:else if allDescriptionsSubmitted && currentParticipant }
416- <input
417- bind:value ={participant .share }
418- on:input ={() => {
419- stakeDistributed =
420- totalAllocatedShares == currentSession .stake ;
421- }}
422- type =" number"
423- step =" 0.01"
424- min =" 0"
425- placeholder =" Share"
426- class =" input"
427- />
415+ <div id =" share-inputs" >
416+ <input
417+ bind:value ={participant .share }
418+ on:input ={() => {
419+ participant .percentage =
420+ ((participant .share || 0 ) / currentSession .stake ) * 100 ;
421+ }}
422+ type =" number"
423+ step =" 0.01"
424+ min =" 0"
425+ placeholder =" Share"
426+ class =" share-input"
427+ />
428+
429+ <input
430+ bind:value ={participant .percentage }
431+ on:input ={(e ) => {
432+ const raw = parseFloat (
433+ (e .target as HTMLInputElement ).value
434+ );
435+ const percentage = isNaN (raw ) ? 0 : raw ;
436+ participant .share =
437+ (currentSession .stake * percentage ) / 100 ;
438+ }}
439+ type =" number"
440+ step =" 0.01"
441+ min =" 0"
442+ placeholder =" Percentage"
443+ class =" share-input"
444+ />
445+ </div >
428446 <textarea bind:value ={participant .reason } placeholder =" Reason"
429447 ></textarea >
430448 {/if }
452470 updateCurrentParticipant ()}>Confirm shares</button
453471 >
454472 {/if }
455- {:else if currentParticipant && stakeDistributed }
473+ {:else if currentParticipant && totalAllocatedShares == currentSession . stake }
456474 <button on:click ={submitVote }>Submit Vote</button >
457475 {/if }
458476 {:else if sessionKeys }
581599 }
582600 }
583601
602+ #share-inputs {
603+ display : flex ;
604+ gap : 0.5rem ;
605+ flex-wrap : wrap ;
606+
607+ .share-input {
608+ flex : 1 ;
609+ }
610+ }
611+
584612 button {
585613 width : min-content ;
586614 white-space : nowrap ;
You can’t perform that action at this time.
0 commit comments