Skip to content

Commit

Permalink
fix(settings): show correct order state (#1347)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwltr authored Oct 18, 2023
1 parent 76e08b0 commit 655974b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
32 changes: 12 additions & 20 deletions src/utils/blocktank/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ export const getCJitEntry = async (entryId: string): Promise<ICJitEntry> => {
*/
export const getOrder = async (orderId: string): Promise<Result<IBtOrder>> => {
try {
const orderState = await bt.getOrder(orderId);
return ok(orderState);
const order = await bt.getOrder(orderId);
return ok(order);
} catch (e) {
return err(e);
}
Expand Down Expand Up @@ -317,52 +317,44 @@ export const getStateMessage = (order: IBtOrder): string => {
const channelState: BtOpenChannelState | undefined = order.channel?.state;

switch (orderState) {
case 'expired':
case BtOrderState.EXPIRED:
return i18n.t('lightning:order_state.expired');
}

switch (paymentState) {
case 'refunded':
case BtPaymentState.REFUNDED:
return i18n.t('lightning:order_state.refunded');
}

if (channelState) {
switch (channelState) {
case 'opening':
case BtOpenChannelState.OPENING:
return i18n.t('lightning:order_state.opening');
case 'open':
case BtOpenChannelState.OPEN:
return i18n.t('lightning:order_state.open');
case 'closed':
case BtOpenChannelState.CLOSED:
return i18n.t('lightning:order_state.closed');
}
}

switch (orderState) {
case 'closed':
case BtOrderState.CLOSED:
return i18n.t('lightning:order_state.closed');
case 'open':
case BtOrderState.OPEN:
return i18n.t('lightning:order_state.open');
case 'created':
return i18n.t('lightning:order_state.awaiting_payment');
}

switch (paymentState) {
case 'created':
case BtPaymentState.CREATED:
return i18n.t('lightning:order_state.awaiting_payment');
case 'paid':
case BtPaymentState.PAID:
return i18n.t('lightning:order_state.paid');
}

switch (orderState) {
case 'closed':
return i18n.t('lightning:order_state.closed');
case 'open':
return i18n.t('lightning:order_state.open');
case 'created':
case BtOrderState.CREATED:
return i18n.t('lightning:order_state.awaiting_payment');
}

return 'Unknown state';
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/utils/i18n/locales/en/wallet.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"other": "Other"
},
"details_savings_title": "Savings Balance",
"details_savings_subtitle": "On-chain BTC",
"details_savings_subtitle": "BTC",
"details_spending_title": "Spending Balance",
"details_spending_subtitle": "Instant BTC",
"tx_invalid": "Transaction Invalid",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/i18n/locales/ru/wallet.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"other": "Другие"
},
"details_savings_title": "Баланс Сбережений",
"details_savings_subtitle": "On-chain BTC",
"details_savings_subtitle": "BTC",
"details_spending_title": "Баланс Расходов",
"details_spending_subtitle": "Мгновенные BTC",
"tx_invalid": "Неверная Транзакция",
Expand Down

0 comments on commit 655974b

Please sign in to comment.