Update status of the parent component
This commit is contained in:
parent
b7e2bbb46f
commit
d307ff6927
@ -1,9 +1,6 @@
|
||||
import { Slider } from 'primereact/slider';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
export default function AffinitySlider({ initialValue, onChange }: { initialValue: number, onChange?: (value: number) => void }) {
|
||||
const [value, setValue] = useState(initialValue);
|
||||
useEffect(() => {setValue(initialValue)}, [initialValue]);
|
||||
export default function AffinitySlider({value , onChange }: { value: number, onChange: (value: number) => void }) {
|
||||
|
||||
const label = (value: number) => {
|
||||
if (value < 0.2) {
|
||||
@ -25,7 +22,7 @@ export default function AffinitySlider({ initialValue, onChange }: { initialValu
|
||||
|
||||
return (
|
||||
<>
|
||||
<Slider value={value} min={0} max={2} step={.1} onChange={(e) =>setValue(e.value)} className='w-80 bg-gray-400' />
|
||||
<Slider value={value} min={0} max={2} step={.1} onChange={(e) =>onChange(e.value)} className='w-80 bg-gray-400' />
|
||||
<span className="px-4 w-1/5">
|
||||
{ label(value) }
|
||||
</span>
|
||||
|
@ -113,7 +113,7 @@ export default function GroupFormDialog({ groups, onCreate, onHide, group, visib
|
||||
groups.map((group) =>
|
||||
<div key={group.id} className="flex flex-row hover:bg-gray-300 px-3 py-2 items-center">
|
||||
<span className="w-1/3 text-right px-4">{group.name}</span>
|
||||
<AffinitySlider initialValue={group.id && affinities[group.id] || 2} />
|
||||
<AffinitySlider value={group.id && affinities[group.id] || 2} onChange={(value) => setAffinities({...affinities, [group.id || "default"]:value})} />
|
||||
</div>)
|
||||
}
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user