Skip to content

Commit

Permalink
🩹 Fix mocked council stages following the Nara upgrade (#4807)
Browse files Browse the repository at this point in the history
* Fix mocked council stages on following the Nara upgrade

* Show responsive styles in stories
  • Loading branch information
thesan authored Mar 14, 2024
1 parent 57517df commit 1f165fe
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
17 changes: 10 additions & 7 deletions packages/ui/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createGlobalStyle } from 'styled-components'

import { GlobalModals } from '../src/app/GlobalModals'
import { GlobalStyle } from '../src/app/providers/GlobalStyle'
import { ResponsiveProvider } from '../src/common/providers/responsive/provider'
import { OnBoardingProvider } from '../src/common/providers/onboarding/provider'
import { NotificationsHolder } from '../src/common/components/page/SideNotification'
import { TransactionStatus } from '../src/common/components/TransactionStatus/TransactionStatus'
Expand Down Expand Up @@ -53,16 +54,18 @@ const RHFDecorator: Decorator = (Story) => {
)
}

const ModalDecorator: Decorator = (Story) => (
const Providers: Decorator = (Story) => (
<TransactionStatusProvider>
<ModalContextProvider>
<OnBoardingProvider>
<ValidatorContextProvider>
<Story />
<GlobalModals />
<NotificationsHolder>
<TransactionStatus />
</NotificationsHolder>
<ResponsiveProvider>
<Story />
<GlobalModals />
<NotificationsHolder>
<TransactionStatus />
</NotificationsHolder>
</ResponsiveProvider>
</ValidatorContextProvider>
</OnBoardingProvider>
</ModalContextProvider>
Expand All @@ -85,7 +88,7 @@ const KeyringDecorator: Decorator = (Story) => {
}

export const decorators = [
ModalDecorator,
Providers,
stylesWrapperDecorator,
i18nextDecorator,
RHFDecorator,
Expand Down
2 changes: 0 additions & 2 deletions packages/ui/src/app/App.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ export default {
: {
query: {
members: { membershipPrice: joy(20) },
council: { stage: { stage: { isIdle: true }, changedAt: 123 } },
referendum: { stage: {} },
staking: {
validators: {
entries: Object.entries(validators).map(([address, { commission }]) => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ export default {
accounts: { list: allAccounts },
chain: {
query: {
council: {
stage: { stage: { isIdle: true }, changedAt: 123 },
},
referendum: {
accountsOptedOut: {
keys: Array.from({ length: 23 }).map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export default {
council: {
budget: joy(1000),
councilorReward: joy(1),
stage: { stage: { isIdle: true }, changedAt: 123 },
},
referendum: { stage: {} },
},
Expand Down
8 changes: 4 additions & 4 deletions packages/ui/src/council/hooks/useElectionStage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ export const useElectionStage = (): UseElectionStage => {
export const electionStageObservable = (api: Api) => {
const councilObservable = api.query.council.stage().pipe(
concatMap(({ stage: councilStage, changedAt }): Observable<StageInfo> => {
if (councilStage.isIdle) {
if (councilStage.isIdle.valueOf()) {
return of({ stage: 'inactive', changedAt })
} else if (councilStage.isAnnouncing) {
} else if (councilStage.isAnnouncing.valueOf()) {
return of({ stage: 'announcing', changedAt })
}
return EMPTY
})
)
const referendumObservable = api.query.referendum.stage().pipe(
concatMap((referendumStage): Observable<StageInfo> => {
if (referendumStage.isVoting) {
if (referendumStage.isVoting.valueOf()) {
return of({ stage: 'voting', changedAt: referendumStage.asVoting.started })
} else if (referendumStage.isRevealing) {
} else if (referendumStage.isRevealing.valueOf()) {
return of({ stage: 'revealing', changedAt: referendumStage.asRevealing.started })
}
return EMPTY
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/mocks/data/proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ export const proposalsPagesChain = (
budget: councilBudget,
councilorReward,
nextRewardPayments,
stage: { stage: { isIdle: true }, changedAt: 123 },
},
referendum: { stage: {} },

Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/mocks/providers/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export const MockApiProvider: FC<MockApiProps> = ({ children, chain }) => {
const defaultQuery = {
session: { validators: [] },
staking: { activeEra: {} },
council: { stage: { stage: { isIdle: true, isAnnouncing: false }, changedAt: 123 } },
referendum: { stage: { isVoting: false, isRevealing: false } },
}
const rpcChain = {
getBlockHash: createType('BlockHash', BLOCK_HASH),
Expand Down

0 comments on commit 1f165fe

Please sign in to comment.