After doing the redesign some tables

This commit is contained in:
Your Name 2026-07-01 12:22:21 +02:00
parent f637f68976
commit 6c4650ccf3
7 changed files with 642 additions and 377 deletions

View File

@ -69,7 +69,6 @@ export function CandlePredictPage() {
const { isAdmin } = useAuth();
const theme = useTheme();
const isCompact = useMediaQuery(theme.breakpoints.down('md'));
const chartHeight = isCompact ? 300 : 380;
const [selectedIntervalMinutes, setSelectedIntervalMinutes] = useState<number | undefined>(
undefined
@ -123,6 +122,7 @@ export function CandlePredictPage() {
const state = stateQ.data;
const config = state?.config;
const chartHeight = isCompact ? 300 : 380;
const predictionTypes = config?.predictionTypes ?? {
single: true,
auto: true,
@ -468,6 +468,20 @@ export function CandlePredictPage() {
);
}
const autoPanelProps = {
config,
interval,
intervals,
settings: state?.autoSettings ?? null,
mainBalanceLabel: walletLabels.main,
bonusBalanceLabel: walletLabels.bonus,
testBalanceLabel: walletLabels.test,
saveError: autoSaveError,
onClearSaveError: () => setAutoSaveError(null),
onSave: saveAuto,
saving: autoMut.isPending,
};
return (
<Box sx={{ minWidth: 0 }}>
<Stack
@ -556,10 +570,11 @@ export function CandlePredictPage() {
label={statusLabel}
sx={{
fontWeight: 800,
maxWidth: '100%',
maxWidth: { xs: '100%', lg: 'min(100%, 720px)' },
height: 'auto',
alignSelf: { xs: 'stretch', sm: 'flex-end' },
'& .MuiChip-label': {
whiteSpace: 'normal',
whiteSpace: { xs: 'normal', md: 'nowrap' },
py: 0.75,
lineHeight: 1.35,
fontSize: { xs: '0.75rem', sm: '0.8125rem' },
@ -578,11 +593,11 @@ export function CandlePredictPage() {
sx={{
display: 'grid',
gap: 2,
gridTemplateColumns: { xs: '1fr', lg: '1fr 360px' },
alignItems: 'start',
gridTemplateColumns: { xs: '1fr', lg: 'minmax(0, 1fr) minmax(300px, 360px)' },
alignItems: 'stretch',
}}
>
<Stack spacing={2}>
<Stack spacing={2} sx={{ minWidth: 0, height: '100%' }}>
{isAdmin && <AdminPoolInsights config={config} interval={interval} round={round} />}
<Paper sx={{ p: { xs: 1.5, sm: 2 }, borderRadius: 3, display: { xs: 'block', lg: 'none' } }}>
@ -591,64 +606,53 @@ export function CandlePredictPage() {
{showAutoPanel && (
<Box sx={{ display: { xs: 'block', lg: 'none' } }}>
<AutoPredictionPanel
config={config}
interval={interval}
intervals={intervals}
settings={state.autoSettings}
mainBalanceLabel={walletLabels.main}
bonusBalanceLabel={walletLabels.bonus}
testBalanceLabel={walletLabels.test}
saveError={autoSaveError}
onClearSaveError={() => setAutoSaveError(null)}
onSave={saveAuto}
saving={autoMut.isPending}
/>
<AutoPredictionPanel {...autoPanelProps} />
</Box>
)}
{candlesQ.isLoading ? (
<Skeleton variant="rounded" height={chartHeight} />
) : (
<CandlestickChart
candles={candlesQ.candles}
height={chartHeight}
hasMoreOlder={candlesQ.hasMore}
loadingOlder={candlesQ.loadingMore}
onLoadOlder={() => void candlesQ.loadOlder()}
/>
)}
<RecentPredictionsPanel
refreshKey={predictionsRefreshKey}
autoPredictionEnabled={state.autoSettings?.enabled}
roundStatus={round?.status}
intervalMinutes={activeIntervalMinutes}
/>
<Box
sx={{
flex: 1,
minHeight: chartHeight,
display: { xs: 'block', lg: 'flex' },
flexDirection: 'column',
}}
>
{candlesQ.isLoading ? (
<Skeleton variant="rounded" height={chartHeight} sx={{ flex: { lg: 1 } }} />
) : (
<CandlestickChart
candles={candlesQ.candles}
height={chartHeight}
fillHeight={!isCompact}
hasMoreOlder={candlesQ.hasMore}
loadingOlder={candlesQ.loadingMore}
onLoadOlder={() => void candlesQ.loadOlder()}
/>
)}
</Box>
</Stack>
<Stack spacing={2}>
<Stack spacing={2} sx={{ minWidth: 0 }}>
<Box sx={{ display: { xs: 'none', lg: 'block' } }}>{renderBettingPanels()}</Box>
{showAutoPanel && (
<Box sx={{ display: { xs: 'none', lg: 'block' } }}>
<AutoPredictionPanel
config={config}
interval={interval}
intervals={intervals}
settings={state.autoSettings}
mainBalanceLabel={walletLabels.main}
bonusBalanceLabel={walletLabels.bonus}
testBalanceLabel={walletLabels.test}
saveError={autoSaveError}
onClearSaveError={() => setAutoSaveError(null)}
onSave={saveAuto}
saving={autoMut.isPending}
/>
</Box>
)}
</Stack>
</Box>
{showAutoPanel && (
<Box sx={{ display: { xs: 'none', lg: 'block' }, mt: 2 }}>
<AutoPredictionPanel {...autoPanelProps} layout="horizontal" />
</Box>
)}
<Box sx={{ mt: 2 }}>
<RecentPredictionsPanel
refreshKey={predictionsRefreshKey}
autoPredictionEnabled={state.autoSettings?.enabled}
roundStatus={round?.status}
intervalMinutes={activeIntervalMinutes}
/>
</Box>
<Snackbar
open={!!toast}
autoHideDuration={3500}

View File

@ -38,12 +38,24 @@ type Props = {
}
) => Promise<void>;
saving?: boolean;
/** Compact horizontal bar when auto is already enabled (desktop layout). */
layout?: 'vertical' | 'horizontal';
};
function intervalLabel(intervals: CandlePredictInterval[], minutes: number): string {
return intervals.find((i) => i.intervalMinutes === minutes)?.label ?? `${minutes} min`;
}
function stakeAccountShort(kind: StakeAccountKind): string {
if (kind === 'bonus') return 'Bonus';
if (kind === 'test') return 'Test';
return 'Main';
}
function modeShort(mode: 'each_round' | 'interval'): string {
return mode === 'interval' ? 'Délai minimum' : 'Chaque manche';
}
/** Auto Prediction configuration panel. */
export function AutoPredictionPanel({
config,
@ -57,9 +69,11 @@ export function AutoPredictionPanel({
onClearSaveError,
onSave,
saving,
layout = 'vertical',
}: Props) {
const serverEnabled = settings?.enabled ?? false;
const [configuring, setConfiguring] = useState(false);
const [editing, setEditing] = useState(false);
const current = settings ?? {
enabled: false,
@ -72,7 +86,9 @@ export function AutoPredictionPanel({
lastAutoBetAt: null,
};
const showForm = serverEnabled || configuring;
const isHorizontal = layout === 'horizontal';
const showCompact = serverEnabled && !editing && !configuring;
const showForm = (serverEnabled || configuring) && !showCompact;
const switchChecked = serverEnabled || configuring;
const [mode, setMode] = useState<'each_round' | 'interval'>(current.mode ?? 'each_round');
@ -85,6 +101,7 @@ export function AutoPredictionPanel({
useEffect(() => {
if (serverEnabled) {
setConfiguring(false);
setEditing(false);
}
}, [serverEnabled]);
@ -127,6 +144,239 @@ export function AutoPredictionPanel({
});
};
const settingsForm = showForm ? (
<Stack
spacing={2}
component="form"
onSubmit={(e) => {
e.preventDefault();
if (!stakeFieldValid) return;
const fd = new FormData(e.currentTarget);
const selectedMode = fd.get('mode') as 'each_round' | 'interval';
void onSave({
enabled: true,
direction: fd.get('direction') as 'short' | 'long',
stakeDisplay: stakeValue,
mode: selectedMode,
stakeAccountKind,
validateWalletBalance: true,
attemptImmediateBet: true,
intervalSeconds:
selectedMode === 'interval'
? Number(fd.get('intervalSeconds') || 60)
: current.intervalSeconds ?? 60,
}).then(() => setEditing(false));
}}
>
<Box
sx={{
px: 1.5,
py: 1.25,
borderRadius: 2,
border: '1px solid rgba(255,255,255,0.1)',
background: 'rgba(0,0,0,0.15)',
}}
>
<Stack direction="row" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap' }}>
<Typography variant="body2" sx={{ fontWeight: 800 }}>
Target period:
</Typography>
<Chip label={targetLabel} size="small" color="secondary" sx={{ fontWeight: 800 }} />
</Stack>
{viewingDifferentPeriod ? (
<Typography variant="caption" sx={{ display: 'block', mt: 0.75, opacity: 0.7 }}>
You are viewing {interval.label}. Save to move auto to {interval.label}.
</Typography>
) : (
<Typography variant="caption" sx={{ display: 'block', mt: 0.75, opacity: 0.7 }}>
Set from the prediction period you select when saving. One auto config per account.
</Typography>
)}
</Box>
<FormControl fullWidth size="small">
<InputLabel>Direction</InputLabel>
<Select name="direction" label="Direction" defaultValue={current.direction ?? 'short'}>
<MenuItem value="short">Short candle</MenuItem>
<MenuItem value="long">Long candle</MenuItem>
</Select>
</FormControl>
<StakeWalletSelector
value={stakeAccountKind}
onChange={(kind) => {
onClearSaveError?.();
setStakeAccountKind(kind);
}}
mainBalanceLabel={mainBalanceLabel}
bonusBalanceLabel={bonusBalanceLabel}
testBalanceLabel={testBalanceLabel}
/>
<CustomStakeAmountField
label="Stake amount"
value={stakeValue}
minStake={config.minStakeAmount}
maxStake={config.maxStakeAmount}
onValidChange={setStakeValue}
onValidityChange={setStakeFieldValid}
helperText={`Quick picks: ${config.stakeAmounts.join(', ')} · custom from ${config.minStakeAmount} to ${config.maxStakeAmount} USDT`}
/>
<FormControl fullWidth size="small">
<InputLabel>Mode</InputLabel>
<Select
name="mode"
label="Mode"
value={mode}
onChange={(e) => setMode(e.target.value as 'each_round' | 'interval')}
>
{config.autoModes.includes('each_round') && (
<MenuItem value="each_round">Chaque nouvelle manche</MenuItem>
)}
{config.autoModes.includes('interval') && (
<MenuItem value="interval">Délai minimum</MenuItem>
)}
</Select>
<FormHelperText>
{mode === 'interval'
? 'Une mise par manche maximum. Attend au moins le délai indiqué depuis la dernière mise auto avant de parier sur la manche suivante (ou au save).'
: 'Place une mise dès l’ouverture de la fenêtre de prédiction de chaque nouvelle manche.'}
</FormHelperText>
</FormControl>
{mode === 'interval' && (
<TextField
name="intervalSeconds"
label="Délai minimum entre mises auto (secondes)"
type="number"
size="small"
defaultValue={current.intervalSeconds ?? 60}
slotProps={{
htmlInput: { min: 1, step: 1 },
}}
helperText="Temps minimal depuis la dernière mise auto réussie. Ne permet pas plusieurs mises sur la même manche — seulement d’espacer deux mises consécutives (ex. après un enregistrement récent)."
/>
)}
<Stack direction="row" spacing={1} sx={{ flexWrap: 'wrap' }}>
<Button type="submit" variant="outlined" disabled={saving || !stakeFieldValid}>
Enregistrer les paramètres auto
</Button>
{serverEnabled && (
<Button type="button" variant="text" onClick={() => setEditing(false)} disabled={saving}>
Annuler
</Button>
)}
</Stack>
</Stack>
) : null;
if (!serverEnabled && !configuring && isHorizontal) {
return (
<Box
sx={{
p: { xs: 1.5, md: 2 },
borderRadius: 3,
border: '1px solid rgba(255,255,255,0.08)',
background: 'rgba(124,92,255,0.04)',
}}
>
<Stack
direction={{ xs: 'column', sm: 'row' }}
spacing={1.5}
sx={{ alignItems: { sm: 'center' }, justifyContent: 'space-between' }}
>
<Stack direction="row" spacing={1} sx={{ alignItems: 'center', minWidth: 0 }}>
<AutoModeRoundedIcon color="secondary" fontSize="small" />
<Box sx={{ minWidth: 0 }}>
<Typography sx={{ fontWeight: 900 }}>Auto Prediction</Typography>
<Typography variant="caption" sx={{ opacity: 0.65, display: 'block' }}>
Activez pour parier automatiquement à chaque manche.
</Typography>
</Box>
</Stack>
<FormControlLabel
sx={{ m: 0, flexShrink: 0 }}
control={
<Switch checked={switchChecked} onChange={(e) => void handleToggle(e.target.checked)} />
}
label="Activer la prédiction auto"
/>
</Stack>
{current.lastAutoBetAt && (
<Typography variant="caption" sx={{ opacity: 0.65, display: 'block', mt: 1 }}>
Dernière mise auto : {new Date(current.lastAutoBetAt).toLocaleString()}
</Typography>
)}
</Box>
);
}
if (showCompact && isHorizontal) {
const directionLabel = current.direction === 'long' ? 'Long' : 'Short';
const accountKind = current.stakeAccountKind ?? 'main';
return (
<Box
sx={{
p: { xs: 1.5, md: 2 },
borderRadius: 3,
border: '1px solid rgba(124,92,255,0.35)',
background: 'rgba(124,92,255,0.08)',
}}
>
<Stack spacing={1.5}>
<Stack
direction={{ xs: 'column', sm: 'row' }}
spacing={1.5}
sx={{ alignItems: { sm: 'center' }, justifyContent: 'space-between' }}
>
<Stack direction="row" spacing={1} sx={{ alignItems: 'center', flexShrink: 0 }}>
<AutoModeRoundedIcon color="secondary" fontSize="small" />
<Typography sx={{ fontWeight: 900 }}>Prédiction auto active</Typography>
</Stack>
<Stack direction="row" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap' }}>
<Button size="small" variant="outlined" onClick={() => setEditing(true)} sx={{ fontWeight: 800 }}>
Modifier
</Button>
<FormControlLabel
sx={{ m: 0 }}
control={
<Switch
size="small"
checked={switchChecked}
onChange={(e) => void handleToggle(e.target.checked)}
/>
}
label="Désactiver"
/>
</Stack>
</Stack>
<Stack direction="row" spacing={0.75} useFlexGap sx={{ flexWrap: 'wrap', alignItems: 'center' }}>
<Chip label={targetLabel} size="small" color="secondary" sx={{ fontWeight: 800 }} />
<Chip label={directionLabel} size="small" variant="outlined" sx={{ fontWeight: 700 }} />
<Chip
label={`${current.stakeDisplay ?? 1} USDT`}
size="small"
variant="outlined"
sx={{ fontWeight: 700 }}
/>
<Chip label={stakeAccountShort(accountKind)} size="small" variant="outlined" sx={{ fontWeight: 700 }} />
<Chip label={modeShort(current.mode ?? 'each_round')} size="small" variant="outlined" sx={{ fontWeight: 700 }} />
</Stack>
{current.lastAutoBetAt && (
<Typography variant="caption" sx={{ opacity: 0.7 }}>
Dernière mise auto : {new Date(current.lastAutoBetAt).toLocaleString()}
</Typography>
)}
</Stack>
</Box>
);
}
return (
<Box
sx={{
@ -143,20 +393,60 @@ export function AutoPredictionPanel({
Auto Prediction
</Typography>
</Stack>
<Typography variant="body2" sx={{ opacity: 0.75 }}>
Place automatiquement <strong>une prédiction par manche</strong> sur la période cible, avec
les paramètres ci-dessous. La mise est prélevée sur le portefeuille sélectionné. Rien n&apos;est
envoyé tant que vous n&apos;avez pas cliqué sur <strong>Enregistrer</strong>.
</Typography>
{!showCompact && (
<Typography variant="body2" sx={{ opacity: 0.75 }}>
Place automatiquement <strong>une prédiction par manche</strong> sur la période cible, avec
les paramètres ci-dessous. La mise est prélevée sur le portefeuille sélectionné. Rien n&apos;est
envoyé tant que vous n&apos;avez pas cliqué sur <strong>Enregistrer</strong>.
</Typography>
)}
{saveError && showForm && <Alert severity="error">{saveError}</Alert>}
<FormControlLabel
control={
<Switch checked={switchChecked} onChange={(e) => void handleToggle(e.target.checked)} />
}
label="Activer la prédiction auto"
/>
{showCompact && !isHorizontal ? (
<>
<Stack direction="row" spacing={0.75} useFlexGap sx={{ flexWrap: 'wrap', alignItems: 'center' }}>
<Chip label={targetLabel} size="small" color="secondary" sx={{ fontWeight: 800 }} />
<Chip
label={current.direction === 'long' ? 'Long' : 'Short'}
size="small"
variant="outlined"
sx={{ fontWeight: 700 }}
/>
<Chip
label={`${current.stakeDisplay ?? 1} USDT`}
size="small"
variant="outlined"
sx={{ fontWeight: 700 }}
/>
<Chip
label={stakeAccountShort(current.stakeAccountKind ?? 'main')}
size="small"
variant="outlined"
sx={{ fontWeight: 700 }}
/>
</Stack>
<Stack direction="row" spacing={1} sx={{ flexWrap: 'wrap' }}>
<Button size="small" variant="outlined" onClick={() => setEditing(true)} sx={{ fontWeight: 800 }}>
Modifier les paramètres
</Button>
</Stack>
{current.lastAutoBetAt && (
<Typography variant="caption" sx={{ opacity: 0.7 }}>
Dernière mise auto : {new Date(current.lastAutoBetAt).toLocaleString()}
</Typography>
)}
</>
) : null}
{(showCompact || !serverEnabled) && (
<FormControlLabel
control={
<Switch checked={switchChecked} onChange={(e) => void handleToggle(e.target.checked)} />
}
label="Activer la prédiction auto"
/>
)}
{configuring && !serverEnabled && (
<Alert severity="info" sx={{ borderRadius: 2 }}>
@ -166,126 +456,9 @@ export function AutoPredictionPanel({
</Alert>
)}
{showForm && (
<Stack
spacing={2}
component="form"
onSubmit={(e) => {
e.preventDefault();
if (!stakeFieldValid) return;
const fd = new FormData(e.currentTarget);
const selectedMode = fd.get('mode') as 'each_round' | 'interval';
void onSave({
enabled: true,
direction: fd.get('direction') as 'short' | 'long',
stakeDisplay: stakeValue,
mode: selectedMode,
stakeAccountKind,
validateWalletBalance: true,
attemptImmediateBet: true,
intervalSeconds:
selectedMode === 'interval' ? Number(fd.get('intervalSeconds') || 60) : current.intervalSeconds ?? 60,
});
}}
>
<Box
sx={{
px: 1.5,
py: 1.25,
borderRadius: 2,
border: '1px solid rgba(255,255,255,0.1)',
background: 'rgba(0,0,0,0.15)',
}}
>
<Stack direction="row" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap' }}>
<Typography variant="body2" sx={{ fontWeight: 800 }}>
Target period:
</Typography>
<Chip label={targetLabel} size="small" color="secondary" sx={{ fontWeight: 800 }} />
</Stack>
{viewingDifferentPeriod ? (
<Typography variant="caption" sx={{ display: 'block', mt: 0.75, opacity: 0.7 }}>
You are viewing {interval.label}. Save to move auto to {interval.label}.
</Typography>
) : (
<Typography variant="caption" sx={{ display: 'block', mt: 0.75, opacity: 0.7 }}>
Set from the prediction period you select when saving. One auto config per account.
</Typography>
)}
</Box>
{settingsForm}
<FormControl fullWidth size="small">
<InputLabel>Direction</InputLabel>
<Select name="direction" label="Direction" defaultValue={current.direction ?? 'short'}>
<MenuItem value="short">Short candle</MenuItem>
<MenuItem value="long">Long candle</MenuItem>
</Select>
</FormControl>
<StakeWalletSelector
value={stakeAccountKind}
onChange={(kind) => {
onClearSaveError?.();
setStakeAccountKind(kind);
}}
mainBalanceLabel={mainBalanceLabel}
bonusBalanceLabel={bonusBalanceLabel}
testBalanceLabel={testBalanceLabel}
/>
<CustomStakeAmountField
label="Stake amount"
value={stakeValue}
minStake={config.minStakeAmount}
maxStake={config.maxStakeAmount}
onValidChange={setStakeValue}
onValidityChange={setStakeFieldValid}
helperText={`Quick picks: ${config.stakeAmounts.join(', ')} · custom from ${config.minStakeAmount} to ${config.maxStakeAmount} USDT`}
/>
<FormControl fullWidth size="small">
<InputLabel>Mode</InputLabel>
<Select
name="mode"
label="Mode"
value={mode}
onChange={(e) => setMode(e.target.value as 'each_round' | 'interval')}
>
{config.autoModes.includes('each_round') && (
<MenuItem value="each_round">Chaque nouvelle manche</MenuItem>
)}
{config.autoModes.includes('interval') && (
<MenuItem value="interval">Délai minimum</MenuItem>
)}
</Select>
<FormHelperText>
{mode === 'interval'
? 'Une mise par manche maximum. Attend au moins le délai indiqué depuis la dernière mise auto avant de parier sur la manche suivante (ou au save).'
: 'Place une mise dès l’ouverture de la fenêtre de prédiction de chaque nouvelle manche.'}
</FormHelperText>
</FormControl>
{mode === 'interval' && (
<TextField
name="intervalSeconds"
label="Délai minimum entre mises auto (secondes)"
type="number"
size="small"
defaultValue={current.intervalSeconds ?? 60}
slotProps={{
htmlInput: { min: 1, step: 1 },
}}
helperText="Temps minimal depuis la dernière mise auto réussie. Ne permet pas plusieurs mises sur la même manche — seulement d’espacer deux mises consécutives (ex. après un enregistrement récent)."
/>
)}
<Button type="submit" variant="outlined" disabled={saving || !stakeFieldValid}>
Enregistrer les paramètres auto
</Button>
</Stack>
)}
{current.lastAutoBetAt && (
{!showCompact && current.lastAutoBetAt && (
<Alert severity="info" sx={{ py: 0.5 }}>
Dernière mise auto : {new Date(current.lastAutoBetAt).toLocaleString()}
</Alert>

View File

@ -13,6 +13,8 @@ const LOAD_MORE_THRESHOLD = 8;
type Props = {
candles: OhlcCandle[];
height?: number;
/** Grow to fill the parent flex/grid cell (height from ResizeObserver). */
fillHeight?: boolean;
hasMoreOlder?: boolean;
loadingOlder?: boolean;
onLoadOlder?: () => void;
@ -54,6 +56,7 @@ function applyFixedViewport(chart: IChartApi, barCount: number, followLatest: bo
export function CandlestickChart({
candles,
height = 380,
fillHeight = false,
hasMoreOlder = false,
loadingOlder = false,
onLoadOlder,
@ -76,8 +79,11 @@ export function CandlestickChart({
useEffect(() => {
if (!containerRef.current) return;
const chart = createChart(containerRef.current, {
height,
const container = containerRef.current;
const measuredHeight = fillHeight ? container.clientHeight || height : height;
const chart = createChart(container, {
height: measuredHeight,
layout: {
background: { type: ColorType.Solid, color: 'transparent' },
textColor: 'rgba(255,255,255,0.72)',
@ -150,10 +156,15 @@ export function CandlestickChart({
chart.timeScale().subscribeVisibleLogicalRangeChange(onRangeChange);
const ro = new ResizeObserver(() => {
if (containerRef.current) {
chart.applyOptions({ width: containerRef.current.clientWidth });
applyFixedViewport(chart, series.data().length, followLatestRef.current);
}
if (!containerRef.current) return;
const nextHeight = fillHeight
? containerRef.current.clientHeight || height
: height;
chart.applyOptions({
width: containerRef.current.clientWidth,
height: nextHeight,
});
applyFixedViewport(chart, series.data().length, followLatestRef.current);
});
ro.observe(containerRef.current);
@ -164,7 +175,7 @@ export function CandlestickChart({
chartRef.current = null;
seriesRef.current = null;
};
}, [height]);
}, [height, fillHeight]);
useEffect(() => {
if (!seriesRef.current || !chartRef.current) return;
@ -209,12 +220,12 @@ export function CandlestickChart({
}, [candles]);
return (
<Box sx={{ position: 'relative' }}>
<Box sx={{ position: 'relative', height: fillHeight ? '100%' : undefined, flex: fillHeight ? 1 : undefined }}>
<Box
ref={containerRef}
sx={{
width: '100%',
minHeight: height,
...(fillHeight ? { height: '100%', minHeight: height } : { minHeight: height }),
borderRadius: 3,
overflow: 'hidden',
border: '1px solid rgba(255,255,255,0.08)',

View File

@ -18,6 +18,7 @@ import {
import { useTheme } from '@mui/material/styles';
import useMediaQuery from '@mui/material/useMediaQuery';
import { useEffect, useState } from 'react';
import { ScrollableTable } from '../../../shared/components/ScrollableTable';
import {
PREDICTIONS_PAGE_SIZE,
useMyCandlePredictions,
@ -203,21 +204,28 @@ function ModeChip({ prediction }: { prediction: CandlePredictPrediction }) {
bgcolor: `${MULTI_ACCENT}22`,
color: MULTI_ACCENT,
border: `1px solid ${MULTI_ACCENT}55`,
whiteSpace: 'nowrap',
flexShrink: 0,
}}
/>
);
}
return (
<Stack direction="row" spacing={0.5} useFlexGap sx={{ flexWrap: 'wrap' }}>
<Stack direction="row" spacing={0.5} sx={{ alignItems: 'center', flexWrap: 'nowrap', width: 'max-content' }}>
<Chip
label="Single"
size="small"
variant="outlined"
sx={{ fontWeight: 800, fontSize: 11 }}
sx={{ fontWeight: 800, fontSize: 11, flexShrink: 0 }}
/>
{prediction.isAuto && (
<Chip label="Auto" size="small" color="warning" sx={{ fontWeight: 700, fontSize: 11 }} />
<Chip
label="Auto"
size="small"
color="warning"
sx={{ fontWeight: 700, fontSize: 11, flexShrink: 0 }}
/>
)}
</Stack>
);
@ -329,6 +337,53 @@ function PredictionCell({ prediction }: { prediction: CandlePredictPrediction })
return <DirectionCell direction={prediction.direction} />;
}
function PeriodCell({
prediction,
period,
}: {
prediction: CandlePredictPrediction;
period: ReturnType<typeof formatCandlePeriod>;
}) {
const meta = [period.detail, period.placedAt].filter(Boolean).join(' · ');
return (
<Box>
<Stack direction="row" spacing={0.75} sx={{ alignItems: 'center', flexWrap: 'nowrap' }}>
<Typography variant="body2" sx={{ fontWeight: 600, whiteSpace: 'nowrap' }}>
{period.range}
</Typography>
<Chip
label={`${prediction.intervalMinutes}m`}
size="small"
variant="outlined"
sx={{ height: 20, fontSize: 11, flexShrink: 0 }}
/>
</Stack>
{meta && (
<Typography
variant="caption"
sx={{ opacity: 0.65, whiteSpace: 'nowrap', display: 'block', mt: 0.25 }}
>
{meta}
</Typography>
)}
</Box>
);
}
const predictionsTableSx = {
width: '100%',
'& th': {
fontWeight: 700,
whiteSpace: 'nowrap',
py: 1.25,
},
'& td': {
verticalAlign: 'middle',
py: 1.25,
},
} as const;
/** Paginated list of the user's latest Candle Predict predictions. */
export function RecentPredictionsPanel({
refreshKey,
@ -361,7 +416,7 @@ export function RecentPredictionsPanel({
const total = predictionsQ.data?.total ?? 0;
return (
<Paper sx={{ p: 2, borderRadius: 3, overflowX: 'auto' }}>
<Paper sx={{ p: 2, borderRadius: 3, minWidth: 0 }}>
<Stack
direction={{ xs: 'column', sm: 'row' }}
spacing={1}
@ -459,93 +514,88 @@ export function RecentPredictionsPanel({
</>
) : (
<>
<Table size="small">
<TableHead>
<TableRow>
<TableCell>Mode</TableCell>
<TableCell>Prediction</TableCell>
<TableCell>Period</TableCell>
<TableCell>Stake</TableCell>
<TableCell>Account</TableCell>
<TableCell>Status</TableCell>
<TableCell>Payout</TableCell>
</TableRow>
</TableHead>
<TableBody>
{items.map((p) => {
const period = formatCandlePeriod(p);
const progressDetail = multiProgressDetail(p);
return (
<TableRow
key={p.id}
sx={
isMultiPrediction(p)
? { '& td': { borderBottomColor: `${MULTI_ACCENT}22` } }
: undefined
}
>
<TableCell>
<ModeChip prediction={p} />
</TableCell>
<TableCell sx={{ minWidth: 220 }}>
<PredictionCell prediction={p} />
</TableCell>
<TableCell>
<Stack spacing={0.25}>
<Stack direction="row" spacing={0.75} sx={{ alignItems: 'center' }}>
<Typography variant="body2" sx={{ fontWeight: 600 }}>
{period.range}
</Typography>
<Chip
label={`${p.intervalMinutes}m`}
size="small"
variant="outlined"
sx={{ height: 20, fontSize: 11 }}
/>
</Stack>
{period.detail && (
<Typography variant="caption" sx={{ opacity: 0.6 }}>
{period.detail}
</Typography>
)}
<Typography variant="caption" sx={{ opacity: 0.6 }}>
{period.placedAt}
</Typography>
</Stack>
</TableCell>
<TableCell>{p.stakeDisplay}</TableCell>
<TableCell>
<Chip
label={formatStakeAccount(p.stakeAccountKind ?? 'main')}
size="small"
color={stakeAccountChipColor(p.stakeAccountKind ?? 'main')}
variant={p.stakeAccountKind === 'main' ? 'outlined' : 'filled'}
sx={{ fontWeight: 700, fontSize: 11 }}
/>
</TableCell>
<TableCell>
<Stack spacing={0.25}>
<StatusLabel status={p.status} />
{progressDetail && (
<Typography variant="caption" sx={{ opacity: 0.65, fontWeight: 600 }}>
{progressDetail}
</Typography>
)}
</Stack>
</TableCell>
<TableCell>{p.payoutDisplay > 0 ? p.payoutDisplay : '—'}</TableCell>
</TableRow>
);
})}
{!items.length && (
<ScrollableTable minWidth={860}>
<Table size="small" sx={predictionsTableSx}>
<TableHead>
<TableRow>
<TableCell colSpan={7} sx={{ opacity: 0.6 }}>
No predictions yet
<TableCell sx={{ width: '1%', pr: 2 }}>Mode</TableCell>
<TableCell sx={{ minWidth: 160 }}>Prediction</TableCell>
<TableCell sx={{ minWidth: 220 }}>Period</TableCell>
<TableCell align="right" sx={{ width: 72 }}>
Stake
</TableCell>
<TableCell sx={{ width: 88 }}>Account</TableCell>
<TableCell sx={{ minWidth: 110 }}>Status</TableCell>
<TableCell align="right" sx={{ width: 72 }}>
Payout
</TableCell>
</TableRow>
)}
</TableBody>
</Table>
</TableHead>
<TableBody>
{items.map((p) => {
const period = formatCandlePeriod(p);
const progressDetail = multiProgressDetail(p);
return (
<TableRow
key={p.id}
sx={
isMultiPrediction(p)
? { '& td': { borderBottomColor: `${MULTI_ACCENT}22` } }
: undefined
}
>
<TableCell sx={{ whiteSpace: 'nowrap' }}>
<ModeChip prediction={p} />
</TableCell>
<TableCell sx={{ minWidth: 160 }}>
<PredictionCell prediction={p} />
</TableCell>
<TableCell sx={{ minWidth: 220 }}>
<PeriodCell prediction={p} period={period} />
</TableCell>
<TableCell align="right" sx={{ whiteSpace: 'nowrap', fontWeight: 600 }}>
{p.stakeDisplay}
</TableCell>
<TableCell sx={{ whiteSpace: 'nowrap' }}>
<Chip
label={formatStakeAccount(p.stakeAccountKind ?? 'main')}
size="small"
color={stakeAccountChipColor(p.stakeAccountKind ?? 'main')}
variant={p.stakeAccountKind === 'main' ? 'outlined' : 'filled'}
sx={{ fontWeight: 700, fontSize: 11 }}
/>
</TableCell>
<TableCell>
<Stack spacing={0.25} sx={{ minWidth: 0 }}>
<Box sx={{ whiteSpace: 'nowrap' }}>
<StatusLabel status={p.status} />
</Box>
{progressDetail && (
<Typography
variant="caption"
sx={{ opacity: 0.65, fontWeight: 600, whiteSpace: 'nowrap' }}
>
{progressDetail}
</Typography>
)}
</Stack>
</TableCell>
<TableCell align="right" sx={{ whiteSpace: 'nowrap', fontWeight: 600 }}>
{p.payoutDisplay > 0 ? p.payoutDisplay : '—'}
</TableCell>
</TableRow>
);
})}
{!items.length && (
<TableRow>
<TableCell colSpan={7} sx={{ opacity: 0.6 }}>
No predictions yet
</TableCell>
</TableRow>
)}
</TableBody>
</Table>
</ScrollableTable>
{total > PREDICTIONS_PAGE_SIZE && (
<Box sx={{ display: 'flex', justifyContent: 'center', mt: 2 }}>

View File

@ -20,6 +20,7 @@ import {
useUpdateAdminMultiLevels,
} from '../candle-predict/hooks/useCandlePredict';
import type { MultiCandleLevel } from '../candle-predict/types';
import { ScrollableTable } from '../../shared/components/ScrollableTable';
/** Admin panel for multi-candle level configuration. */
export function CandlePredictMultiLevelsPanel() {
@ -67,67 +68,69 @@ export function CandlePredictMultiLevelsPanel() {
</Alert>
)}
<Table size="small">
<TableHead>
<TableRow>
<TableCell>Level</TableCell>
<TableCell>Candles</TableCell>
<TableCell>Enabled</TableCell>
<TableCell>Pool multiplier</TableCell>
<TableCell>Payout multiplier</TableCell>
<TableCell>Sort</TableCell>
</TableRow>
</TableHead>
<TableBody>
{rows.map((row) => (
<TableRow key={row.level}>
<TableCell>{row.level}</TableCell>
<TableCell>{row.candleCount}</TableCell>
<TableCell>
<Switch
checked={row.enabled}
onChange={(e) => updateRow(row.level, { enabled: e.target.checked })}
/>
</TableCell>
<TableCell>
<TextField
type="number"
size="small"
value={row.poolMultiplier}
slotProps={{ htmlInput: { min: 0.01, step: 0.1 } }}
onChange={(e) =>
updateRow(row.level, { poolMultiplier: Number(e.target.value) || 1 })
}
sx={{ width: 100 }}
/>
</TableCell>
<TableCell>
<TextField
type="number"
size="small"
value={row.payoutMultiplier}
slotProps={{ htmlInput: { min: 0.01, step: 0.1 } }}
onChange={(e) =>
updateRow(row.level, { payoutMultiplier: Number(e.target.value) || 1 })
}
sx={{ width: 100 }}
/>
</TableCell>
<TableCell>
<TextField
type="number"
size="small"
value={row.sortOrder}
onChange={(e) =>
updateRow(row.level, { sortOrder: Number(e.target.value) || row.level })
}
sx={{ width: 72 }}
/>
</TableCell>
<ScrollableTable minWidth={720}>
<Table size="small">
<TableHead>
<TableRow>
<TableCell sx={{ whiteSpace: 'nowrap' }}>Level</TableCell>
<TableCell sx={{ whiteSpace: 'nowrap' }}>Candles</TableCell>
<TableCell sx={{ whiteSpace: 'nowrap' }}>Enabled</TableCell>
<TableCell sx={{ whiteSpace: 'nowrap' }}>Pool multiplier</TableCell>
<TableCell sx={{ whiteSpace: 'nowrap' }}>Payout multiplier</TableCell>
<TableCell sx={{ whiteSpace: 'nowrap' }}>Sort</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableHead>
<TableBody>
{rows.map((row) => (
<TableRow key={row.level}>
<TableCell>{row.level}</TableCell>
<TableCell>{row.candleCount}</TableCell>
<TableCell>
<Switch
checked={row.enabled}
onChange={(e) => updateRow(row.level, { enabled: e.target.checked })}
/>
</TableCell>
<TableCell>
<TextField
type="number"
size="small"
value={row.poolMultiplier}
slotProps={{ htmlInput: { min: 0.01, step: 0.1 } }}
onChange={(e) =>
updateRow(row.level, { poolMultiplier: Number(e.target.value) || 1 })
}
sx={{ width: 100 }}
/>
</TableCell>
<TableCell>
<TextField
type="number"
size="small"
value={row.payoutMultiplier}
slotProps={{ htmlInput: { min: 0.01, step: 0.1 } }}
onChange={(e) =>
updateRow(row.level, { payoutMultiplier: Number(e.target.value) || 1 })
}
sx={{ width: 100 }}
/>
</TableCell>
<TableCell>
<TextField
type="number"
size="small"
value={row.sortOrder}
onChange={(e) =>
updateRow(row.level, { sortOrder: Number(e.target.value) || row.level })
}
sx={{ width: 72 }}
/>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</ScrollableTable>
<Button
variant="contained"

View File

@ -36,6 +36,7 @@ import {
formatPercent,
formatRawUsdt,
} from '../utils/format';
import { ScrollableTable } from '../../../shared/components/ScrollableTable';
function gridItem(xs = 12, sm = 6, md = 3) {
return { xs, sm, md };
@ -44,17 +45,21 @@ function gridItem(xs = 12, sm = 6, md = 3) {
function SegmentRow({ label, seg, to }: { label: string; seg: BetSegment; to?: string }) {
const cells = (
<>
<TableCell sx={{ fontWeight: 600 }}>{label}</TableCell>
<TableCell align="right">{formatCount(seg.users)}</TableCell>
<TableCell align="right">{formatCount(seg.predictions)}</TableCell>
<TableCell align="right">{formatRawUsdt(seg.stakeRaw)}</TableCell>
<TableCell sx={{ fontWeight: 600, whiteSpace: 'nowrap' }}>{label}</TableCell>
<TableCell align="right" sx={{ whiteSpace: 'nowrap' }}>{formatCount(seg.users)}</TableCell>
<TableCell align="right" sx={{ whiteSpace: 'nowrap' }}>{formatCount(seg.predictions)}</TableCell>
<TableCell align="right" sx={{ whiteSpace: 'nowrap' }}>{formatRawUsdt(seg.stakeRaw)}</TableCell>
<TableCell
align="right"
sx={{ color: seg.netPnlRaw >= 0 ? 'success.main' : 'error.main', fontWeight: 600 }}
sx={{
color: seg.netPnlRaw >= 0 ? 'success.main' : 'error.main',
fontWeight: 600,
whiteSpace: 'nowrap',
}}
>
{formatRawUsdt(seg.netPnlRaw)}
</TableCell>
<TableCell align="right">{seg.winRate.toFixed(2)}%</TableCell>
<TableCell align="right" sx={{ whiteSpace: 'nowrap' }}>{seg.winRate.toFixed(2)}%</TableCell>
</>
);
@ -78,10 +83,12 @@ function FixedTableCard({
title,
children,
reportTo,
tableMinWidth = 640,
}: {
title: string;
children: ReactNode;
reportTo?: string;
tableMinWidth?: number;
}) {
return (
<Card sx={{ overflow: 'hidden', height: '100%' }}>
@ -89,7 +96,7 @@ function FixedTableCard({
<Typography variant="subtitle2" sx={{ fontWeight: 700, px: 2, pt: 2, pb: 1 }}>
{title}
</Typography>
<Box sx={{ width: '100%', maxWidth: '100%', minWidth: 0, overflowX: 'auto' }}>{children}</Box>
<ScrollableTable minWidth={tableMinWidth}>{children}</ScrollableTable>
{reportTo && (
<Box sx={{ px: 2, pb: 1.5 }}>
<ReportDetailLink to={reportTo} />
@ -373,29 +380,41 @@ export function GameSection({ data }: { data: AdminDashboardData }) {
</Grid>
<Card sx={{ overflow: 'hidden' }}>
<Table size="small">
<TableHead>
<TableRow>
<TableCell>Segment</TableCell>
<TableCell align="right">Utilisateurs</TableCell>
<TableCell align="right">Prédictions</TableCell>
<TableCell align="right">Misé</TableCell>
<TableCell align="right">Net P/L</TableCell>
<TableCell align="right">Taux réussite</TableCell>
</TableRow>
</TableHead>
<TableBody>
<SegmentRow label="Prédictions normales" seg={g.manual} to={reportUrl(REPORT_PATHS.predictionsManual, dateQ)} />
<SegmentRow label="Auto Prediction" seg={g.auto} to={reportUrl(REPORT_PATHS.predictionsAuto, dateQ)} />
<SegmentRow label="Multi-candles" seg={g.multiCandle} to={reportUrl(REPORT_PATHS.predictionsMultiCandle, dateQ)} />
<SegmentRow label="Réel + manuel" seg={g.cross.realManual} to={reportUrl(REPORT_PATHS.predictionsManual, dateQ)} />
<SegmentRow label="Réel + auto" seg={g.cross.realAuto} to={reportUrl(REPORT_PATHS.predictionsAuto, dateQ)} />
<SegmentRow label="Réel + multi-candles" seg={g.cross.realMulti} to={reportUrl(REPORT_PATHS.predictionsMultiCandle, dateQ)} />
<SegmentRow label="Test + manuel" seg={g.cross.testManual} to={reportUrl(REPORT_PATHS.predictionsTest, dateQ)} />
<SegmentRow label="Test + auto" seg={g.cross.testAuto} to={reportUrl(REPORT_PATHS.predictionsTest, dateQ)} />
<SegmentRow label="Test + multi-candles" seg={g.cross.testMulti} to={reportUrl(REPORT_PATHS.predictionsMultiCandle, dateQ)} />
</TableBody>
</Table>
<ScrollableTable minWidth={820}>
<Table size="small">
<TableHead>
<TableRow>
<TableCell sx={{ whiteSpace: 'nowrap' }}>Segment</TableCell>
<TableCell align="right" sx={{ whiteSpace: 'nowrap' }}>
Utilisateurs
</TableCell>
<TableCell align="right" sx={{ whiteSpace: 'nowrap' }}>
Prédictions
</TableCell>
<TableCell align="right" sx={{ whiteSpace: 'nowrap' }}>
Misé
</TableCell>
<TableCell align="right" sx={{ whiteSpace: 'nowrap' }}>
Net P/L
</TableCell>
<TableCell align="right" sx={{ whiteSpace: 'nowrap' }}>
Taux réussite
</TableCell>
</TableRow>
</TableHead>
<TableBody>
<SegmentRow label="Prédictions normales" seg={g.manual} to={reportUrl(REPORT_PATHS.predictionsManual, dateQ)} />
<SegmentRow label="Auto Prediction" seg={g.auto} to={reportUrl(REPORT_PATHS.predictionsAuto, dateQ)} />
<SegmentRow label="Multi-candles" seg={g.multiCandle} to={reportUrl(REPORT_PATHS.predictionsMultiCandle, dateQ)} />
<SegmentRow label="Réel + manuel" seg={g.cross.realManual} to={reportUrl(REPORT_PATHS.predictionsManual, dateQ)} />
<SegmentRow label="Réel + auto" seg={g.cross.realAuto} to={reportUrl(REPORT_PATHS.predictionsAuto, dateQ)} />
<SegmentRow label="Réel + multi-candles" seg={g.cross.realMulti} to={reportUrl(REPORT_PATHS.predictionsMultiCandle, dateQ)} />
<SegmentRow label="Test + manuel" seg={g.cross.testManual} to={reportUrl(REPORT_PATHS.predictionsTest, dateQ)} />
<SegmentRow label="Test + auto" seg={g.cross.testAuto} to={reportUrl(REPORT_PATHS.predictionsTest, dateQ)} />
<SegmentRow label="Test + multi-candles" seg={g.cross.testMulti} to={reportUrl(REPORT_PATHS.predictionsMultiCandle, dateQ)} />
</TableBody>
</Table>
</ScrollableTable>
</Card>
<Grid container spacing={2} sx={{ mt: 2 }}>
@ -598,7 +617,7 @@ export function GeographySection({ data }: { data: AdminDashboardData }) {
</Card>
</Grid>
</Grid>
<FixedTableCard title="Synthèse top 8 pays" reportTo={REPORT_PATHS.geoUsers}>
<FixedTableCard title="Synthèse top 8 pays" reportTo={REPORT_PATHS.geoUsers} tableMinWidth={760}>
<Table size="small">
<TableHead>
<TableRow>
@ -653,7 +672,7 @@ export function DemographicsSection({ data }: { data: AdminDashboardData }) {
</Grid>
<Grid container spacing={2}>
<Grid size={{ xs: 12, md: 6 }}>
<FixedTableCard title="Détail par sexe">
<FixedTableCard title="Détail par sexe" tableMinWidth={680}>
<Table size="small">
<TableHead>
<TableRow>
@ -679,7 +698,7 @@ export function DemographicsSection({ data }: { data: AdminDashboardData }) {
</FixedTableCard>
</Grid>
<Grid size={{ xs: 12, md: 6 }}>
<FixedTableCard title="Détail par tranche d'âge">
<FixedTableCard title="Détail par tranche d'âge" tableMinWidth={680}>
<Table size="small">
<TableHead>
<TableRow>

View File

@ -3,10 +3,12 @@ import type { ReactNode } from 'react';
type Props = {
children: ReactNode;
/** Minimum table width before horizontal scroll appears */
minWidth?: number;
};
/** Horizontal scroll wrapper for wide tables on small screens. */
export function ScrollableTable({ children }: Props) {
export function ScrollableTable({ children, minWidth = 640 }: Props) {
return (
<Box
sx={{
@ -15,6 +17,9 @@ export function ScrollableTable({ children }: Props) {
minWidth: 0,
overflowX: 'auto',
WebkitOverflowScrolling: 'touch',
'& table': {
minWidth,
},
}}
>
{children}