mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 02:21:35 +00:00
Book coordinator filter (#1087)
* Fix book loading * Fix Robot page * Code Review * Book coordinator filter
This commit is contained in:
parent
c648132163
commit
83410c174e
@ -20,6 +20,8 @@ import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
|
||||
|
||||
import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
|
||||
import SwapCalls from '@mui/icons-material/SwapCalls';
|
||||
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext';
|
||||
import RobotAvatar from '../RobotAvatar';
|
||||
|
||||
interface BookControlProps {
|
||||
width: number;
|
||||
@ -33,6 +35,7 @@ const BookControl = ({
|
||||
setPaymentMethods,
|
||||
}: BookControlProps): JSX.Element => {
|
||||
const { fav, setFav } = useContext<UseAppStoreType>(AppContext);
|
||||
const { federation } = useContext<UseFederationStoreType>(FederationContext);
|
||||
|
||||
const { t, i18n } = useTranslation();
|
||||
const theme = useTheme();
|
||||
@ -52,6 +55,11 @@ const BookControl = ({
|
||||
setFav({ ...fav, currency, mode: currency === 1000 ? 'swap' : 'fiat' });
|
||||
};
|
||||
|
||||
const handleHostChange = function (e: React.ChangeEvent<HTMLInputElement>): void {
|
||||
const coordinator = String(e.target.value);
|
||||
setFav({ ...fav, coordinator });
|
||||
};
|
||||
|
||||
const handleTypeChange = function (mouseEvent: React.MouseEvent, val: number): void {
|
||||
setFav({ ...fav, type: val });
|
||||
};
|
||||
@ -306,6 +314,63 @@ const BookControl = ({
|
||||
</Select>
|
||||
</Grid>
|
||||
) : null}
|
||||
|
||||
{width > large ? (
|
||||
<Grid item sx={{ position: 'relative', top: '0.5em' }}>
|
||||
<Typography variant='caption' color='text.secondary'>
|
||||
{fav.currency === 1000 ? t(fav.type === 0 ? 'to' : 'from') : t('hosted by')}
|
||||
</Typography>
|
||||
</Grid>
|
||||
) : null}
|
||||
<Grid item>
|
||||
<Select
|
||||
autoWidth
|
||||
sx={{
|
||||
height: '2.3em',
|
||||
border: '0.5px solid',
|
||||
backgroundColor: theme.palette.background.paper,
|
||||
borderRadius: '4px',
|
||||
borderColor: 'text.disabled',
|
||||
'&:hover': {
|
||||
borderColor: 'text.primary',
|
||||
},
|
||||
}}
|
||||
size='small'
|
||||
label={t('Select Host')}
|
||||
required={true}
|
||||
value={fav.coordinator}
|
||||
inputProps={{
|
||||
style: { textAlign: 'center' },
|
||||
}}
|
||||
onChange={handleHostChange}
|
||||
>
|
||||
<MenuItem value='any'>
|
||||
<div style={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap' }}>
|
||||
<FlagWithProps code='ANY' />
|
||||
</div>
|
||||
</MenuItem>
|
||||
{Object.values(federation.coordinators).map((coordinator) =>
|
||||
coordinator.enabled ? (
|
||||
<MenuItem
|
||||
key={coordinator.shortAlias}
|
||||
value={coordinator.shortAlias}
|
||||
color='text.secondary'
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap' }}>
|
||||
<RobotAvatar
|
||||
shortAlias={coordinator.shortAlias}
|
||||
style={{ width: '1.428em', height: '1.428em' }}
|
||||
smooth={true}
|
||||
small={true}
|
||||
/>
|
||||
</div>
|
||||
</MenuItem>
|
||||
) : (
|
||||
<></>
|
||||
),
|
||||
)}
|
||||
</Select>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Divider />
|
||||
</Box>
|
||||
|
@ -154,7 +154,7 @@ export const initialAppContext: UseAppStoreType = {
|
||||
clientVersion: getClientVersion(),
|
||||
setAcknowledgedWarning: () => {},
|
||||
acknowledgedWarning: false,
|
||||
fav: { type: null, currency: 0, mode: 'fiat' },
|
||||
fav: { type: null, currency: 0, mode: 'fiat', coordinator: 'any' },
|
||||
setFav: () => {},
|
||||
};
|
||||
|
||||
|
@ -2,6 +2,7 @@ export interface Favorites {
|
||||
type: number | null;
|
||||
mode: 'swap' | 'fiat';
|
||||
currency: number;
|
||||
coordinator: string;
|
||||
}
|
||||
|
||||
export default Favorites;
|
||||
|
@ -27,6 +27,14 @@ const filterByPayment = function (order: PublicOrder, paymentMethods: any[]): bo
|
||||
}
|
||||
};
|
||||
|
||||
const filterByHost = function (order: PublicOrder, shortAlias: string): boolean {
|
||||
if (shortAlias === 'any') {
|
||||
return true;
|
||||
} else {
|
||||
return order.coordinatorShortAlias === shortAlias;
|
||||
}
|
||||
};
|
||||
|
||||
const filterByAmount = function (order: PublicOrder, filter: AmountFilter): boolean {
|
||||
const filterMaxAmount =
|
||||
Number(filter.amount !== '' ? filter.amount : filter.maxAmount) * (1 + filter.threshold);
|
||||
@ -66,13 +74,16 @@ const filterOrders = function ({
|
||||
const paymentMethodChecks =
|
||||
paymentMethods.length > 0 ? filterByPayment(order, paymentMethods) : true;
|
||||
const amountChecks = amountFilter != null ? filterByAmount(order, amountFilter) : true;
|
||||
const hostChecks =
|
||||
baseFilter.coordinator != 'any' ? filterByHost(order, baseFilter.coordinator) : true;
|
||||
return (
|
||||
typeChecks &&
|
||||
modeChecks &&
|
||||
premiumChecks &&
|
||||
currencyChecks &&
|
||||
paymentMethodChecks &&
|
||||
amountChecks
|
||||
amountChecks &&
|
||||
hostChecks
|
||||
);
|
||||
});
|
||||
return filteredOrders;
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "DESTÍ",
|
||||
"I want to": "Vull",
|
||||
"METHOD": "MÈTODE",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "Selecciona moneda de pagament",
|
||||
"Select Payment Method": "Tria mètode de pagament",
|
||||
"Sell": "Vendre",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "Swap In",
|
||||
"Swap Out": "Swap Out",
|
||||
"and use": "i fer servir",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "pagar amb",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "Afegir filtre",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "DESTINATION",
|
||||
"I want to": "Já chci",
|
||||
"METHOD": "METHOD",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "Vybrat měnu platby",
|
||||
"Select Payment Method": "Select Payment Method",
|
||||
"Sell": "Prodej",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "Swap In",
|
||||
"Swap Out": "Swap Out",
|
||||
"and use": "použít",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "pay with",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "Přidat filter",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "DESTINATION",
|
||||
"I want to": "Ich möchte",
|
||||
"METHOD": "METHOD",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "Währung auswählen",
|
||||
"Select Payment Method": "Select Payment Method",
|
||||
"Sell": "Verkaufen",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "Swap In",
|
||||
"Swap Out": "Swap Out",
|
||||
"and use": "und verwende",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "pay with",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "Add filter",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "DESTINATION",
|
||||
"I want to": "I want to",
|
||||
"METHOD": "METHOD",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "Select Payment Currency",
|
||||
"Select Payment Method": "Select Payment Method",
|
||||
"Sell": "Sell",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "Swap In",
|
||||
"Swap Out": "Swap Out",
|
||||
"and use": "and use",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "pay with",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "Add filter",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "DESTINO",
|
||||
"I want to": "Quiero",
|
||||
"METHOD": "MÉTODO",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "Selecciona moneda de pago",
|
||||
"Select Payment Method": "Selecciona método de pago",
|
||||
"Sell": "Vender",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "Swap a LN",
|
||||
"Swap Out": "Swap desde LN",
|
||||
"and use": "y usa",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "paga con",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "Añadir filtro",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "DESTINATION",
|
||||
"I want to": "Nahi dut",
|
||||
"METHOD": "METHOD",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "Aukeratu Ordainketa Txanpona",
|
||||
"Select Payment Method": "Select Payment Method",
|
||||
"Sell": "Saldu",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "Swap In",
|
||||
"Swap Out": "Swap Out",
|
||||
"and use": "eta erabili",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "pay with",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "Gehitu iragazkia",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "DESTINATION",
|
||||
"I want to": "Je veux",
|
||||
"METHOD": "MÉTHODE",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "Sélectionner la devise de paiement",
|
||||
"Select Payment Method": "Sélectionner le mode de paiement",
|
||||
"Sell": "Vendre",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "Échange LN->OC",
|
||||
"Swap Out": "Échange OC->LN",
|
||||
"and use": "et utiliser",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "payer avec",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "Ajouter filtre",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "DESTINAZIONE",
|
||||
"I want to": "Voglio",
|
||||
"METHOD": "METODO",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "Seleziona valuta di pagamento",
|
||||
"Select Payment Method": "Seleziona il metodo di pagamento",
|
||||
"Sell": "Vendere",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "Swap In",
|
||||
"Swap Out": "Swap Out",
|
||||
"and use": "ed usa",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "paga con",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "Aggiungi filtro",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "方向",
|
||||
"I want to": "私はしたいのは:",
|
||||
"METHOD": "方法",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "支払い通貨を選択してください。",
|
||||
"Select Payment Method": "支払い方法を選択してください。",
|
||||
"Sell": "売る",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "スワップイン",
|
||||
"Swap Out": "スワップアウト",
|
||||
"and use": "そして使用するのは",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "支払い方法は:",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "フィルタを追加",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "DESTINATION",
|
||||
"I want to": "chcę",
|
||||
"METHOD": "METHOD",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "Wybierz walutę płatności",
|
||||
"Select Payment Method": "Select Payment Method",
|
||||
"Sell": "Sprzedać",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "Swap In",
|
||||
"Swap Out": "Swap Out",
|
||||
"and use": "i użyć",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "pay with",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "Add filter",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "DESTINATION",
|
||||
"I want to": "Eu quero",
|
||||
"METHOD": "METHOD",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "Selecione a moeda de pagamento",
|
||||
"Select Payment Method": "Select Payment Method",
|
||||
"Sell": "Vender",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "Swap In",
|
||||
"Swap Out": "Swap Out",
|
||||
"and use": "e utilizar",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "pay with",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "Add filter",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "МЕСТО НАЗНАЧЕНИЯ",
|
||||
"I want to": "Я хочу",
|
||||
"METHOD": "МЕТОД",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "Выбрать Валюту",
|
||||
"Select Payment Method": "Выбрать способ оплаты",
|
||||
"Sell": "Продать",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "Своп в",
|
||||
"Swap Out": "Своп из",
|
||||
"and use": "и использовать",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "оплатить",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "Добавить фильтр",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "DESTINATION",
|
||||
"I want to": "Jag vill",
|
||||
"METHOD": "METHOD",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "Välj betalningsvaluta",
|
||||
"Select Payment Method": "Select Payment Method",
|
||||
"Sell": "Sälja",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "Swap In",
|
||||
"Swap Out": "Swap Out",
|
||||
"and use": "och använda",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "pay with",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "Add filter",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "MAELEKEZO",
|
||||
"I want to": "Nataka",
|
||||
"METHOD": "NJIA",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "Chagua Sarafu ya Malipo",
|
||||
"Select Payment Method": "Chagua Njia ya Malipo",
|
||||
"Sell": "Uza",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "Badilisha Ndani",
|
||||
"Swap Out": "Badilisha Nje",
|
||||
"and use": "na tumia",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "lipa kwa",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "Ongeza kichujio",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "DESTINATION",
|
||||
"I want to": "ฉันต้องการ",
|
||||
"METHOD": "METHOD",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "เลือกสกุลเงิน",
|
||||
"Select Payment Method": "Select Payment Method",
|
||||
"Sell": "ขาย",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "Swap In",
|
||||
"Swap Out": "Swap Out",
|
||||
"and use": "และใช้",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "pay with",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "เพิ่มตัวกรอง",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "目的地",
|
||||
"I want to": "我想要",
|
||||
"METHOD": "方式",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "选择支付货币",
|
||||
"Select Payment Method": "选择付款方式",
|
||||
"Sell": "出售",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "换入",
|
||||
"Swap Out": "换出",
|
||||
"and use": "并使用",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "支付",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "加筛选",
|
||||
|
@ -83,6 +83,7 @@
|
||||
"DESTINATION": "目的地",
|
||||
"I want to": "我想要",
|
||||
"METHOD": "方式",
|
||||
"Select Host": "Select Host",
|
||||
"Select Payment Currency": "選擇支付貨幣",
|
||||
"Select Payment Method": "選擇付款方式",
|
||||
"Sell": "出售",
|
||||
@ -90,6 +91,7 @@
|
||||
"Swap In": "換入",
|
||||
"Swap Out": "換出",
|
||||
"and use": "並使用",
|
||||
"hosted by": "hosted by",
|
||||
"pay with": "支付",
|
||||
"#15": "Phrases in components/BookTable/index.tsx",
|
||||
"Add filter": "加篩選",
|
||||
|
Loading…
Reference in New Issue
Block a user