Skip to content

Commit

Permalink
fix: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut authored and Sergey Zhuravlev committed Aug 9, 2024
1 parent f9bed4f commit 29a2c28
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useStoreMap, useUnit } from 'effector-react';
import { type ChainId, type Referendum } from '@shared/core';
import { pickNestedValue } from '@shared/lib/utils';
import { Markdown, Shimmering } from '@shared/ui';
import { networkModel } from '@/entities/network';
import { TrackInfo, referendumService } from '@entities/governance';
import { detailsAggregate } from '../../aggregates/details';

Expand All @@ -15,6 +16,8 @@ type Props = {

export const ProposalDescription = ({ chainId, referendum }: Props) => {
const isDescriptionLoading = useUnit(detailsAggregate.$isDescriptionLoading);
const addressPrefix = useUnit(networkModel.$chains)[chainId]?.addressPrefix;

const description = useStoreMap({
store: detailsAggregate.$descriptions,
keys: [chainId, referendum.referendumId],
Expand All @@ -24,7 +27,7 @@ export const ProposalDescription = ({ chainId, referendum }: Props) => {
return (
<div>
<div className="mb-4 flex items-center">
<ProposerName referendum={referendum} />
<ProposerName referendum={referendum} addressPrefix={addressPrefix} />
<div className="grow" />
{referendumService.isOngoing(referendum) && <TrackInfo trackId={referendum.track} />}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import { useStoreMap } from 'effector-react';

import { useI18n } from '@app/providers';
import { toAddress } from '@/shared/lib/utils';
import { type OngoingReferendum, type Referendum } from '@shared/core';
import { type Referendum } from '@shared/core';
import { FootnoteText, Shimmering } from '@shared/ui';
import { referendumService } from '@entities/governance';
import { AccountAddress } from '@entities/wallet';
import { detailsAggregate } from '../../aggregates/details';

type Props = {
referendum: Referendum;
addressPrefix: number;
};

export const ProposerName = ({ referendum }: Props) => {
export const ProposerName = ({ referendum, addressPrefix }: Props) => {
const { t } = useI18n();

const proposer = useStoreMap({
Expand All @@ -38,12 +39,12 @@ export const ProposerName = ({ referendum }: Props) => {
address={proposer.parent.address}
name={proposer.parent.name || proposer.email || proposer.twitter || proposer.parent.address}
/>
) : (referendum as OngoingReferendum)?.submissionDeposit?.who ? (
) : referendumService.isOngoing(referendum) && referendum.submissionDeposit?.who ? (
<AccountAddress
addressFont="text-text-secondary"
size={16}
address={(referendum as OngoingReferendum).submissionDeposit!.who}
name={toAddress((referendum as OngoingReferendum).submissionDeposit!.who, { chunk: 6 })}
address={referendum.submissionDeposit.who}
name={toAddress(referendum.submissionDeposit!.who, { chunk: 6, prefix: addressPrefix })}
/>
) : null;

Expand Down

0 comments on commit 29a2c28

Please sign in to comment.