Big refactoring
Deploy / lint (push) Failing after 21s
Deploy / test (push) Has been skipped
Deploy / deploy (push) Has been skipped

This commit is contained in:
Dennis Thiessen
2026-03-03 15:20:18 +01:00
parent 181cfe6588
commit 0a011d4ce9
55 changed files with 6898 additions and 544 deletions
@@ -0,0 +1,97 @@
import { useEffect, useState } from 'react';
import {
useBootstrapTickers,
useTickerUniverseSetting,
useUpdateTickerUniverseSetting,
} from '../../hooks/useAdmin';
import type { TickerUniverse } from '../../lib/types';
const UNIVERSE_OPTIONS: Array<{ value: TickerUniverse; label: string }> = [
{ value: 'sp500', label: 'S&P 500' },
{ value: 'nasdaq100', label: 'NASDAQ 100' },
{ value: 'nasdaq_all', label: 'NASDAQ All' },
];
export function TickerUniverseBootstrap() {
const { data, isLoading, isError, error } = useTickerUniverseSetting();
const updateDefault = useUpdateTickerUniverseSetting();
const bootstrap = useBootstrapTickers();
const [universe, setUniverse] = useState<TickerUniverse>('sp500');
const [pruneMissing, setPruneMissing] = useState(false);
useEffect(() => {
if (data?.universe) {
setUniverse(data.universe);
}
}, [data]);
const onSaveDefault = () => {
updateDefault.mutate(universe);
};
const onBootstrap = () => {
bootstrap.mutate({ universe, pruneMissing });
};
return (
<div className="glass p-5 space-y-4">
<h3 className="text-sm font-semibold text-gray-200">Ticker Universe Discovery</h3>
<p className="text-xs text-gray-500">
Auto-discover tickers from a predefined universe and keep your registry updated.
</p>
{isError && (
<p className="text-sm text-red-400">
{(error as Error)?.message || 'Failed to load ticker universe setting'}
</p>
)}
<div className="grid gap-4 md:grid-cols-3">
<label className="block space-y-1 md:col-span-2">
<span className="text-xs text-gray-400">Default Universe</span>
<select
value={universe}
onChange={(e) => setUniverse(e.target.value as TickerUniverse)}
className="w-full input-glass px-3 py-2 text-sm"
disabled={isLoading || updateDefault.isPending || bootstrap.isPending}
>
{UNIVERSE_OPTIONS.map((option) => (
<option key={option.value} value={option.value}>
{option.label}
</option>
))}
</select>
</label>
<label className="flex items-end gap-2 pb-2">
<input
type="checkbox"
checked={pruneMissing}
onChange={(e) => setPruneMissing(e.target.checked)}
disabled={bootstrap.isPending}
className="h-4 w-4 rounded border-white/20 bg-transparent"
/>
<span className="text-xs text-gray-400">Prune removed symbols</span>
</label>
</div>
<div className="flex flex-wrap gap-2">
<button
className="btn-gradient px-4 py-2 text-sm disabled:opacity-50"
onClick={onSaveDefault}
disabled={isLoading || updateDefault.isPending || bootstrap.isPending}
>
{updateDefault.isPending ? 'Saving…' : 'Save Default Universe'}
</button>
<button
className="px-4 py-2 text-sm rounded border border-white/[0.1] text-gray-300 hover:text-white disabled:opacity-50"
onClick={onBootstrap}
disabled={isLoading || updateDefault.isPending || bootstrap.isPending}
>
{bootstrap.isPending ? 'Bootstrapping…' : 'Bootstrap Now'}
</button>
</div>
</div>
);
}