fix: synchronize shadow book save state
This commit is contained in:
@@ -41,6 +41,7 @@ export function PerformanceSettings() {
|
|||||||
const saveBook = useMutation({
|
const saveBook = useMutation({
|
||||||
mutationFn: (payload: Partial<ShadowBookConfig>) => updateShadowBookSettings(payload),
|
mutationFn: (payload: Partial<ShadowBookConfig>) => updateShadowBookSettings(payload),
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
|
qc.setQueryData(['admin', 'shadow-book'], data);
|
||||||
setBook(data);
|
setBook(data);
|
||||||
qc.invalidateQueries({ queryKey: ['admin', 'shadow-book'] });
|
qc.invalidateQueries({ queryKey: ['admin', 'shadow-book'] });
|
||||||
qc.invalidateQueries({ queryKey: ['paper-trades', 'performance'] });
|
qc.invalidateQueries({ queryKey: ['paper-trades', 'performance'] });
|
||||||
@@ -115,8 +116,9 @@ export function PerformanceSettings() {
|
|||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={book.enabled}
|
checked={book.enabled}
|
||||||
|
disabled={saveBook.isPending}
|
||||||
onChange={(e) => setBook({ ...book, enabled: e.target.checked })}
|
onChange={(e) => setBook({ ...book, enabled: e.target.checked })}
|
||||||
className="mt-0.5"
|
className="mt-0.5 disabled:cursor-wait disabled:opacity-50"
|
||||||
/>
|
/>
|
||||||
<span>
|
<span>
|
||||||
<span className="text-sm text-gray-200">Shadow book enabled</span>
|
<span className="text-sm text-gray-200">Shadow book enabled</span>
|
||||||
@@ -136,8 +138,9 @@ export function PerformanceSettings() {
|
|||||||
min={1}
|
min={1}
|
||||||
max={100}
|
max={100}
|
||||||
value={book.capacity}
|
value={book.capacity}
|
||||||
|
disabled={saveBook.isPending}
|
||||||
onChange={(e) => setBook({ ...book, capacity: Number(e.target.value) })}
|
onChange={(e) => setBook({ ...book, capacity: Number(e.target.value) })}
|
||||||
className="input-glass w-full px-3 py-2 text-sm"
|
className="input-glass w-full px-3 py-2 text-sm disabled:cursor-wait disabled:opacity-50"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<label className="block space-y-1">
|
<label className="block space-y-1">
|
||||||
@@ -148,8 +151,9 @@ export function PerformanceSettings() {
|
|||||||
min={0.05}
|
min={0.05}
|
||||||
max={10}
|
max={10}
|
||||||
value={book.risk_pct}
|
value={book.risk_pct}
|
||||||
|
disabled={saveBook.isPending}
|
||||||
onChange={(e) => setBook({ ...book, risk_pct: Number(e.target.value) })}
|
onChange={(e) => setBook({ ...book, risk_pct: Number(e.target.value) })}
|
||||||
className="input-glass w-full px-3 py-2 text-sm"
|
className="input-glass w-full px-3 py-2 text-sm disabled:cursor-wait disabled:opacity-50"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<label className="block space-y-1">
|
<label className="block space-y-1">
|
||||||
@@ -159,8 +163,9 @@ export function PerformanceSettings() {
|
|||||||
min={1000}
|
min={1000}
|
||||||
step={1000}
|
step={1000}
|
||||||
value={book.start_equity}
|
value={book.start_equity}
|
||||||
|
disabled={saveBook.isPending}
|
||||||
onChange={(e) => setBook({ ...book, start_equity: Number(e.target.value) })}
|
onChange={(e) => setBook({ ...book, start_equity: Number(e.target.value) })}
|
||||||
className="input-glass w-full px-3 py-2 text-sm"
|
className="input-glass w-full px-3 py-2 text-sm disabled:cursor-wait disabled:opacity-50"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user