Skip to content
Snippets Groups Projects
Commit 29cae751 authored by Lukas's avatar Lukas
Browse files

Merge branch 'develop' into lbudginas/#428_comment_search_operation_type_search_trigger

parents 30856962 45c74f80
No related branches found
No related tags found
1 merge request!527Lbudginas/#428 comment search operation type search trigger
Pipeline #113978 canceled
import { Search } from "lucide-react";
import React from "react";
interface NoResultProps {
title?: string;
description?: string;
}
const NoResult: React.FC<NoResultProps> = ({
title = "No Results Found",
description = "We could not find anything matching your search. Try refining your filters or starting a new search.",
}) => {
return (
<div className="mt-2 flex flex-col items-center justify-center bg-theme p-6 w-full text-center space-y-3">
<div className="flex items-center justify-center w-12 h-12 bg-explorer-bg-start rounded-full">
<Search className="w-6 h-6" />
</div>
<h2 className="text-xl font-semibold">
{title}
</h2>
<p className="text-sm">{description}</p>
</div>
);
};
export default NoResult;
......@@ -10,15 +10,6 @@ import {
grabNumericValue,
} from "@/utils/StringUtils";
import { cn, formatNumber } from "@/lib/utils";
import Link from "next/link";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faHistory } from "@fortawesome/free-solid-svg-icons";
import {
Tooltip,
TooltipProvider,
TooltipTrigger,
TooltipContent,
} from "@radix-ui/react-tooltip";
type AccountBalanceCardProps = {
header: string;
userDetails: Explorer.FormattedAccountDetails;
......@@ -36,6 +27,7 @@ const cardNameMap = new Map([
["received_vesting_shares", "Received HP"],
["delegated_vesting_shares", "Delegated HP"],
["vesting_withdraw_rate", "Powering down HP"],
]);
const unclaimedRecourses = new Map([
......@@ -96,25 +88,6 @@ const AccountBalanceCard: React.FC<AccountBalanceCardProps> = ({
const [isBalancesHidden, setIsBalancesHidden] = useState(false);
const [totalBalance, setTotalBalance] = useState(0);
useEffect(() => {
const newBalance = keys.reduce((acc, param) => {
if (cardNameMap.has(param) && !skipCalculation.includes(param)) {
const value = grabNumericValue(userDetails.dollars[param]);
if (typeof value === "number" && !isNaN(value)) {
return acc + value;
} else {
console.error("Value is not a number:", value);
return acc;
}
}
return acc;
}, 0);
setTotalBalance(newBalance);
}, [keys, userDetails]);
const renderBalance = () => {
return (
<TableRow className="border-b border-gray-700 hover:bg-inherit font-bold">
......@@ -123,7 +96,7 @@ const AccountBalanceCard: React.FC<AccountBalanceCardProps> = ({
className="text-right"
colSpan={2}
>
{formatNumber(totalBalance, false, true)} $
{changeHBDToDollarsDisplay(userDetails.dollars.account_value)}
</TableCell>
</TableRow>
);
......
......@@ -13,6 +13,7 @@ import { useSearchesContext } from "@/contexts/SearchesContext";
import useAccountOperations from "@/hooks/api/accountPage/useAccountOperations";
import ErrorPage from "@/pages/ErrorPage";
import { getAccountPageLink } from "../utils/accountSearchHelpers";
import NoResult from "@/components/NoResult";
const AccountSearchResults = () => {
const {
......@@ -97,9 +98,7 @@ const AccountSearchResults = () => {
/>
</div>
) : (
<div className="flex justify-center w-full text-black dark:text-white">
No operations matching given criteria
</div>
<NoResult/>
)}
</>
);
......
......@@ -5,6 +5,7 @@ import useBlockSearch from "@/hooks/api/homePage/useBlockSearch";
import useOperationsTypes from "@/hooks/api/common/useOperationsTypes";
import ErrorPage from "@/pages/ErrorPage";
import { getBlockPageLink } from "../utils/blockSearchHelpers";
import NoResult from "@/components/NoResult";
const BlockSearchResults = () => {
const { blockSearchProps } = useSearchesContext();
......@@ -22,25 +23,25 @@ const BlockSearchResults = () => {
if (!blockSearchData) return;
return (
<div className="bg-theme dark:bg-theme p-2 md: h-fit rounded">
<div className="text-center">Results:</div>
<div className="flex flex-wrap">
{blockSearchData.total_blocks > 0 ? (
blockSearchData.blocks_result.map(({ block_num }) => (
<Link
key={block_num}
<>
{blockSearchData.total_blocks > 0 ? (
<div className="bg-theme dark:bg-theme p-2 md: h-fit rounded">
<div className="text-center">Results:</div>
<div className="flex flex-wrap pl-4">
{blockSearchData.blocks_result.map(({ block_num }) => (
<Link
key={block_num}
href={blockPageLink(block_num)}
>
<div className="m-1 border border-solid p-1">{block_num}</div>
</Link>
))
))}
</div>
</div>
) : (
<div className="flex justify-center w-full">
No blocks matching given criteria
</div>
<NoResult/>
)}
</div>
</div>
</>
);
};
......
......@@ -7,6 +7,7 @@ import CustomPagination from "@/components/CustomPagination";
import { config } from "@/Config";
import { useRouter } from "next/router";
import AccountCommentPermlinkResultTable from "@/components/account/tabs/posts/AccountCommentPermlinkResultTable";
import NoResult from "@/components/NoResult";
const CommentPermlinkSearchResults = () => {
const {
......@@ -94,9 +95,7 @@ const CommentPermlinkSearchResults = () => {
</div>
</div>
) : (
<div className="flex justify-center w-full">
No permlinks matching given criteria
</div>
<NoResult/>
)}
</>
);
......
......@@ -14,6 +14,7 @@ import useCommentSearch from "@/hooks/api/common/useCommentSearch";
import { useSearchesContext } from "@/contexts/SearchesContext";
import { getCommentPageLink } from "../utils/commentSearchHelpers";
import { usePathname } from "next/navigation";
import NoResult from "@/components/NoResult";
const CommentSearchResults = () => {
const {
......@@ -91,9 +92,7 @@ const CommentSearchResults = () => {
/>
</div>
) : (
<div className="flex justify-center w-full text-black dark:text-white">
No operations matching given criteria
</div>
<NoResult/>
)}
</>
);
......
......@@ -25,6 +25,7 @@ const useConvertedAccountDetails = (accountName: string, liveDataEnabled: boolea
return formattedHP as string;
}
const { hiveChain } = useHiveChainContext();
const {accountDetails, notFound}= useAccountDetails(accountName, liveDataEnabled);
if (!dynamicGlobalData || !hiveChain || !accountDetails) return {formattedAccountDetails: undefined, notFound: undefined};
......@@ -75,6 +76,7 @@ const useConvertedAccountDetails = (accountName: string, liveDataEnabled: boolea
created: formatAndDelocalizeTime(accountDetails.created),
};
// Prepare HBD for $ display
const dollars = {
hbd_balance: accountDetailsForFormat.hbd_balance,
......@@ -89,8 +91,23 @@ const useConvertedAccountDetails = (accountName: string, liveDataEnabled: boolea
vesting_shares: hiveChain.hiveToHbd(vesting_shares, rawFeedPrice, rawQuote),
vesting_withdraw_rate: hiveChain.hiveToHbd(vesting_withdraw_rate, rawFeedPrice, rawQuote)
}
interface NaiAsset {
amount: string;
nai: string;
precision: number
}
/* Account Value Calculations */
const skipCalculation = ["delegated_vesting_shares", "received_vesting_shares"];
let totalAccountValue = Object.entries(dollars).reduce((sum, [key, value]) => {
if (value && value.hasOwnProperty('amount') && !skipCalculation.includes(key)) {
return sum + Number((value as NaiAsset).amount);
}
return sum;
}, 0);
(dollars as any)["account_value"] = hiveChain.hbd(totalAccountValue);
const formattedAccountDetails = {...hiveChain?.formatter.format({
...accountDetailsForFormat,
......@@ -98,7 +115,7 @@ const useConvertedAccountDetails = (accountName: string, liveDataEnabled: boolea
vests,
has_hbd_reward: !!accountDetails.reward_hbd_balance,
has_vesting_reward: !!Number(accountDetails.reward_vesting_balance),
has_hive_reward: !!accountDetails.reward_hive_balance
has_hive_reward: !!accountDetails.reward_hive_balance,
}),
} as Explorer.FormattedAccountDetails;
delete formattedAccountDetails.last_post;
......
......@@ -244,6 +244,7 @@ declare module Explorer {
curation_rewards: string;
vesting_balance: string;
reward_vesting_hive: string;
account_value : string;
}
interface FormattedAccountDetails
......@@ -297,6 +298,7 @@ declare module Explorer {
created: string;
vests: AccountDetailsVests;
dollars: AccountDetailsDollars;
account_value?: number;
}
interface BalanceHistoryForTable {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment