Filter by robosats orders

This commit is contained in:
koalasat 2024-11-13 17:20:57 +01:00
parent 04670cd671
commit 4e8017b9c3
No known key found for this signature in database
GPG Key ID: 2F7F61C6146AB157
3 changed files with 18 additions and 5 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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 &&