diff --git a/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/InstructionsSummary.tsx b/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/InstructionsSummary.tsx index 828ab3a5e6..407f4fbcd4 100644 --- a/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/InstructionsSummary.tsx +++ b/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/InstructionsSummary.tsx @@ -1,6 +1,13 @@ +import { Listbox, Transition } from '@headlessui/react' import { PythCluster } from '@pythnetwork/client' import { MultisigInstruction } from '@pythnetwork/xc-admin-common' import { getInstructionsSummary } from './utils' +import { getMappingCluster } from '../../InstructionViews/utils' +import CopyText from '../../common/CopyText' +import Arrow from '@images/icons/down.inline.svg' +import { Fragment, useState, useMemo, useContext } from 'react' +import { usePythContext } from '../../../contexts/PythContext' +import { ClusterContext } from '../../../contexts/ClusterContext' export const InstructionsSummary = ({ instructions, @@ -8,18 +15,197 @@ export const InstructionsSummary = ({ }: { instructions: MultisigInstruction[] cluster: PythCluster +}) => ( +
+ {getInstructionsSummary({ instructions, cluster }).map((instruction) => ( + + ))} +
+) + +const SummaryItem = ({ + instruction, +}: { + instruction: ReturnType[number] }) => { - const instructionsCount = getInstructionsSummary({ instructions, cluster }) + switch (instruction.name) { + case 'addPublisher': + case 'delPublisher': { + return ( +
+
+ {instruction.name}: {instruction.count} +
+ +
+ ) + } + default: { + return ( +
+ {instruction.name}: {instruction.count} +
+ ) + } + } +} + +type AddRemovePublisherDetailsProps = { + isAdd: boolean + summaries: { + readonly priceAccount: string + readonly pub: string + }[] +} + +const AddRemovePublisherDetails = ({ + isAdd, + summaries, +}: AddRemovePublisherDetailsProps) => { + const { cluster } = useContext(ClusterContext) + const { priceAccountKeyToSymbolMapping, publisherKeyToNameMapping } = + usePythContext() + const publisherKeyToName = + publisherKeyToNameMapping[getMappingCluster(cluster)] + const [groupBy, setGroupBy] = useState<'publisher' | 'price account'>( + 'publisher' + ) + const grouped = useMemo( + () => + Object.groupBy(summaries, (summary) => + groupBy === 'publisher' ? summary.pub : summary.priceAccount + ), + [groupBy, summaries] + ) return ( -
- {Object.entries(instructionsCount).map(([name, count]) => { - return ( -
- {name}: {count} +
+
+
Group by
+