+ function openDetails(transaction: Transaction) {
+ setTransaction(transaction);
+ setModalOpen(true);
+ }
+
+ function getTransactionType(tx: Transaction): "incoming" | "outgoing" {
+ return [tx.type && "sent"].includes(tx.type) ? "outgoing" : "incoming";
+ }
+
+ return (
+
+ {loading ? (
+
+
+
+ ) : !transactions?.length && noResultMsg ? (
+
{noResultMsg}
+ ) : (
+ <>
+
+ {transactions?.map((tx) => {
+ const type = getTransactionType(tx);
+
+ return (
+
openDetails(tx)}
+ >
+
+
+ {type == "outgoing" ? (
+
+ ) : (
+
+ )}
+
-
+
- {tx.publisherLink && tx.title ? (
-
- {tx.title}
-
- ) : (
- tx.title || tx.boostagram?.message || "\u00A0"
- )}
+ {tx.title ||
+ tx.boostagram?.message ||
+ (type == "incoming" ? t("received") : t("sent"))}
-
+
{tx.date}
-
+
-
- {[tx.type && "sent", "sending"].includes(tx.type)
- ? "-"
- : "+"}
+
+ {type == "outgoing" ? "-" : "+"}{" "}
{getFormattedSats(tx.totalAmount)}
+
{!!tx.totalAmountFiat && (
-
+
~{tx.totalAmountFiat}
)}
- {(!!tx.description ||
- [tx.type && "sent", "sending"].includes(tx.type) ||
- (tx.type === "received" && tx.boostagram)) && (
-
-
-
- )}
-
-
- {(tx.description || tx.boostagram) && (
-
- {tx.description &&
{tx.description}
}
- {tx.boostagram && (
-
- -
- {t("transactionsTable.boostagram.sender")}:{" "}
- {tx.boostagram.sender_name}
-
- -
- {t("transactionsTable.boostagram.message")}:{" "}
- {tx.boostagram.message}
-
- -
- {t("transactionsTable.boostagram.app")}:{" "}
- {tx.boostagram.app_name}
-
- -
- {t("transactionsTable.boostagram.podcast")}:{" "}
- {tx.boostagram.podcast}
-
-
- )}
-
- )}
- {(tx.totalFees !== undefined || tx.location) && (
-
- {tx.totalFees !== undefined && (
-
-
- {t("transactionsTable.fee")}
-
-
- {getFormattedSats(tx.totalFees)}
-
- )}
- {tx.location && (
-
-
-
- )}
-
- )}
- {tx.preimage && (
-
-
-
- {t("transactionsTable.preimage")}
-
-
- {tx.preimage}
-
-
- )}
-
-
- >
- )}
-
+
+ );
+ })}
- ))}
-
- >
+ {transaction && (
+
{
+ setModalOpen(false);
+ }}
+ />
+ )}
+ >
+ )}
+
);
}
diff --git a/src/app/hooks/useInvoices.ts b/src/app/hooks/useInvoices.ts
deleted file mode 100644
index a9c2bb3a1f..0000000000
--- a/src/app/hooks/useInvoices.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import dayjs from "dayjs";
-import { useCallback, useState } from "react";
-import toast from "~/app/components/Toast";
-import { useSettings } from "~/app/context/SettingsContext";
-import api from "~/common/lib/api";
-import { Transaction } from "~/types";
-
-export const useInvoices = () => {
- const { settings, getFormattedFiat } = useSettings();
-
- const [isLoadingInvoices, setIsLoadingInvoices] = useState(false);
- const [incomingTransactions, setIncomingTransactions] = useState<
- Transaction[]
- >([]);
-
- const loadInvoices = useCallback(
- async (limit?: number) => {
- setIsLoadingInvoices(true);
- let result;
- try {
- result = await api.getInvoices({ isSettled: true, limit });
- } catch (e) {
- if (e instanceof Error) toast.error(`Error: ${e.message}`);
- setIsLoadingInvoices(false);
- return;
- }
-
- const invoices: Transaction[] = result.invoices.map((invoice) => ({
- ...invoice,
- title: invoice.memo,
- description: invoice.memo,
- date: dayjs(invoice.settleDate).fromNow(),
- }));
-
- for (const invoice of invoices) {
- invoice.totalAmountFiat = settings.showFiat
- ? await getFormattedFiat(invoice.totalAmount)
- : "";
- }
-
- setIncomingTransactions(invoices);
- setIsLoadingInvoices(false);
- },
- [getFormattedFiat, settings.showFiat]
- );
-
- return {
- isLoadingInvoices,
- incomingTransactions,
- loadInvoices,
- };
-};
diff --git a/src/app/hooks/useTransactions.ts b/src/app/hooks/useTransactions.ts
index 7fc62c0fc7..1d1f5cd001 100644
--- a/src/app/hooks/useTransactions.ts
+++ b/src/app/hooks/useTransactions.ts
@@ -1,7 +1,7 @@
+import dayjs from "dayjs";
import { useCallback, useState } from "react";
import toast from "~/app/components/Toast";
import { useSettings } from "~/app/context/SettingsContext";
-import { convertPaymentsToTransactions } from "~/app/utils/payments";
import api from "~/common/lib/api";
import { Transaction } from "~/types";
@@ -11,22 +11,28 @@ export const useTransactions = () => {
const [isLoadingTransactions, setIsLoadingTransactions] = useState(true);
const loadTransactions = useCallback(
- async (accountId: string, limit?: number) => {
+ async (limit?: number) => {
try {
- const { payments } = await api.getPaymentsByAccount({
- accountId,
+ const getTransactionsResponse = await api.getTransactions({
limit,
});
- const _transactions: Transaction[] =
- await convertPaymentsToTransactions(payments);
- for (const transaction of _transactions) {
+ const transactions = getTransactionsResponse.transactions.map(
+ (transaction) => ({
+ ...transaction,
+ title: transaction.memo,
+ date: dayjs(transaction.settleDate).fromNow(),
+ timestamp: transaction.settleDate,
+ })
+ );
+
+ for (const transaction of transactions) {
transaction.totalAmountFiat = settings.showFiat
? await getFormattedFiat(transaction.totalAmount)
: "";
}
- setTransactions(_transactions);
+ setTransactions(transactions);
setIsLoadingTransactions(false);
} catch (e) {
console.error(e);
diff --git a/src/app/router/Options/Options.tsx b/src/app/router/Options/Options.tsx
index af4acba192..2eabac9606 100644
--- a/src/app/router/Options/Options.tsx
+++ b/src/app/router/Options/Options.tsx
@@ -76,16 +76,7 @@ function Options() {
} />
} />
} />
-
- }
- />
- }
- />
-
+
} />
} />
} />
} />
diff --git a/src/app/screens/Accounts/Detail/index.tsx b/src/app/screens/Accounts/Detail/index.tsx
index 54ad2b3a40..f2a5dff3c6 100644
--- a/src/app/screens/Accounts/Detail/index.tsx
+++ b/src/app/screens/Accounts/Detail/index.tsx
@@ -1,4 +1,3 @@
-import { CrossIcon } from "@bitcoin-design/bitcoin-icons-react/filled";
import Button from "@components/Button";
import Container from "@components/Container";
import Loading from "@components/Loading";
@@ -264,50 +263,42 @@ function AccountDetail() {
-
-
- {t("export.title")}
-
-
-
-
{exportLoading && (
-
+
{t("export.waiting")}
)}
{!exportLoading && (
-
-
-
{t("export.scan_qr")}
+
+
{t("export.scan_qr")}
+
-
-
-
- {lndHubData.lnAddress && (
-
-
- {t("export.your_ln_address")}
-
- {lndHubData.lnAddress && (
-
{lndHubData.lnAddress}
- )}
-
- )}
+
+
+
+ {lndHubData.lnAddress && (
+
+
+ {t("export.your_ln_address")}
+
+ {lndHubData.lnAddress && (
+
{lndHubData.lnAddress}
+ )}
+
+ )}
)}
diff --git a/src/app/screens/Home/AllowanceView/index.tsx b/src/app/screens/Home/AllowanceView/index.tsx
index e836e13b15..7f454498ae 100644
--- a/src/app/screens/Home/AllowanceView/index.tsx
+++ b/src/app/screens/Home/AllowanceView/index.tsx
@@ -139,9 +139,6 @@ const AllowanceView: FC
= (props) => {
/>
)}
-
- {t("allowance_view.recent_transactions")}
-
{isLoadingTransactions && (
@@ -152,7 +149,7 @@ const AllowanceView: FC
= (props) => {
{hasTransactions && }
{!isLoadingTransactions && !transactions?.length && (
-
+
= (props) => {
+ const itemsLimit = 8;
+
const { t } = useTranslation("translation", { keyPrefix: "home" });
const { t: tCommon } = useTranslation("common");
- const { t: tComponents } = useTranslation("components");
const navigate = useNavigate();
- const { account, balancesDecorated, accountLoading } = useAccount();
+ const { account, accountLoading } = useAccount();
const lightningAddress = account?.lightningAddress || "";
@@ -48,31 +48,11 @@ const DefaultView: FC = (props) => {
const { transactions, isLoadingTransactions, loadTransactions } =
useTransactions();
- const { isLoadingInvoices, incomingTransactions, loadInvoices } =
- useInvoices();
-
- const isLoadingOutgoing = accountLoading || isLoadingTransactions;
- const isLoadingIncoming = accountLoading || isLoadingInvoices;
-
- const itemsLimit = 8;
+ const isLoading = accountLoading || isLoadingTransactions;
useEffect(() => {
- if (account?.id) loadTransactions(account.id, itemsLimit);
- }, [
- account?.id,
- balancesDecorated?.accountBalance,
- loadTransactions,
- itemsLimit,
- ]);
-
- useEffect(() => {
- loadInvoices(itemsLimit);
- }, [
- account?.id,
- balancesDecorated?.accountBalance,
- loadInvoices,
- itemsLimit,
- ]);
+ loadTransactions(itemsLimit);
+ }, [loadTransactions, itemsLimit]);
// check if currentURL is blocked
useEffect(() => {
@@ -142,7 +122,7 @@ const DefaultView: FC = (props) => {
)}
-
+
}
@@ -180,71 +160,31 @@ const DefaultView: FC
= (props) => {
)}
- {isLoadingTransactions && (
+ {isLoading && (
)}
- {!isLoadingTransactions && (
+ {!isLoading && (
-
- {t("default_view.recent_transactions")}
-
-
-
-
- {[
- tComponents("transaction_list.tabs.outgoing"),
- tComponents("transaction_list.tabs.incoming"),
- ].map((category) => (
-
- ))}
-
-
-
-
- <>
-
- {!isLoadingOutgoing && transactions.length > 0 && (
-
-
- handleViewAllLink("/transactions/outgoing")
- }
- >
- {t("default_view.all_transactions_link")}
-
-
- )}
- >
-
-
- <>
-
- {!isLoadingIncoming && incomingTransactions.length > 0 && (
-
-
- handleViewAllLink("/transactions/incoming")
- }
- >
- {t("default_view.all_transactions_link")}
-
-
- )}
- >
-
-
-
+
+
+ {!isLoading && transactions.length > 0 && (
+
+
handleViewAllLink("/transactions")}
+ className="flex justify-center items-center mt-2"
+ >
+ {t("default_view.see_all")}
+
+
+
+ )}
)}
diff --git a/src/app/screens/Publishers/Detail/index.tsx b/src/app/screens/Publishers/Detail/index.tsx
index 038c6c0639..c0909df09e 100644
--- a/src/app/screens/Publishers/Detail/index.tsx
+++ b/src/app/screens/Publishers/Detail/index.tsx
@@ -64,30 +64,25 @@ function PublisherDetail() {
}, [fetchData, isLoadingSettings]);
return (
-
-
- {allowance && (
-
{
- navigate("/publishers", { replace: true });
- }}
- title={allowance?.name || ""}
- image={allowance?.imageURL || ""}
- url={allowance?.host}
- isCard={false}
- isSmall={false}
- />
- )}
-
+ <>
+ {allowance && (
+
{
+ navigate("/publishers", { replace: true });
+ }}
+ title={allowance?.name || ""}
+ image={allowance?.imageURL || ""}
+ url={allowance?.host}
+ isCard={false}
+ isSmall={false}
+ />
+ )}
{allowance && (
-
-
- {t("allowance_view.recent_transactions")}
-
+
{transactions && transactions?.length > 0 ? (
) : (
@@ -104,7 +99,7 @@ function PublisherDetail() {
)}
-
+ >
);
}
diff --git a/src/app/screens/Settings/index.tsx b/src/app/screens/Settings/index.tsx
index 291ac9eb06..680f5c0242 100644
--- a/src/app/screens/Settings/index.tsx
+++ b/src/app/screens/Settings/index.tsx
@@ -1,4 +1,3 @@
-import { CrossIcon } from "@bitcoin-design/bitcoin-icons-react/outline";
import Button from "@components/Button";
import Container from "@components/Container";
import LocaleSwitcher from "@components/LocaleSwitcher/LocaleSwitcher";
@@ -295,32 +294,22 @@ function Settings() {
-
-
- {t("change_password.title")}
-
-
-
-