Skip to content

Commit ddbd08b

Browse files
committed
fix: more improvements
1 parent 4c9041a commit ddbd08b

File tree

3 files changed

+45
-18
lines changed

3 files changed

+45
-18
lines changed

example/app/(tabs)/TradeQuoteScreens/get-trade-quotes.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default function GetTradeQuotesScreen() {
3535
latitude: "40.7505",
3636
longitude: "-73.9935",
3737
});
38+
const [serviceAccountID, setServiceAccountID] = useState("");
3839
const candleClient = useCandleClient();
3940
const navigation = useNavigation<any>();
4041

@@ -43,6 +44,7 @@ export default function GetTradeQuotesScreen() {
4344
const accounts = await candleClient.getTradeQuotes({
4445
lost: {
4546
assetKind: "fiat",
47+
serviceAccountID: serviceAccountID,
4648
},
4749
gained: {
4850
originCoordinates: {
@@ -104,6 +106,15 @@ export default function GetTradeQuotesScreen() {
104106
}
105107
/>
106108
</View>
109+
<Text style={{ fontWeight: "600" }}>Service Account ID</Text>
110+
<View style={{ flexDirection: "row", gap: 8 }}>
111+
<TextInput
112+
style={styles.input}
113+
placeholder="Service Account ID"
114+
value={serviceAccountID}
115+
onChangeText={(text) => setServiceAccountID(text)}
116+
/>
117+
</View>
107118
<TouchableOpacity
108119
style={styles.primaryButton}
109120
onPress={() => {

example/app/(tabs)/TradeScreen/get-trades.tsx

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,7 @@ export default function GetTradesScreen() {
4444
const fetchTrades = async (filters: TradeQuery) => {
4545
try {
4646
setIsLoading(true);
47-
const result = await candleClient.getTrades({
48-
linkedAccountIDs: filters.linkedAccountIDs,
49-
dateTimeSpan:
50-
filters.dateTimeSpan === "none" ? undefined : filters.dateTimeSpan,
51-
gainedAssetKind: filters.gainedAssetKind,
52-
lostAssetKind: filters.lostAssetKind,
53-
counterpartyKind: filters.counterpartyKind,
54-
});
47+
const result = await candleClient.getTrades(filters);
5548
setTrades(result);
5649
} catch (error) {
5750
Alert.alert(`Failed to fetch trades: ${error}`);
@@ -86,15 +79,34 @@ export default function GetTradesScreen() {
8679
};
8780
});
8881
}}
89-
actions={FILTER_CONFIG.map((f) => ({
90-
id: f.key,
91-
title: f.title,
92-
subactions: f.options.map((opt) => ({
93-
id: `${f.key}|${opt.value}`,
94-
title: opt.label,
95-
state: filters[f.key] === opt.value ? "on" : "off",
96-
})),
97-
}))}
82+
actions={FILTER_CONFIG.map((f) =>
83+
f.key === "linkedAccountIDs"
84+
? {
85+
id: f.key,
86+
title: f.title,
87+
subactions:
88+
linkedAccounts.map((acc) => ({
89+
id: `linkedAccountIDs|${acc.linkedAccountID}`,
90+
title: acc.service,
91+
state: filters.linkedAccountIDs
92+
? filters.linkedAccountIDs
93+
.split(",")
94+
.includes(acc.linkedAccountID)
95+
? ("on" as const)
96+
: ("off" as const)
97+
: ("off" as const),
98+
})) ?? [],
99+
}
100+
: {
101+
id: f.key,
102+
title: f.title,
103+
subactions: f.options.map((opt) => ({
104+
id: `${f.key}|${opt.value}`,
105+
title: opt.label,
106+
state: filters[f.key] === opt.value ? "on" : "off",
107+
})),
108+
}
109+
)}
98110
shouldOpenOnLongPress={false}
99111
>
100112
<View>

example/app/(tabs)/TradeScreen/models.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const SUPPORTED_SPANS = [
1414
{ id: "P1M", title: "1 Month" },
1515
{ id: "P6M", title: "6 Months" },
1616
{ id: "P1Y", title: "1 Year" },
17-
{ id: "none", title: "No Span" },
1817
] as const;
1918

2019
type SectionItem =
@@ -58,6 +57,11 @@ const FILTER_CONFIG = [
5857
label: k,
5958
})),
6059
},
60+
{
61+
key: "linkedAccountIDs",
62+
title: "Linked Accounts",
63+
options: [],
64+
},
6165
] as const;
6266

6367
const assetDisplayName = (asset: TradeAsset): string => {

0 commit comments

Comments
 (0)