Skip to content

Commit

Permalink
Show society member check info, #1034
Browse files Browse the repository at this point in the history
  • Loading branch information
hyifeng committed Sep 4, 2024
1 parent 56f06af commit ef1a6a8
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 60 deletions.
11 changes: 7 additions & 4 deletions next/components/listInfo/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Flex, FlexBetween } from "@osn/common-ui";
import uniq from "lodash.uniq";
import { getSpaceAssets } from "frontedUtils/getSpaceAssets";
import AssetList from "../assetList";
import { isOnePersonOnVoteOnly } from "frontedUtils/strategy";

const Wrapper = styled.div``;

Expand Down Expand Up @@ -116,10 +117,12 @@ export default function Details({ space }) {
</div>
</DetailsItem>

<DetailsItem>
<DetailsLabel>Assets({assets.length})</DetailsLabel>
<AssetList assets={assets} />
</DetailsItem>
{!isOnePersonOnVoteOnly(space?.weightStrategy) && (
<DetailsItem>
<DetailsLabel>Assets({assets.length})</DetailsLabel>
<AssetList assets={assets} />
</DetailsItem>
)}
</DetailSections>
</Wrapper>
);
Expand Down
19 changes: 11 additions & 8 deletions next/components/postDetail/postInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Panel from "@/components/postDetail/panel";
import SideSectionTitle from "@/components/sideBar/sideSectionTitle";
import AssetList from "../assetList";
import { getSpaceAssets } from "frontedUtils/getSpaceAssets";
import { isOnePersonOnVoteOnly } from "frontedUtils/strategy";

const Wrapper = styled(Panel)`
> :not(:first-child) {
Expand Down Expand Up @@ -115,14 +116,16 @@ export default function PostInfo({ data, space }) {
)}
</div>
</div>
<div>
<SideSectionTitle
title={`Assets(${assets.length})`}
img="/imgs/icons/asset.svg"
/>
<Divider />
<AssetList assets={assets} />
</div>
{!isOnePersonOnVoteOnly(space?.weightStrategy) && (
<div>
<SideSectionTitle
title={`Assets(${assets.length})`}
img="/imgs/icons/asset.svg"
/>
<Divider />
<AssetList assets={assets} />
</div>
)}
<div>
<SideSectionTitle title="Timestamp" img="/imgs/icons/timeline.svg" />
<Divider />
Expand Down
15 changes: 9 additions & 6 deletions next/components/postDetail/postResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { VoteItem } from "./strategyResult/common/styled";
import QuorumBalanceOfResult from "./strategyResult/quorumBalanceOfResult";
import QuorumQuadraticBalanceOfResult from "./strategyResult/quorumQuadraticBalanceOfResult";
import OnePersonOneVoteResult from "./strategyResult/onePersonOneVoteResult";
import { isOnePersonOnVoteOnly } from "frontedUtils/strategy";

export default function PostResult({ data, voteStatus, space }) {
const votedAmount = data?.votedWeights?.balanceOf || 0;
Expand Down Expand Up @@ -81,12 +82,14 @@ export default function PostResult({ data, voteStatus, space }) {
<SideSectionTitle title="Results" img="/imgs/icons/strategy.svg" />
<Divider />
<div>
<VoteItem>
<div>Voted</div>
<div>
<ValueDisplay value={votedAmount?.toString()} space={space} />
</div>
</VoteItem>
{!isOnePersonOnVoteOnly(data?.weightStrategy) && (
<VoteItem>
<div>Voted</div>
<div>
<ValueDisplay value={votedAmount?.toString()} space={space} />
</div>
</VoteItem>
)}
<VoteItem>
<div>Voters</div>
<div>{data?.votesCount}</div>
Expand Down
70 changes: 38 additions & 32 deletions next/components/postDetail/postVote.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import { useTerminate } from "./terminate";
import { Tooltip } from "@osn/common-ui";
import VoteBalanceDetail from "./VoteBalanceDetail";
import DelegationInfo from "./delegationInfo";
import { isOnePersonOnVoteOnly } from "frontedUtils/strategy";
import SocietyMemberHit from "../postCreate/societyMemberHit";

const Wrapper = styled.div`
> :not(:first-child) {
Expand Down Expand Up @@ -258,39 +260,43 @@ export default function PostVote({ proposal }) {
if (!proposalClosed) {
let balanceInfo = null;

if (voteDelegation) {
balanceInfo = (
<DelegationInfo
delegatee={voteDelegation?.delegatee}
network={loginNetwork}
/>
);
} else {
balanceInfo = (
<>
{!isNil(voteBalance) && (
<div>
<Tooltip
content={
!isZero(voteBalance) ? (
<VoteBalanceDetail details={balanceDetail} />
) : null
}
>
{`Available ${toApproximatelyFixed(
bigNumber2Locale(
fromAssetUnit(
voteBalance,
proposal?.networksConfig?.decimals,
if (!isOnePersonOnVoteOnly(proposal?.weightStrategy)) {
if (voteDelegation) {
balanceInfo = (
<DelegationInfo
delegatee={voteDelegation?.delegatee}
network={loginNetwork}
/>
);
} else {
balanceInfo = (
<>
{!isNil(voteBalance) && (
<div>
<Tooltip
content={
!isZero(voteBalance) ? (
<VoteBalanceDetail details={balanceDetail} />
) : null
}
>
{`Available ${toApproximatelyFixed(
bigNumber2Locale(
fromAssetUnit(
voteBalance,
proposal?.networksConfig?.decimals,
),
),
),
)} ${proposal.networksConfig?.symbol}`}
</Tooltip>
</div>
)}
{belowThreshold && <RedText>Insufficient</RedText>}
</>
);
)} ${proposal.networksConfig?.symbol}`}
</Tooltip>
</div>
)}
{belowThreshold && <RedText>Insufficient</RedText>}
</>
);
}
} else if (proposal.networksConfig?.accessibility === "society") {
balanceInfo = <SocietyMemberHit />;
}

voteButton = (
Expand Down
23 changes: 13 additions & 10 deletions next/components/postDetail/postVotesItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Voter from "@/components/role/voter";
import { Tooltip } from "@osn/common-ui";
import VoteBalanceDetail from "./VoteBalanceDetail";
import { isZero } from "frontedUtils";
import { isOnePersonOnVoteOnly } from "frontedUtils/strategy";

const Item = styled.div`
padding: 20px 0;
Expand Down Expand Up @@ -190,16 +191,18 @@ export default function PostVotesItem({
</EqualWrapper>
<EqualWrapper>
<BalanceWrapper>
<ValueDisplay
value={data.weights?.balanceOf}
space={space}
showAEM={true}
tooltipContent={
!isZero(data.weights?.balanceOf) ? (
<VoteBalanceDetail details={data.weights?.details} />
) : null
}
/>
{!isOnePersonOnVoteOnly(space.strategies) && (
<ValueDisplay
value={data.weights?.balanceOf}
space={space}
showAEM={true}
tooltipContent={
!isZero(data.weights?.balanceOf) ? (
<VoteBalanceDetail details={data.weights?.details} />
) : null
}
/>
)}
<IpfsSquare
href={
data?.pinHash &&
Expand Down

0 comments on commit ef1a6a8

Please sign in to comment.