diff --git a/README.md b/README.md
index ab8a87d..6eb44cd 100644
--- a/README.md
+++ b/README.md
@@ -4,4 +4,6 @@ This is the repo that you will use during the Web Academy exercises. Please fork
Before participating, make sure you have gone through [the pre-requisites](https://dhis2.github.io/academy-web-app-dev/docs/before-academy/) for the academy.
-For more information about the academy and the topics taught, check the website: https://dhis2.github.io/academy-web-app-dev/
\ No newline at end of file
+For more information about the academy and the topics taught, check the website: https://dhis2.github.io/academy-web-app-dev/
+
+Hi My name is Hijab Hassan
\ No newline at end of file
diff --git a/i18n/en.pot b/i18n/en.pot
new file mode 100644
index 0000000..5e4e380
--- /dev/null
+++ b/i18n/en.pot
@@ -0,0 +1,18 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: i18next-conv\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1)\n"
+"POT-Creation-Date: 2024-04-17T11:02:09.401Z\n"
+"PO-Revision-Date: 2024-04-17T11:02:09.401Z\n"
+
+msgid "Home"
+msgstr "Home"
+
+msgid "DHIS2 Web App Academy 2024"
+msgstr "DHIS2 Web App Academy 2024"
+
+msgid "Running on DHIS2 API version"
+msgstr "Running on DHIS2 API version"
diff --git a/package.json b/package.json
index 0c33cfc..d6cc739 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,7 @@
"private": true,
"scripts": {
"build": "d2-app-scripts build",
- "start": "d2-app-scripts start",
+ "start": "d2-app-scripts start --proxy https://dev.im.dhis2.org/academy-web --proxyPort 8082",
"test": "d2-app-scripts test",
"deploy": "d2-app-scripts deploy",
"lint": "d2-style check",
diff --git a/src/navigation/Navigation.js b/src/navigation/Navigation.js
index 38b5781..d25e063 100644
--- a/src/navigation/Navigation.js
+++ b/src/navigation/Navigation.js
@@ -1,3 +1,4 @@
+import {Menu, MenuItem} from '@dhis2/ui'
import PropTypes from 'prop-types'
import React from 'react'
// @TODO: Import the `Menu` and `MenuItem` components
@@ -17,7 +18,7 @@ const NavigationItem = ({ path, label }) => {
const onClick = () => navigate(path)
// @TODO: Use the `MenuItem` component instead of the `div`
- return
{label}
+ return < MenuItem label={label} active={isActive} onClick={onClick}/>
}
NavigationItem.propTypes = {
@@ -27,8 +28,8 @@ NavigationItem.propTypes = {
export const Navigation = () => (
// @TODO: Use the `Menu` components instead of the `div`
-
-
+ (
label="Form"
path="/form"
/>
-
+
)
diff --git a/src/views/Attributes.js b/src/views/Attributes.js
index 87b6a40..711b5b1 100644
--- a/src/views/Attributes.js
+++ b/src/views/Attributes.js
@@ -1,24 +1,74 @@
+import {useDataQuery} from '@dhis2/app-runtime'
+import {
+ CenteredContent,
+ CircularLoader,
+ NoticeBox} from '@dhis2/ui'
+import {
+ DataTable,
+ DataTableBody,
+ DataTableCell,
+ DataTableColumnHeader,
+ DataTableHead,
+ DataTableRow} from '@dhis2-ui/table'
import React from 'react'
-import { useGetAttributes } from '../hooks/index.js'
+//import { useGetAttributes } from '../hooks/index.js'
+//tested query in the playground
+const query= {
+ "attributesList": {
+ "resource": "attributes",
+ "params": {
+ "pageSize": 5,
+ "fields": ["displayName", "code", "unique"],
+ "order": "displayName:desc",
+ },
+ },
+}
export const Attributes = () => {
// we get the data using a custom hook
// we will update this implementation after learning about app-runtime
- const { loading, error, data } = useGetAttributes()
+ const { loading, error, data} = useDataQuery(query)
+
+ if (loading) {
+ return (
+
+
+
+ )
+ }
+
+ if (error) {
+ return {error?.message}
+ }
return (
Attributes
-
loading: {JSON.stringify(loading)}
-
error message: {error?.message}
- {
- // if there is any data available
- data?.attributes?.attributes && (
-
- {JSON.stringify(data.attributes.attributes, null, 4)}
-
- )
- }
+
+
+
+
+ Name
+
+
+ Unique
+
+
+
+
+ {data?.attributesList?.attributes.map(
+ ({id, displayName, unique}) => (
+
+ {displayName}
+ {
+ unique ? 'Yes' : 'No'
+
+ }
+
+ )
+ )}
+
+
)
}
diff --git a/src/views/Form.js b/src/views/Form.js
index 1713331..d20ab35 100644
--- a/src/views/Form.js
+++ b/src/views/Form.js
@@ -1,4 +1,17 @@
-import { ReactFinalForm } from '@dhis2/ui'
+import { useAlert } from '@dhis2/app-runtime'
+import {
+ Button,
+ InputFieldFF,
+ SingleSelectFieldFF,
+ SwitchFieldFF,
+ composeValidators,
+ createEqualTo,
+ email,
+ hasValue,
+ dhis2Password,
+ dhis2Username,
+ ReactFinalForm,
+} from '@dhis2/ui'
import React from 'react'
import styles from './Form.module.css'
@@ -15,31 +28,134 @@ import styles from './Form.module.css'
* @param {string} values.email-confirmation
* @param {bool} values.newsletter
*/
-const alertValues = (values) => {
- const formattedValuesString = JSON.stringify(values, null, 2)
- alert(formattedValuesString)
-}
+//const alertValues = (values) => {
+// const formattedValuesString = JSON.stringify(values, null, 2)
+// alert(formattedValuesString)
+//}
const { Field, Form: RFForm } = ReactFinalForm
-export const Form = () => (
-
-
Form
-
-
- {({ handleSubmit }) => (
-
- )}
-
-
-)
+export const Form = () => {
+ const { show } = useAlert((values) => {
+ if(values.title === 'prof') {
+ return `All good ${values.firstname}`
+ }
+ return 'All is goods'
+ }, (values) => {
+ if(values.title !== 'prof') {
+ return {
+ warning: true
+ }
+ }
+ return {
+ critical: true
+ }
+ })
+
+ const alertValues = (values) => {
+ show(values)
+ }
+
+ return (
+
+
Form
+
+
+ {({ handleSubmit }) => (
+
+ )}
+
+
+ )
+}
diff --git a/src/views/Home.js b/src/views/Home.js
index 76ef507..a38e490 100644
--- a/src/views/Home.js
+++ b/src/views/Home.js
@@ -1,9 +1,17 @@
+import {useConfig} from '@dhis2/app-runtime'
+import i18n from '@dhis2/d2-i18n'
+import {Tag} from '@dhis2/ui'
import React from 'react'
-export const Home = () => (
-
-
Home
+export const Home = () => {
+ const config = useConfig()
+ return (
+
+
{i18n.t("Home")}
-
DHIS2 Web App Academy 2024
-
-)
+
{i18n.t("DHIS2 Web App Academy 2024")}
+
+
{i18n.t("Running on DHIS2 API version")} {config.apiVersion}
+
+ )
+}