Skip to content

Commit

Permalink
fix: replace modal
Browse files Browse the repository at this point in the history
  • Loading branch information
hlvhe committed Jul 2, 2024
1 parent 0a8ee99 commit 04de1c2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
10 changes: 3 additions & 7 deletions packages/ui/src/app/GlobalModals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export const MODAL_WITH_CLOSE_CONFIRMATION: ModalNames[] = [
]

export const GlobalModals = () => {
const { modal, hideModal, currentModalMachine, showModal, modalData, isClosing } = useModal()
const { modal, hideModal, currentModalMachine, showModal, isClosing } = useModal()
const { active: activeMember } = useMyMemberships()
const { status } = useTransactionStatus()
const Modal = useMemo(() => (modal && modal in modals ? memo(() => modals[modal as ModalNames]) : null), [modal])
Expand All @@ -235,12 +235,8 @@ export const GlobalModals = () => {
const potentialFallback = useGlobalModalHandler(currentModalMachine, hideModal)

if (modal && !GUEST_ACCESSIBLE_MODALS.includes(modal as ModalNames) && !activeMember) {
showModal<SwitchMemberModalCall>({
modal: 'SwitchMember',
data: {
originalModalName: modal as ModalNames,
originalModalData: modalData,
},
showModal({
modal: 'OnBoardingModal',
})
return null
}
Expand Down
10 changes: 3 additions & 7 deletions packages/ui/test/council/modals/AnnounceCandidacyModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,12 @@ describe('UI: Announce Candidacy Modal', () => {

renderModal()

const switchMemberModalCall = {
modal: 'SwitchMember',
data: {
originalModalName: 'AnnounceCandidateModal',
originalModalData: null,
},
const onBoardingModalCall = {
modal: 'OnBoardingModal',
}

expect(showModal).toBeCalledTimes(1)
expect(showModal).toBeCalledWith({ ...switchMemberModalCall })
expect(showModal).toBeCalledWith({ ...onBoardingModalCall })
})

it('Transaction fee', async () => {
Expand Down
6 changes: 1 addition & 5 deletions packages/ui/test/forum/modals/CreateThreadModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ describe('CreateThreadModal', () => {
useMyMemberships.active = undefined
renderModal()
expect(useModal.showModal).toBeCalledWith({
modal: 'SwitchMember',
data: {
originalModalName: 'CreateThreadModal',
originalModalData: useModal.modalData,
},
modal: 'OnBoardingModal',
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,7 @@ describe('UI: ApplyForRoleModal', () => {
await renderModal()

expect(showModal).toBeCalledWith({
modal: 'SwitchMember',
data: {
originalModalData: modalData,
originalModalName: 'ApplyForRoleModal',
},
modal: 'OnBoardingModal',
})
showModal.mockClear()
})
Expand Down

0 comments on commit 04de1c2

Please sign in to comment.