mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-13 10:56:24 +00:00
Filter by robosats orders
This commit is contained in:
parent
04670cd671
commit
4e8017b9c3
@ -5,7 +5,7 @@
|
|||||||
/* Colors */
|
/* Colors */
|
||||||
$background-color: #ffffff !default;
|
$background-color: #ffffff !default;
|
||||||
$text-color: #2c2c2c !default;
|
$text-color: #2c2c2c !default;
|
||||||
$muted-text-color: #393e46 !default;
|
$muted-text-color: hsl(217, 10%, 25%) !default;
|
||||||
$primary-color: #1976d2 !default;
|
$primary-color: #1976d2 !default;
|
||||||
$primary-light-color: #42a5f5 !default;
|
$primary-light-color: #42a5f5 !default;
|
||||||
$primary-dark-color: #1565c0 !default;
|
$primary-dark-color: #1565c0 !default;
|
||||||
|
@ -22,6 +22,8 @@ import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
|
|||||||
import SwapCalls from '@mui/icons-material/SwapCalls';
|
import SwapCalls from '@mui/icons-material/SwapCalls';
|
||||||
import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
|
import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
|
||||||
import RobotAvatar from '../RobotAvatar';
|
import RobotAvatar from '../RobotAvatar';
|
||||||
|
import RoboSats from '../Icons/RoboSats';
|
||||||
|
import RoboSatsNoText from '../Icons/RoboSatsNoText';
|
||||||
|
|
||||||
interface BookControlProps {
|
interface BookControlProps {
|
||||||
width: number;
|
width: number;
|
||||||
@ -350,6 +352,11 @@ const BookControl = ({
|
|||||||
<FlagWithProps code='ANY' />
|
<FlagWithProps code='ANY' />
|
||||||
</div>
|
</div>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
<MenuItem value='robosats'>
|
||||||
|
<div style={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap' }}>
|
||||||
|
<RoboSatsNoText sx={{ color: '#1976d2' }} />
|
||||||
|
</div>
|
||||||
|
</MenuItem>
|
||||||
{federation
|
{federation
|
||||||
.getCoordinators()
|
.getCoordinators()
|
||||||
.filter((coord) => coord.enabled)
|
.filter((coord) => coord.enabled)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { type PublicOrder, type Favorites, type Federation } from '../models';
|
import { type PublicOrder, type Favorites, type Federation, Coordinator } from '../models';
|
||||||
import thirdParties from '../../static/thirdparties.json';
|
import thirdParties from '../../static/thirdparties.json';
|
||||||
|
|
||||||
interface AmountFilter {
|
interface AmountFilter {
|
||||||
@ -28,9 +28,16 @@ const filterByPayment = function (order: PublicOrder, paymentMethods: any[]): bo
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const filterByHost = function (order: PublicOrder, shortAlias: string): boolean {
|
const filterByHost = function (
|
||||||
|
order: PublicOrder,
|
||||||
|
shortAlias: string,
|
||||||
|
federation: Federation,
|
||||||
|
): boolean {
|
||||||
if (shortAlias === 'any') {
|
if (shortAlias === 'any') {
|
||||||
return true;
|
return true;
|
||||||
|
} else if (shortAlias == 'robosats') {
|
||||||
|
const coordinator = federation.getCoordinator(order.coordinatorShortAlias ?? '');
|
||||||
|
return coordinator?.federated ?? false;
|
||||||
} else {
|
} else {
|
||||||
return order.coordinatorShortAlias === shortAlias;
|
return order.coordinatorShortAlias === shortAlias;
|
||||||
}
|
}
|
||||||
@ -84,8 +91,7 @@ const filterOrders = function ({
|
|||||||
const paymentMethodChecks =
|
const paymentMethodChecks =
|
||||||
paymentMethods.length > 0 ? filterByPayment(order, paymentMethods) : true;
|
paymentMethods.length > 0 ? filterByPayment(order, paymentMethods) : true;
|
||||||
const amountChecks = amountFilter !== null ? filterByAmount(order, amountFilter) : true;
|
const amountChecks = amountFilter !== null ? filterByAmount(order, amountFilter) : true;
|
||||||
const hostChecks =
|
const hostChecks = filterByHost(order, baseFilter.coordinator, federation);
|
||||||
baseFilter.coordinator !== 'any' ? filterByHost(order, baseFilter.coordinator) : true;
|
|
||||||
return (
|
return (
|
||||||
coordinatorCheck &&
|
coordinatorCheck &&
|
||||||
typeChecks &&
|
typeChecks &&
|
||||||
|
Loading…
Reference in New Issue
Block a user