-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #222 from alleslabs/feat/account-proposals
feat: add proposal of an user
- Loading branch information
Showing
16 changed files
with
254 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./ProposalsTableHeader"; | ||
export * from "./ProposalsTableRow"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./codes"; | ||
export * from "./contracts"; | ||
export * from "./proposals"; |
124 changes: 124 additions & 0 deletions
124
src/lib/pages/account-details/components/tables/proposals/ProposalsTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import { Box, Flex } from "@chakra-ui/react"; | ||
import { observer } from "mobx-react-lite"; | ||
import type { ChangeEvent } from "react"; | ||
|
||
import { Loading } from "lib/components/Loading"; | ||
import { Pagination } from "lib/components/pagination"; | ||
import { usePaginator } from "lib/components/pagination/usePaginator"; | ||
import { EmptyState } from "lib/components/state/EmptyState"; | ||
import { TableContainer } from "lib/components/table"; | ||
import { | ||
ProposalsTableHeader, | ||
ProposalsTableRow, | ||
} from "lib/components/table/proposals"; | ||
import { TableTitle } from "lib/components/table/TableTitle"; | ||
import { ViewMore } from "lib/components/table/ViewMore"; | ||
import { useProposalsByWalletAddressPagination } from "lib/services/proposalService"; | ||
import type { HumanAddr, Option } from "lib/types"; | ||
|
||
interface ProposalsTableProps { | ||
walletAddress: HumanAddr; | ||
scrollComponentId: string; | ||
totalData: Option<number>; | ||
refetchCount: () => void; | ||
onViewMore?: () => void; | ||
} | ||
|
||
const ProposalsTableBody = observer( | ||
({ | ||
walletAddress, | ||
scrollComponentId, | ||
totalData, | ||
refetchCount, | ||
onViewMore, | ||
}: ProposalsTableProps) => { | ||
const { | ||
pagesQuantity, | ||
currentPage, | ||
setCurrentPage, | ||
pageSize, | ||
setPageSize, | ||
offset, | ||
} = usePaginator({ | ||
total: totalData, | ||
initialState: { | ||
pageSize: 10, | ||
currentPage: 1, | ||
isDisabled: false, | ||
}, | ||
}); | ||
const { data: proposals, isLoading } = | ||
useProposalsByWalletAddressPagination( | ||
walletAddress, | ||
offset, | ||
onViewMore ? 5 : pageSize | ||
); | ||
|
||
const onPageChange = (nextPage: number) => { | ||
refetchCount(); | ||
setCurrentPage(nextPage); | ||
}; | ||
|
||
const onPageSizeChange = (e: ChangeEvent<HTMLSelectElement>) => { | ||
const size = Number(e.target.value); | ||
refetchCount(); | ||
setPageSize(size); | ||
setCurrentPage(1); | ||
}; | ||
|
||
const templateColumns = | ||
"100px minmax(300px, 1fr) 150px 280px 180px 190px 160px"; | ||
|
||
if (isLoading) return <Loading />; | ||
if (!proposals?.length) | ||
return ( | ||
<Flex | ||
py="64px" | ||
direction="column" | ||
borderY="1px solid" | ||
borderColor="pebble.700" | ||
> | ||
<EmptyState message="This account did not open any proposals before." /> | ||
</Flex> | ||
); | ||
return ( | ||
<> | ||
<TableContainer> | ||
<ProposalsTableHeader templateColumns={templateColumns} /> | ||
{proposals.map((proposal) => ( | ||
<ProposalsTableRow | ||
key={proposal.proposalId} | ||
proposal={proposal} | ||
templateColumns={templateColumns} | ||
/> | ||
))} | ||
</TableContainer> | ||
{totalData && | ||
(onViewMore | ||
? totalData > 5 && <ViewMore onClick={onViewMore} /> | ||
: totalData > 10 && ( | ||
<Pagination | ||
currentPage={currentPage} | ||
pagesQuantity={pagesQuantity} | ||
offset={offset} | ||
totalData={totalData} | ||
scrollComponentId={scrollComponentId} | ||
pageSize={pageSize} | ||
onPageChange={onPageChange} | ||
onPageSizeChange={onPageSizeChange} | ||
/> | ||
))} | ||
</> | ||
); | ||
} | ||
); | ||
|
||
export const ProposalsTable = ({ | ||
totalData, | ||
...componentProps | ||
}: ProposalsTableProps) => ( | ||
<Box mt={12} mb={4}> | ||
<TableTitle title="Opened Proposals" count={totalData ?? 0} /> | ||
<ProposalsTableBody totalData={totalData} {...componentProps} /> | ||
</Box> | ||
); |
1 change: 1 addition & 0 deletions
1
src/lib/pages/account-details/components/tables/proposals/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./ProposalsTable"; |
Oops, something went wrong.
54d90b5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
terra-celatone-frontend-staging – ./
terra-celatone-frontend-staging-git-develop-alleslabs.vercel.app
terra-celatone-frontend-staging.vercel.app
terra-celatone-frontend-staging-alleslabs.vercel.app
terra-staging.celat.one
54d90b5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
osmosis-celatone-frontend-staging – ./
osmosis-celatone-frontend-staging-git-develop-alleslabs.vercel.app
osmosis-staging.celat.one
osmosis-celatone-frontend-staging-alleslabs.vercel.app
celatone-frontend-staging.vercel.app
celatone-staging.osmosis.zone