Skip to content

Commit

Permalink
fix: put LoginAppWrapper in separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
tomzemp committed Sep 12, 2023
1 parent 151357d commit fdcd8a3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 30 deletions.
30 changes: 1 addition & 29 deletions adapter/src/components/AppWrapper.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import PropTypes from 'prop-types'
import React from 'react'
import {
useCurrentUserLocale,
useSystemDefaultLocale,
} from '../utils/useLocale.js'
import { useCurrentUserLocale } from '../utils/useLocale.js'
import { useVerifyLatestUser } from '../utils/useVerifyLatestUser.js'
import { Alerts } from './Alerts.js'
import { ConnectedHeaderBar } from './ConnectedHeaderBar.js'
Expand Down Expand Up @@ -37,28 +34,3 @@ AppWrapper.propTypes = {
children: PropTypes.node,
plugin: PropTypes.bool,
}

export const LoginAppWrapper = ({ children }) => {
const { loading: localeLoading } = useSystemDefaultLocale()
// cannot check current user for a loginApp (no api/me)

if (localeLoading) {
return <LoadingMask />
}

return (
<div className="app-shell-adapter">
<style jsx>{styles}</style>
<div className="app-shell-app">
<ErrorBoundary onRetry={() => window.location.reload()}>
{children}
</ErrorBoundary>
</div>
<Alerts />
</div>
)
}

LoginAppWrapper.propTypes = {
children: PropTypes.node,
}
32 changes: 32 additions & 0 deletions adapter/src/components/LoginAppWrapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import PropTypes from 'prop-types'
import React from 'react'
import { useSystemDefaultLocale } from '../utils/useLocale.js'
import { Alerts } from './Alerts.js'
import { ErrorBoundary } from './ErrorBoundary.js'
import { LoadingMask } from './LoadingMask.js'
import { styles } from './styles/AppWrapper.style.js'

export const LoginAppWrapper = ({ children }) => {
const { loading: localeLoading } = useSystemDefaultLocale()
// cannot check current user for a loginApp (no api/me)

if (localeLoading) {
return <LoadingMask />
}

return (
<div className="app-shell-adapter">
<style jsx>{styles}</style>
<div className="app-shell-app">
<ErrorBoundary onRetry={() => window.location.reload()}>
{children}
</ErrorBoundary>
</div>
<Alerts />
</div>
)
}

LoginAppWrapper.propTypes = {
children: PropTypes.node,
}
3 changes: 2 additions & 1 deletion adapter/src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { checkForSWUpdateAndReload } from '@dhis2/pwa'
import PropTypes from 'prop-types'
import React from 'react'
import { LoginAppWrapper, AppWrapper } from './components/AppWrapper.js'
import { AppWrapper } from './components/AppWrapper.js'
import { ErrorBoundary } from './components/ErrorBoundary.js'
import { LoginAppWrapper } from './components/LoginAppWrapper.js'
import { OfflineInterfaceProvider } from './components/OfflineInterfaceContext.js'
import { PWALoadingBoundary } from './components/PWALoadingBoundary.js'
import { ServerVersionProvider } from './components/ServerVersionProvider.js'
Expand Down

0 comments on commit fdcd8a3

Please sign in to comment.