Skip to content

Commit

Permalink
Rename orgs to Accounts (#104)
Browse files Browse the repository at this point in the history
* Rename to Accounts

* Use compte not compta
  • Loading branch information
selankon authored Aug 22, 2024
1 parent 683568c commit 4c3efa6
Show file tree
Hide file tree
Showing 24 changed files with 152 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ReducedTextAndCopy } from '~components/Layout/CopyButton'
import { FallbackAccountImg, RoutePath } from '~constants'
import LinkCard from '~components/Layout/LinkCard'

type IOrganizationCardProps = {
type IAccountCardProps = {
id?: string
electionCount?: number
} & CardProps
Expand All @@ -19,17 +19,17 @@ type IOrganizationCardProps = {
* @param rest chakra CardProps
* @constructor
*/
export const OrganizationCard = ({ id, ...rest }: IOrganizationCardProps) => {
if (!id) return <OrganizationCardSkeleton {...rest} />
export const AccountCard = ({ id, ...rest }: IAccountCardProps) => {
if (!id) return <AccountCardSkeleton {...rest} />

return (
<OrganizationProvider id={id}>
<OrganizationCardSkeleton id={id} {...rest} />
<AccountCardSkeleton id={id} {...rest} />
</OrganizationProvider>
)
}

const OrganizationCardSkeleton = ({ electionCount: ec, ...rest }: IOrganizationCardProps) => {
const AccountCardSkeleton = ({ electionCount: ec, ...rest }: IAccountCardProps) => {
const { organization, loading } = useOrganization()
const { t } = useTranslation()

Expand All @@ -40,7 +40,7 @@ const OrganizationCardSkeleton = ({ electionCount: ec, ...rest }: IOrganizationC

return (
<LinkCard
to={generatePath(RoutePath.Organization, { pid, tab: null, page: null })}
to={generatePath(RoutePath.Account, { pid, tab: null, page: null })}
direction={'row'}
alignItems='center'
pl={4}
Expand All @@ -50,7 +50,7 @@ const OrganizationCardSkeleton = ({ electionCount: ec, ...rest }: IOrganizationC
<Avatar
mx='auto'
fallbackSrc={FallbackAccountImg}
alt={t('organization.avatar_alt', {
alt={t('account.avatar_alt', {
name: organization?.account.name.default || organization?.address,
}).toString()}
/>
Expand All @@ -68,7 +68,7 @@ const OrganizationCardSkeleton = ({ electionCount: ec, ...rest }: IOrganizationC
</ReducedTextAndCopy>
{electionCount && (
<Text fontSize={'sm'}>
<Trans i18nKey={'organization.process_count'} count={electionCount}>
<Trans i18nKey={'account.process_count'} count={electionCount}>
<strong>Process:</strong> {{ count: electionCount }}
</Trans>
</Text>
Expand All @@ -78,20 +78,20 @@ const OrganizationCardSkeleton = ({ electionCount: ec, ...rest }: IOrganizationC
)
}

export const SmallOrganizationCard = ({ id, flex, avatar }: { id: string; flex?: FlexProps; avatar?: BoxProps }) => {
export const SmallAccountCard = ({ id, flex, avatar }: { id: string; flex?: FlexProps; avatar?: BoxProps }) => {
const { organization } = useOrganization()
const { t } = useTranslation()

const orgName = organization?.account.name.default
const orgLink = generatePath(RoutePath.Organization, { pid: id, tab: null, page: null })
const orgLink = generatePath(RoutePath.Account, { pid: id, tab: null, page: null })

return (
<Flex direction={'row'} alignItems={'center'} gap={2} {...flex}>
<Box w={'30px'} minW={'30px'} {...avatar}>
<Avatar
mx='auto'
fallbackSrc={'/images/fallback-account-dark.png'}
alt={t('organization.avatar_alt', {
alt={t('account.avatar_alt', {
name: orgName || organization?.address,
}).toString()}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { HeroHeaderLayout } from '~components/Layout/HeroHeaderLayout'
import { RouteParamsTabs } from '~components/Layout/RouteParamsTabs'
import { RawContentBox } from '~components/Layout/ShowRawButton'
import { FallbackHeaderImg, RoutePath } from '~constants'
import AccountTransfers from '~components/Organizations/Details/Transfers'
import OrganizationElections from './Details/Elections'
import OrgDetails from './Details/OrgDetails'
import AccountFees from '~components/Organizations/Details/Fees'
import AccountTransfers from '~components/Accounts/Details/Transfers'
import AccountElections from './Details/Elections'
import AccountDetails from './Details/AccountDetails'
import AccountFees from '~components/Accounts/Details/Fees'
import TextAndTag from '~components/Layout/TextAndTag'

const OrganizationDetail = () => {
const AccountDetail = () => {
const { organization } = useOrganization()

const { t } = useTranslation()
Expand All @@ -35,39 +35,36 @@ const OrganizationDetail = () => {
</ReducedTextAndCopy>
</VStack>
</HeroHeaderLayout>
<RouteParamsTabs path={RoutePath.Organization} isLazy>
<RouteParamsTabs path={RoutePath.Account} isLazy>
<TabList display='flex' flexWrap='wrap'>
<Tab>
<Trans i18nKey={'process.tab_details'}>Details</Trans>
</Tab>
<Tab>
<TextAndTag
text={t('organization.elections_count', { defaultValue: 'Elections' })}
text={t('account.elections_count', { defaultValue: 'Elections' })}
tagLabel={organization.electionIndex.toString()}
/>
</Tab>
<Tab>
<TextAndTag
text={t('organization.transfers_count', { defaultValue: 'Transfers' })}
text={t('account.transfers_count', { defaultValue: 'Transfers' })}
tagLabel={transfersCount?.toString() ?? '0'}
/>
</Tab>
<Tab>
<TextAndTag
text={t('organization.fees', { defaultValue: 'Fees' })}
tagLabel={feesCount?.toString() ?? '0'}
/>
<TextAndTag text={t('account.fees', { defaultValue: 'Fees' })} tagLabel={feesCount?.toString() ?? '0'} />
</Tab>
<Tab>
<Trans i18nKey={'raw'}>Raw</Trans>
</Tab>
</TabList>
<TabPanels>
<TabPanel>
<OrgDetails org={organization} />
<AccountDetails org={organization} />
</TabPanel>
<TabPanel>
<OrganizationElections org={organization} />
<AccountElections org={organization} />
</TabPanel>
<TabPanel>
<AccountTransfers org={organization} txCount={transfersCount} />
Expand All @@ -84,4 +81,4 @@ const OrganizationDetail = () => {
)
}

export default OrganizationDetail
export default AccountDetail
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ import { FaUserAlt } from 'react-icons/fa'
import { DetailsGrid, GridItemProps } from '~components/Layout/DetailsGrid'
import { AppBaseURL } from '~constants'

const OrgDetails = ({ org }: { org: AccountData }) => {
const AccountDetails = ({ org }: { org: AccountData }) => {
const { t } = useTranslation()

const details: GridItemProps[] = [
{
label: t('organization.nonce', { defaultValue: 'Nonce' }),
label: t('account.nonce', { defaultValue: 'Nonce' }),
children: org.nonce,
},
{
label: t('organization.balance', { defaultValue: 'Balance' }),
label: t('account.balance', { defaultValue: 'Balance' }),
children: org.balance,
},
{
label: t('organization.election_count', { defaultValue: 'Elections' }),
label: t('account.election_count', { defaultValue: 'Elections' }),
children: org.electionIndex,
},
{
label: t('organization.profile', { defaultValue: 'Profile' }),
label: t('account.profile', { defaultValue: 'Profile' }),
children: (
<Link target='blank' href={`${AppBaseURL}/organization/${ensure0x(org.address)}`}>
<Icon as={FaUserAlt} boxSize={3} mr={2} />
<Trans i18nKey={'organization.view_profile'}></Trans>
<Trans i18nKey={'account.view_profile'}></Trans>
</Link>
),
},
...(org.account.description.default
? [
{
label: t('organization.description', { defaultValue: 'Description' }),
label: t('account.description', { defaultValue: 'Description' }),
children: <OrganizationDescription />,
},
]
Expand All @@ -47,4 +47,4 @@ const OrgDetails = ({ org }: { org: AccountData }) => {
)
}

export default OrgDetails
export default AccountDetails
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ import { RoutedPagination } from '~components/Pagination/Pagination'
import { RoutedPaginationProvider, useRoutedPagination } from '~components/Pagination/PaginationProvider'
import { ElectionCard } from '~components/Process/Card'
import { RoutePath } from '~constants'
import { useOrganizationElections } from '~queries/organizations'
import { useOrganizationElections } from '~queries/accounts'
import { ContentError, NoResultsError } from '~components/Layout/ContentError'

interface OrgComponentProps {
org: AccountData
}

const OrganizationElections = ({ org }: OrgComponentProps) => {
const AccountElections = ({ org }: OrgComponentProps) => {
if (org.electionIndex === 0) {
return (
<Text>
<Trans i18nKey={'organization.no_elections'}>No elections yet!</Trans>
<Trans i18nKey={'account.no_elections'}>No elections yet!</Trans>
</Text>
)
}

return (
<RoutedPaginationProvider path={RoutePath.Organization}>
<OrganizationElectionsList org={org} />
<RoutedPaginationProvider path={RoutePath.Account}>
<AccountElectionsList org={org} />
</RoutedPaginationProvider>
)
}

const OrganizationElectionsList = ({ org }: OrgComponentProps) => {
const AccountElectionsList = ({ org }: OrgComponentProps) => {
const { page }: { page?: number } = useRoutedPagination()

const { data, isLoading, isError, error } = useOrganizationElections({
Expand Down Expand Up @@ -62,4 +62,4 @@ const OrganizationElectionsList = ({ org }: OrgComponentProps) => {
)
}

export default OrganizationElections
export default AccountElections
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useDateFns } from '~i18n/use-date-fns'
import { AccountData, TransactionType } from '@vocdoni/sdk'
import { PaginationProvider, usePagination } from '~components/Pagination/PaginationProvider'
import { Pagination } from '~components/Pagination/Pagination'
import { useAccountFees } from '~queries/organizations'
import { useAccountFees } from '~queries/accounts'
import { TransactionTypeBadge } from '~components/Transactions/TransactionCard'
import { generatePath, Link as RouterLink } from 'react-router-dom'
import { RoutePath } from '~constants'
Expand Down Expand Up @@ -45,7 +45,7 @@ const AccountFeesTable = ({ org }: { org: AccountData }) => {
if (!data.fees.length) {
return (
<Text>
<Trans i18nKey={'organization.fees.no_fees'}>No fees yet!</Trans>
<Trans i18nKey={'account.fees.no_fees'}>No fees yet!</Trans>
</Text>
)
}
Expand All @@ -58,13 +58,13 @@ const AccountFeesTable = ({ org }: { org: AccountData }) => {
<Thead>
<Tr>
<Th>
<Trans i18nKey={'organization.fees.tx_type'}>Tx Type</Trans>
<Trans i18nKey={'account.fees.tx_type'}>Tx Type</Trans>
</Th>
<Th>
<Trans i18nKey={'organization.transfers.block'}>Block</Trans>
<Trans i18nKey={'account.transfers.block'}>Block</Trans>
</Th>
<Th>
<Trans i18nKey={'organization.fees.cost'}>Cost</Trans>
<Trans i18nKey={'account.fees.cost'}>Cost</Trans>
</Th>
</Tr>
</Thead>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { generatePath, Link as RouterLink } from 'react-router-dom'
import { ReducedTextAndCopy } from '~components/Layout/CopyButton'
import { LoadingCards } from '~components/Layout/Loading'
import { RoutePath } from '~constants'
import { useAccountTransfers } from '~queries/organizations'
import { useAccountTransfers } from '~queries/accounts'
import { useDateFns } from '~i18n/use-date-fns'
import { BiLogInCircle, BiLogOutCircle } from 'react-icons/bi'
import { AccountData } from '@vocdoni/sdk'
Expand All @@ -32,11 +32,11 @@ const FromToIcon = ({ isIncoming, ...rest }: { isIncoming: boolean } & IconProps

let icon = BiLogOutCircle
let color = 'textAccent2B'
let tooltip = t('organization.transfers.outgoing_tx', { defaultValue: 'Outgoing tx' })
let tooltip = t('account.transfers.outgoing_tx', { defaultValue: 'Outgoing tx' })
if (isIncoming) {
icon = BiLogInCircle
color = 'accent1C'
tooltip = t('organization.transfers.incoming_tx', { defaultValue: 'Incoming tx' })
tooltip = t('account.transfers.incoming_tx', { defaultValue: 'Incoming tx' })
}

return (
Expand Down Expand Up @@ -76,7 +76,7 @@ const AccountTransfersTable = ({ txCount, org }: AccountTransfersProps) => {
if (txCount && !(txCount > 0)) {
return (
<Text>
<Trans i18nKey={'organization.transfers.no_transfers'}>No transfers yet!</Trans>
<Trans i18nKey={'account.transfers.no_transfers'}>No transfers yet!</Trans>
</Text>
)
}
Expand All @@ -101,16 +101,16 @@ const AccountTransfersTable = ({ txCount, org }: AccountTransfersProps) => {
<Thead>
<Tr>
<Th>
<Trans i18nKey={'organization.transfers.tx_hash'}>Tx Hash</Trans>
<Trans i18nKey={'account.transfers.tx_hash'}>Tx Hash</Trans>
</Th>
<Th>
<Trans i18nKey={'organization.transfers.block'}>Block</Trans>
<Trans i18nKey={'account.transfers.block'}>Block</Trans>
</Th>
<Th>
<Trans i18nKey={'organization.transfers.from_to'}>From/To</Trans>
<Trans i18nKey={'account.transfers.from_to'}>From/To</Trans>
</Th>
<Th>
<Trans i18nKey={'organization.transfers.amount'}>Amount</Trans>
<Trans i18nKey={'account.transfers.amount'}>Amount</Trans>
</Th>
</Tr>
</Thead>
Expand Down Expand Up @@ -163,7 +163,7 @@ const AccountTransfersTable = ({ txCount, org }: AccountTransfersProps) => {
fontSize={'md'}
p={1}
h={8}
to={generatePath(RoutePath.Organization, {
to={generatePath(RoutePath.Account, {
pid: fromToAddress,
tab: null,
page: null,
Expand Down
Loading

2 comments on commit 4c3efa6

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.