From b3b29b95cb417e159ad87335d68e56ba0fa2b065 Mon Sep 17 00:00:00 2001 From: koalasat Date: Thu, 10 Jul 2025 22:40:44 +0200 Subject: [PATCH] Better information when sclosing trade --- frontend/src/basic/OrderPage/index.tsx | 14 ++++--- .../src/basic/SettingsPage/Coordinators.tsx | 12 +++--- .../TradeBox/Dialogs/ConfirmFiatReceived.tsx | 39 ++++++++++++++++--- .../TradeBox/Dialogs/ConfirmFiatSent.tsx | 19 ++++++--- .../src/components/TradeBox/Prompts/Chat.tsx | 26 +++++-------- frontend/static/locales/ca.json | 13 +++++-- frontend/static/locales/cs.json | 13 +++++-- frontend/static/locales/de.json | 13 +++++-- frontend/static/locales/en.json | 13 +++++-- frontend/static/locales/es.json | 13 +++++-- frontend/static/locales/eu.json | 13 +++++-- frontend/static/locales/fr.json | 13 +++++-- frontend/static/locales/it.json | 13 +++++-- frontend/static/locales/ja.json | 13 +++++-- frontend/static/locales/pl.json | 13 +++++-- frontend/static/locales/pt.json | 13 +++++-- frontend/static/locales/ru.json | 13 +++++-- frontend/static/locales/sv.json | 13 +++++-- frontend/static/locales/sw.json | 13 +++++-- frontend/static/locales/th.json | 13 +++++-- frontend/static/locales/zh-SI.json | 13 +++++-- frontend/static/locales/zh-TR.json | 13 +++++-- 22 files changed, 223 insertions(+), 108 deletions(-) diff --git a/frontend/src/basic/OrderPage/index.tsx b/frontend/src/basic/OrderPage/index.tsx index b789ef80..122ce0c9 100644 --- a/frontend/src/basic/OrderPage/index.tsx +++ b/frontend/src/basic/OrderPage/index.tsx @@ -73,11 +73,11 @@ const OrderPage = (): React.JSX.Element => { if ([1].includes(currentOrder.status)) { setOrderStep(1); } else if ([6, 7, 8].includes(currentOrder.status)) { - setOrderStep(2); - } else if ([9, 10, 11, 12, 13].includes(currentOrder.status)) { - setOrderStep(3); - } else if ([14, 15, 16, 17, 18].includes(currentOrder.status)) { - setOrderStep(4); + setOrderStep(currentOrder.is_taker ? 1 : 2); + } else if ([9, 10, 11, 12].includes(currentOrder.status)) { + setOrderStep(currentOrder.is_taker ? 2 : 3); + } else if ([13, 14, 15, 16, 17, 18].includes(currentOrder.status)) { + setOrderStep(5); } }, [currentOrder?.status]); @@ -120,7 +120,9 @@ const OrderPage = (): React.JSX.Element => { <> ); - const steps = ['Publish', 'Wait', 'Setup', 'Trade', 'Finished']; + const steps = currentOrder?.is_taker + ? ['Take', 'Setup', 'Trade', 'Finished'] + : ['Publish', 'Wait', 'Setup', 'Trade', 'Finished']; return ( diff --git a/frontend/src/basic/SettingsPage/Coordinators.tsx b/frontend/src/basic/SettingsPage/Coordinators.tsx index cedae62e..40cc9142 100644 --- a/frontend/src/basic/SettingsPage/Coordinators.tsx +++ b/frontend/src/basic/SettingsPage/Coordinators.tsx @@ -17,7 +17,7 @@ const Coordinators = (): React.JSX.Element => { const [error, setError] = useState(); const [open, setOpen] = useState(false); // Regular expression to match a valid .onion URL - const onionUrlPattern = /^((http|https):\/\/)?[a-zA-Z2-7]{16,56}\.onion$\/?/; + const onionUrlPattern = /^((http|https):\/\/)?([a-zA-Z2-7]{16,56}\.onion)(\/.*)?$/; const addNewCoordinator: (alias: string, url: string) => void = (alias, url) => { if (!federation.getCoordinator(alias)) { @@ -47,11 +47,11 @@ const Coordinators = (): React.JSX.Element => { if (federation.getCoordinator(newAlias)) { setError(t('Alias already exists')); } else { - if (onionUrlPattern.test(newUrl)) { - let fullNewUrl = newUrl; - if (!/^((http|https):\/\/)/.test(fullNewUrl)) { - fullNewUrl = `http://${newUrl}`; - } + const match = newUrl.match(onionUrlPattern); + console.log(match); + if (match) { + const onionUrl = match[3]; + const fullNewUrl = `http://${onionUrl}`; addNewCoordinator(newAlias, fullNewUrl); garage.syncCoordinator(federation, newAlias); setNewAlias(''); diff --git a/frontend/src/components/TradeBox/Dialogs/ConfirmFiatReceived.tsx b/frontend/src/components/TradeBox/Dialogs/ConfirmFiatReceived.tsx index dceeff70..b88dce83 100644 --- a/frontend/src/components/TradeBox/Dialogs/ConfirmFiatReceived.tsx +++ b/frontend/src/components/TradeBox/Dialogs/ConfirmFiatReceived.tsx @@ -7,6 +7,8 @@ import { DialogContent, DialogContentText, Button, + Typography, + Box, } from '@mui/material'; import { type Order } from '../../../models'; import currencies from '../../../../static/assets/currencies.json'; @@ -37,14 +39,39 @@ export const ConfirmFiatReceivedDialog = ({ return ( - {t('Confirm you received {{amount}} {{currencyCode}}?', { currencyCode, amount })} + {t('✅ Confirm you received {{amount}} {{currencyCode}}?', { currencyCode, amount })} - - {t( - 'Confirming that you received {{amount}} {{currencyCode}} will finalize the trade. The satoshis in the escrow will be released to the buyer. Only confirm after {{amount}} {{currencyCode}} have arrived to your account. Note that if you have received the payment and do not click confirm, you risk losing your bond.', - { currencyCode, amount }, - )} + + + {t('Confirming will finalize the trade.', { currencyCode, amount })} + + + + {t('⚠️ This action cannot be undone!')} + + + + {t('The satoshis in the escrow will be released to the buyer:')} + + + + {t('Only confirm after {{amount}} {{currencyCode}} have arrived to your account.', { + currencyCode, + amount, + })} + + + {t( + 'If you have received the payment and do not click confirm, you risk losing your bond.', + )} + + + {t( + 'Some fiat payment methods might reverse their transactions up to 2 weeks after they are completed. Please keep this token and your order data in case you need to use them as proof.', + )} + + diff --git a/frontend/src/components/TradeBox/Dialogs/ConfirmFiatSent.tsx b/frontend/src/components/TradeBox/Dialogs/ConfirmFiatSent.tsx index ffa0a452..82f1396c 100644 --- a/frontend/src/components/TradeBox/Dialogs/ConfirmFiatSent.tsx +++ b/frontend/src/components/TradeBox/Dialogs/ConfirmFiatSent.tsx @@ -5,8 +5,8 @@ import { DialogTitle, DialogActions, DialogContent, - DialogContentText, Button, + Typography, } from '@mui/material'; import { type Order } from '../../../models'; import currencies from '../../../../static/assets/currencies.json'; @@ -37,15 +37,22 @@ export const ConfirmFiatSentDialog = ({ return ( - {t('Confirm you sent {{amount}} {{currencyCode}}?', { currencyCode, amount })} + {t('✅ Confirm you sent {{amount}} {{currencyCode}}?', { currencyCode, amount })} - + + {t('Confirming will allow your peer to finalize the trade.', { currencyCode, amount })} + + + + {t('⚠️ This action cannot be undone!')} + + + {t( - 'Confirming that you sent {{amount}} {{currencyCode}} will allow your peer to finalize the trade. If you have not yet sent it and you still proceed to falsely confirm, you risk losing your bond.', - { currencyCode, amount }, + 'If you have not yet sent it and you still proceed to falsely confirm, you risk losing your bond.', )} - +