Skip to content

Commit

Permalink
chore: update initial app code [LIBS-644]
Browse files Browse the repository at this point in the history
  • Loading branch information
tomzemp committed Jul 22, 2024
1 parent 47c9dd1 commit afc17d0
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions cli/config/init.entrypoint.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataQuery } from '@dhis2/app-runtime'
import { useDataQuery } from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import React from 'react'
import classes from './App.module.css'
Expand All @@ -9,27 +9,23 @@ const query = {
},
}

const MyApp = () => (
<div className={classes.container}>
<DataQuery query={query}>
{({ error, loading, data }) => {
if (error) {
return <span>ERROR</span>
}
if (loading) {
return <span>...</span>
}
return (
<>
<h1>
{i18n.t('Hello {{name}}', { name: data.me.name })}
</h1>
<h3>{i18n.t('Welcome to DHIS2!')}</h3>
</>
)
}}
</DataQuery>
</div>
)
const MyApp = () => {
const { error, loading, data } = useDataQuery(query)

if (error) {
return <span>{i18n.t('ERROR')}</span>
}

if (loading) {
return <span>{i18n.t('Loading...')}</span>
}

return (
<div className={classes.container}>
<h1>{i18n.t('Hello {{name}}', { name: data?.me?.name })}</h1>
<h3>{i18n.t('Welcome to DHIS2!')}</h3>
</div>
)
}

export default MyApp

0 comments on commit afc17d0

Please sign in to comment.