Skip to content

Commit

Permalink
Remove order icon for player address info
Browse files Browse the repository at this point in the history
  • Loading branch information
cwastche committed Sep 23, 2024
1 parent 87c0098 commit e311567
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 35 deletions.
17 changes: 5 additions & 12 deletions client/src/ui/components/hyperstructures/CoOwners.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ import { LeaderboardManager } from "@/dojo/modelManager/LeaderboardManager";
import { useDojo } from "@/hooks/context/DojoContext";
import { useRealm } from "@/hooks/helpers/useRealm";
import { getStructureByEntityId } from "@/hooks/helpers/useStructures";
import useUIStore from "@/hooks/store/useUIStore";
import { AddressSelect } from "@/ui/elements/AddressSelect";
import Button from "@/ui/elements/Button";

import useUIStore from "@/hooks/store/useUIStore";
import { NumberInput } from "@/ui/elements/NumberInput";
import { OrderIcon } from "@/ui/elements/OrderIcon";
import { SortButton, SortInterface } from "@/ui/elements/SortButton";
import { SortPanel } from "@/ui/elements/SortPanel";
import { displayAddress, formatTime, getEntityIdFromKeys } from "@/ui/utils/utils";
import { ContractAddress, getOrderName, HYPERSTRUCTURE_CONFIG_ID, ID } from "@bibliothecadao/eternum";
import { ContractAddress, HYPERSTRUCTURE_CONFIG_ID, ID } from "@bibliothecadao/eternum";
import { useComponentValue } from "@dojoengine/react";
import { getComponentValue } from "@dojoengine/recs";
import { Plus } from "lucide-react";
Expand Down Expand Up @@ -90,12 +88,11 @@ const CoOwnersRows = ({

const structure = getStructureByEntityId(hyperstructureEntityId);

const { getAddressName, getAddressOrder } = useRealm();
const { getAddressName } = useRealm();

const sortingParams = useMemo(() => {
return [
{ label: "Name", sortKey: "name", className: "" },
{ label: "Order", sortKey: "order", className: "" },
{ label: "Address", sortKey: "address", className: "" },
{ label: "Percentage", sortKey: "percentage", className: "flex justify-end" },
];
Expand All @@ -108,7 +105,7 @@ const CoOwnersRows = ({

return (
<>
<SortPanel className="px-3 py-2 grid grid-cols-4">
<SortPanel className="px-3 py-2 grid grid-cols-3">
{sortingParams.map(({ label, sortKey, className }) => (
<SortButton
className={className}
Expand All @@ -131,15 +128,11 @@ const CoOwnersRows = ({

const isOwner = coOwner.address === ContractAddress(account.address);

const order = getAddressOrder(coOwner.address) || 0;
const orderName = getOrderName(order);

return (
<div key={index} className={`flex mt-1 ${isOwner ? "bg-green/20" : ""} text-xxs text-gold`}>
<div className={`flex relative group items-center text-xs px-2 p-1 w-full`}>
<div className="flex w-full grid grid-cols-4">
<div className="flex w-full grid grid-cols-3">
<div className="text-sm font-bold">{playerName}</div>
<OrderIcon containerClassName="" order={orderName} size="xs" />
<div className=" text-sm font-bold">{displayAddress(coOwner.address.toString(16))}</div>
<div className="text-right">{coOwner.percentage / 100}%</div>
</div>
Expand Down
11 changes: 3 additions & 8 deletions client/src/ui/components/hyperstructures/Leaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const Leaderboard = ({
} = useDojo();

const nextBlockTimestamp = useUIStore((state) => state.nextBlockTimestamp);
const { getAddressName, getAddressOrder } = useRealm();
const { getAddressName } = useRealm();

const playerPointsLeaderboard = useMemo(() => {
return LeaderboardManager.instance().getPlayersByRank(nextBlockTimestamp || 0, hyperstructureEntityId);
Expand All @@ -44,7 +44,6 @@ export const Leaderboard = ({
const sortingParams = useMemo(() => {
return [
{ label: "Name", sortKey: "name", className: "" },
{ label: "Order", sortKey: "order", className: "" },
{ label: "Address", sortKey: "address", className: "" },
{ label: "Points", sortKey: "points", className: "flex justify-end" },
];
Expand All @@ -63,7 +62,7 @@ export const Leaderboard = ({

return update ? (
<>
<SortPanel className="px-3 py-2 grid grid-cols-4">
<SortPanel className="px-3 py-2 grid grid-cols-3">
{sortingParams.map(({ label, sortKey, className }) => (
<SortButton
className={className}
Expand All @@ -85,15 +84,11 @@ export const Leaderboard = ({

const isOwner = address === ContractAddress(account.address);

const order = getAddressOrder(address) || 0;
const orderName = getOrderName(order);

return (
<div key={index} className={`flex mt-1 ${isOwner ? "bg-green/20" : ""} text-xxs text-gold`}>
<div className={`flex relative group items-center text-xs px-2 p-1 w-full`}>
<div className="flex w-full grid grid-cols-4">
<div className="flex w-full grid grid-cols-3">
<div className="text-sm font-bold">{playerName}</div>
<OrderIcon containerClassName="" order={orderName} size="xs" />
<div className=" text-sm font-bold">{displayAddress(address.toString(16))}</div>
<div className="text-right">{currencyIntlFormat(points)}</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import { LeaderboardManager } from "@/dojo/modelManager/LeaderboardManager";
import { useDojo } from "@/hooks/context/DojoContext";
import { useRealm } from "@/hooks/helpers/useRealm";
import useUIStore from "@/hooks/store/useUIStore";
import { ContractAddress, getOrderName } from "@bibliothecadao/eternum";
import { ContractAddress } from "@bibliothecadao/eternum";
import { useMemo, useState } from "react";
import { PlayerPointsLeaderboardInterface } from "../../../../hooks/store/useLeaderBoardStore";
import { OrderIcon } from "../../../elements/OrderIcon";
import { SortButton, SortInterface } from "../../../elements/SortButton";
import { SortPanel } from "../../../elements/SortPanel";
import { currencyIntlFormat, displayAddress, sortItems } from "../../../utils/utils";
import { ReactComponent as Cross } from "@/assets/icons/common/cross.svg";

type PlayerPointsLeaderboardKeys = keyof PlayerPointsLeaderboardInterface;

Expand All @@ -24,7 +22,7 @@ export const PlayersLeaderboard = () => {
account: { account },
} = useDojo();

const { getAddressName, getAddressOrder } = useRealm();
const { getAddressName } = useRealm();

const [activeSort, setActiveSort] = useState<SortInterface>({
sortKey: "number",
Expand All @@ -38,8 +36,7 @@ export const PlayersLeaderboard = () => {
const sortingParams: SortingParamPlayerPointsLeaderboard[] = useMemo(() => {
return [
{ label: "Rank", sortKey: "rank", className: "col-span-1" },
{ label: "Name", sortKey: "addressName", className: "col-span-1" },
{ label: "Order", sortKey: "order", className: "col-span-1" },
{ label: "Name", sortKey: "addressName", className: "col-span-2" },
{ label: "Address", sortKey: "address", className: "col-span-2" },
{ label: "Points", sortKey: "totalPoints", className: "col-span-1" },
];
Expand Down Expand Up @@ -70,21 +67,13 @@ export const PlayersLeaderboard = () => {

const isOwner = address === ContractAddress(account.address);

const order = getAddressOrder(address) || 0;
const orderName = getOrderName(order);

return (
<div
key={index}
className={`grid grid-cols-6 gap-4 p-1 ${isOwner ? "bg-green/20" : ""} text-xxs text-gold`}
>
<div className="col-span-1 ">{`#${index + 1}`}</div>
<div className="col-span-1">{playerName}</div>
{order ? (
<OrderIcon className="col-span-1" order={orderName} size="xs" />
) : (
<Cross className="w-4 h-4 flex justify-center paper" />
)}
<div className="col-span-2">{playerName}</div>
<div className="col-span-2">{displayAddress(address.toString(16))}</div>
<div className="col-span-1"> {currencyIntlFormat(points)}</div>
</div>
Expand Down

0 comments on commit e311567

Please sign in to comment.