Logic fixes

This commit is contained in:
koalasat
2025-07-18 12:11:13 +02:00
parent 3e0d8b22ab
commit 75838dd1fc
21 changed files with 47 additions and 60 deletions

View File

@ -70,7 +70,7 @@ const OrderPage = (): React.JSX.Element => {
return () => {
setCurrentOrder(null);
};
}, [params.orderId, openNoRobot]);
}, [params.orderId, openNoRobot, garage.currentSlot]);
useEffect(() => {
if (!currentOrder) return;

View File

@ -6,13 +6,13 @@ import {
Grid,
LinearProgress,
Typography,
Alert,
Select,
MenuItem,
Box,
useTheme,
type SelectChangeEvent,
IconButton,
Tooltip,
} from '@mui/material';
import { Key, Bolt, Add, DeleteSweep, Download, Settings } from '@mui/icons-material';
import RobotAvatar from '../../components/RobotAvatar';
@ -158,7 +158,8 @@ const RobotProfile = ({
<Grid item sx={{ width: `13.5em` }}>
<RobotAvatar
hashId={slot?.hashId}
smooth={true}
error={!slot?.activeOrder?.id && Boolean(slot?.lastOrder?.id)}
smooth
style={{ maxWidth: '12.5em', maxHeight: '12.5em' }}
placeholderType='generating'
imageStyle={{
@ -168,19 +169,18 @@ const RobotProfile = ({
height: `12.4em`,
width: `12.4em`,
}}
tooltip={t('This is your trading avatar')}
tooltip={
!slot?.activeOrder?.id && Boolean(slot?.lastOrder?.id)
? t(
'Reusing trading identity degrades your privacy against other users, coordinators and observers.',
)
: t('This is your trading avatar')
}
tooltipPosition='top'
/>
{robot?.found && Boolean(slot?.lastOrder?.id) ? (
<Typography align='center' variant='h6'>
{t('Welcome back!')}
</Typography>
) : (
<></>
)}
</Grid>
{federation.loading && !slot?.activeOrder?.id ? (
{federation.loading && !slot?.activeOrder && !slot?.lastOrder ? (
<Grid>
<b>{t('Looking for orders!')}</b>
<LinearProgress />
@ -202,7 +202,7 @@ const RobotProfile = ({
</Grid>
) : null}
{!slot?.activeOrder?.id && Boolean(slot?.lastOrder?.id) ? (
{!slot?.activeOrder && slot?.lastOrder ? (
<Grid item container direction='column' alignItems='center'>
<Grid item>
<Button
@ -216,17 +216,6 @@ const RobotProfile = ({
{t('Last order #{{orderID}}', { orderID: slot?.lastOrder?.id })}
</Button>
</Grid>
<Grid item>
<Alert severity='warning'>
<Grid container direction='column' alignItems='center'>
<Grid item>
{t(
'Reusing trading identity degrades your privacy against other users, coordinators and observers.',
)}
</Grid>
</Grid>
</Alert>
</Grid>
</Grid>
) : null}
@ -234,23 +223,33 @@ const RobotProfile = ({
<Grid item>{t('No existing orders found')}</Grid>
) : null}
<Grid
item
container
direction='row'
justifyContent='stretch'
alignItems='stretch'
sx={{ width: '100%' }}
<Tooltip
placement='top'
enterTouchDelay={0}
hidden={!slot?.lastOrder?.id}
title={t(
'Reusing trading identity degrades your privacy against other users, coordinators and observers.',
)}
>
<TokenInput
fullWidth
inputToken={inputToken}
editable={false}
label={t('Store your token safely')}
setInputToken={setInputToken}
onPressEnter={() => null}
/>
</Grid>
<Grid
item
container
direction='row'
justifyContent='stretch'
alignItems='stretch'
sx={{ width: '100%' }}
>
<TokenInput
error={!slot?.activeOrder?.id && Boolean(slot?.lastOrder?.id)}
fullWidth
inputToken={inputToken}
editable={false}
label={t('Store your token safely')}
setInputToken={setInputToken}
onPressEnter={() => null}
/>
</Grid>
</Tooltip>
</Grid>
<Grid item sx={{ width: '100%' }}>
<Box
@ -265,6 +264,7 @@ const RobotProfile = ({
<Grid item sx={{ width: '100%' }}>
<Typography variant='caption'>{t('Robot Garage')}</Typography>
<Select
error={!slot?.activeOrder?.id && Boolean(slot?.lastOrder?.id)}
fullWidth
required={true}
inputProps={{

View File

@ -18,6 +18,7 @@ interface TokenInputProps {
setInputToken: (state: string) => void;
showCopy?: boolean;
label?: string;
error?: boolean;
}
const TokenInput = ({
@ -32,6 +33,7 @@ const TokenInput = ({
loading = false,
setInputToken,
setValidToken = () => {},
error,
}: TokenInputProps): React.JSX.Element => {
const { t } = useTranslation();
const { garage } = useContext<UseGarageStoreType>(GarageContext);
@ -65,7 +67,7 @@ const TokenInput = ({
} else {
return (
<TextField
error={inputToken.length > 20 ? Boolean(badToken) : false}
error={error || (inputToken.length > 20 ? Boolean(badToken) : false)}
disabled={!editable}
required={true}
label={label ?? ''}

View File

@ -90,14 +90,16 @@ class Slot {
};
updateSlotFromRobot = (robot: Robot | null): void => {
if (robot?.lastOrderId && this.lastOrder?.id !== robot?.lastOrderId) {
if (!robot) return;
if (robot.lastOrderId && this.lastOrder?.id !== robot.lastOrderId) {
this.lastOrder = new Order({ id: robot.lastOrderId, shortAlias: robot.shortAlias });
if (this.activeOrder?.id === robot.lastOrderId) {
this.lastOrder = this.activeOrder;
this.activeOrder = null;
}
}
if (robot?.activeOrderId && this.activeOrder?.id !== robot.activeOrderId) {
if (robot.activeOrderId && this.activeOrder?.id !== robot.activeOrderId) {
this.activeOrder = new Order({
id: robot.activeOrderId,
shortAlias: robot.shortAlias,

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "La reutilització de la identitat de trading degrada la teva privadesa davant d'altres usuaris, coordinadors i observadors.",
"Robot Garage": "Garatge de Robots",
"Store your token safely": "Guarda el teu token de manera segura",
"Welcome back!": "Bentornat!",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "Copiat!",
"Not enough entropy, make it more complex": "Entropia insuficient, fes-ho més complex",

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "Opětovné použití obchodní identity snižuje vaše soukromí vůči ostatním uživatelům, koordinátorům a pozorovatelům.",
"Robot Garage": "Garáž robotů",
"Store your token safely": "Uložte si svůj token bezpečně",
"Welcome back!": "Vítejte zpět!",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "Zkopirováno!",
"Not enough entropy, make it more complex": "Nedostatečná entropie, udělejte ji složitější",

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "Das Wiederverwenden deiner Handelsidentität verringert deine Privatsphäre gegenüber anderen Benutzern, Koordinatoren und Beobachtern.",
"Robot Garage": "Roboter-Garage",
"Store your token safely": "Verwahre dein Token sicher",
"Welcome back!": "Willkommen zurück!",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "Kopiert!",
"Not enough entropy, make it more complex": "Nicht genug Entropie, mach es komplexer",

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "Reusing trading identity degrades your privacy against other users, coordinators and observers.",
"Robot Garage": "Robot Garage",
"Store your token safely": "Store your token safely",
"Welcome back!": "Welcome back!",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "Copied!",
"Not enough entropy, make it more complex": "Not enough entropy, make it more complex",

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "Reusing trading identity degrades your privacy against other users, coordinators and observers.",
"Robot Garage": "Garaje de robots",
"Store your token safely": "Guarda tu token de forma segura",
"Welcome back!": "¡Hola otra vez!",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "¡Copiado!",
"Not enough entropy, make it more complex": "No hay suficiente entropía, hazlo más complejo",

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "Truke nortasuna berriro erabiltzeak pribatutasuna kaltetzen du beste erabiltzaile, koordinatzaile eta behatzaileei dagokienez.",
"Robot Garage": "Robot Garajea",
"Store your token safely": "Gorde zure tokena era seguru batean",
"Welcome back!": "Ongi etorri berriro!",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "Kopiatuta!",
"Not enough entropy, make it more complex": "Ez da nahikoa entropia dago, jar ezazu konplexuago",

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "La réutilisation de l'identité d'échange dégrade votre vie privée par rapport aux autres utilisateurs, coordinateurs et observateurs.",
"Robot Garage": "Garage des robots",
"Store your token safely": "Stockez votre jeton en sécurité",
"Welcome back!": "Bon retour parmi nous !",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "Copié !",
"Not enough entropy, make it more complex": "L'entropie n'est pas suffisante, il faut la rendre plus complexe",

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "Il riutilizzo di identità per gli scambi riduce la privacy rispetto ad altri utenti, coordinatori e osservatori.",
"Robot Garage": "Garage del robot",
"Store your token safely": "Custodisci il tuo token in modo sicuro",
"Welcome back!": "Bentornato!",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "Copiato!",
"Not enough entropy, make it more complex": "Non c'è abbastanza entropia, rendilo più complesso",

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "同一の身元を再利用することは、他のユーザー、管理者、観察者に対してプライバシーを弱める可能性があります。",
"Robot Garage": "ロボットガレージ",
"Store your token safely": "安全にトークンを保存してください。",
"Welcome back!": "またまたこんにちは!",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "コピー完了!",
"Not enough entropy, make it more complex": "十分なエントロピーがありません。より複雑にしてください",

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "Ponowne użycie tożsamości handlowej pogarsza twoją prywatność w stosunku do innych użytkowników, koordynatorów i obserwatorów.",
"Robot Garage": "Garaż robota",
"Store your token safely": "Przechowuj swój token bezpiecznie",
"Welcome back!": "Witamy ponownie!",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "Skopiowane!",
"Not enough entropy, make it more complex": "Za mało entropii, zrób to bardziej złożonym",

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "Reutilizar a identidade de negociação degrada sua privacidade contra outros usuários, coordenadores e observadores.",
"Robot Garage": "Garagem de Robôs",
"Store your token safely": "Guarde seu token de forma segura",
"Welcome back!": "Bem-vindo de volta!",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "Copiado!",
"Not enough entropy, make it more complex": "Entropia insuficiente, torne-a mais complexa",

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "Повторное использование торговых данных ухудшает вашу конфиденциальность по отношению к другим пользователям, координаторам и наблюдателям.",
"Robot Garage": "Гараж роботов",
"Store your token safely": "Храните Ваш токен в безопасности",
"Welcome back!": "С возвращением!",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "Скопировано!",
"Not enough entropy, make it more complex": "Недостаточно энтропии, усложните",

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "Återanvändning av handelsidentitet försämrar din integritet gentemot andra användare, samordnare och observatörer.",
"Robot Garage": "Robotgarage",
"Store your token safely": "Förvara din token säkert",
"Welcome back!": "Välkommen tillbaka!",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "Kopierat!",
"Not enough entropy, make it more complex": "Inte tillräckligt med entropi, gör det mer komplext",

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "Kutumia tena utambulisho wa biashara hupunguza faragha yako dhidi ya watumiaji wengine, waongozaji na waangalizi.",
"Robot Garage": "Ghala la Roboti",
"Store your token safely": "Hifadhi alama yako kwa usalama",
"Welcome back!": "Karibu tena!",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "Imekopiwa!",
"Not enough entropy, make it more complex": "Utaratibu haifai, ifanye kuwa ngumu zaidi",

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "การใช้ตัวตนการซื้อขายซ้ำจะลดความเป็นส่วนตัวของคุณต่อผู้ใช้คนอื่น ผู้ประสานงานและผู้สังเกตการณ์",
"Robot Garage": "โรงรถหุ่นยนต์",
"Store your token safely": "รักษาโทเค็นของคุณให้ปลอดภัย",
"Welcome back!": "ยินดีต้อนรับกลับ!",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "คัดลอกแล้ว!",
"Not enough entropy, make it more complex": "ความซับซ้อนไม่เพียงพอ ทำให้ซับซ้อนมากขึ้น",

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "重复使用交易身份会降低您相对其他用户、协调员和观察者的隐私。",
"Robot Garage": "机器人车库",
"Store your token safely": "安全地存储您的令牌",
"Welcome back!": "欢迎回来!",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "已复制!",
"Not enough entropy, make it more complex": "熵不够,使其更复杂",

View File

@ -60,7 +60,6 @@
"Reusing trading identity degrades your privacy against other users, coordinators and observers.": "重複使用交易身份會降低你的對其他用戶、協調器和觀察者的隱私。",
"Robot Garage": "機器人倉庫",
"Store your token safely": "請安全地存儲你的領牌",
"Welcome back!": "歡迎回來!",
"#10": "Phrases in basic/RobotPage/TokenInput.tsx",
"Copied!": "已複製!",
"Not enough entropy, make it more complex": "熵不夠,請使其更為複雜",