Skip to content

Commit

Permalink
code: include logger
Browse files Browse the repository at this point in the history
  • Loading branch information
xstelea committed Jun 7, 2024
1 parent 939246c commit 5bcbf1c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const RadixConnectRelayModule = (input: {
callBackPath: '/connect',
})

const rcfmPageModule = providers?.rcfmPageModule ?? RcfmPageModule()
const rcfmPageModule = providers?.rcfmPageModule ?? RcfmPageModule({ logger })

const identityModule =
providers?.identityModule ??
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isBrowser } from '../../../../helpers/is-browser'
import { Logger } from '../../../../helpers'

export const RcfmPageState = {
loading: 'loading',
Expand All @@ -9,8 +10,10 @@ export const RcfmPageState = {
export type RcfmPageState = (typeof RcfmPageState)[keyof typeof RcfmPageState]

export type RcfmPageModule = ReturnType<typeof RcfmPageModule>
export const RcfmPageModule = () => {
export const RcfmPageModule = (input: { logger?: Logger }) => {
const logger = input.logger?.getSubLogger({ name: 'RcfmPageModule' })
if (!isBrowser()) {
logger?.debug({ method: 'isBrowser', isBrowser: false })
return {
show: () => {},
hide: () => {},
Expand All @@ -21,28 +24,30 @@ export const RcfmPageModule = () => {
const rcfmPageHtmlElement = document.createElement('radix-rcfm-page')
document.body.appendChild(rcfmPageHtmlElement)

const showWithData = ({
header,
subheader,
isError,
isLoading,
}: {
const showWithData = (values: {
header?: string
subheader?: string
isError?: boolean
isLoading?: boolean
}) => {
const { header, subheader, isError, isLoading } = values
rcfmPageHtmlElement.header = header || ''
rcfmPageHtmlElement.subheader = subheader || ''
rcfmPageHtmlElement.isError = isError || false
rcfmPageHtmlElement.isLoading = isLoading || false
rcfmPageHtmlElement.isHidden = false
logger?.debug({
method: 'showWithData',
values,
})
}
const hide = () => {
logger?.debug({ method: 'hide', isHidden: true })
rcfmPageHtmlElement.isHidden = true
}

const show = (state: RcfmPageState) => {
logger?.debug({ method: 'show', state })
switch (state) {
case RcfmPageState.dAppVerified:
showWithData({
Expand Down

0 comments on commit 5bcbf1c

Please sign in to comment.