diff --git a/i18n/en.pot b/i18n/en.pot new file mode 100644 index 0000000..2b37f43 --- /dev/null +++ b/i18n/en.pot @@ -0,0 +1,15 @@ +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-17T09:43:15.949Z\n" +"PO-Revision-Date: 2024-04-17T09:43:15.950Z\n" + +msgid "Home" +msgstr "Home" + +msgid "DHIS2 Web App Academy 2024" +msgstr "DHIS2 Web App Academy 2024" diff --git a/src/navigation/Navigation.js b/src/navigation/Navigation.js index 38b5781..a075a06 100644 --- a/src/navigation/Navigation.js +++ b/src/navigation/Navigation.js @@ -1,5 +1,7 @@ import PropTypes from 'prop-types' import React from 'react' +import {Menu, MenuItem} from '@dhis2/ui' + // @TODO: Import the `Menu` and `MenuItem` components import { useNavigate, useMatch } from 'react-router-dom' @@ -17,7 +19,7 @@ const NavigationItem = ({ path, label }) => { const onClick = () => navigate(path) // @TODO: Use the `MenuItem` component instead of the `div` - return
{label}
+ return } NavigationItem.propTypes = { @@ -27,7 +29,7 @@ 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..2465137 100644 --- a/src/views/Attributes.js +++ b/src/views/Attributes.js @@ -1,5 +1,6 @@ import React from 'react' import { useGetAttributes } from '../hooks/index.js' +import {Table, TableHead, TableRowHead, TableCellHead, TableBody, TableRow, TableCell, TableFoot} from '@dhis2-ui/table' export const Attributes = () => { // we get the data using a custom hook @@ -15,7 +16,33 @@ export const Attributes = () => { // if there is any data available data?.attributes?.attributes && (
-                        {JSON.stringify(data.attributes.attributes, null, 4)}
+                          
+                            
+                                
+                                    
+                                        Name
+                                    
+                                    
+                                        Unique
+                                    
+                                
+                            
+                            
+                                {data.attributes.attributes.map(attr =>(
+                                    
+                                    
+                                        {attr.displayName}
+                                    
+                                    
+                                         {attr.unique ?"Yes":"No"}
+                                    
+                               
+
+                                ))}
+                            
+                            
+                        
+
) } diff --git a/src/views/Form.js b/src/views/Form.js index 1713331..5ec9be5 100644 --- a/src/views/Form.js +++ b/src/views/Form.js @@ -1,6 +1,7 @@ -import { ReactFinalForm } from '@dhis2/ui' +import { ReactFinalForm, SingleSelectFieldFF, InputFieldFF, SwitchFieldFF, hasValue, email, composeValidators, Button, createEqualTo, dhis2Username, dhis2Password} from '@dhis2/ui' import React from 'react' import styles from './Form.module.css' +import {useAlert} from '@dhis2/app-runtime' /** * This is just a function to demonstrate the values when the form is submitted @@ -11,35 +12,138 @@ import styles from './Form.module.css' * @param {string} values.title * @param {string} values.surname * @param {string} values.firstname + * @param {string} values.username * @param {string} values.email * @param {string} values.email-confirmation * @param {bool} values.newsletter */ -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 => { + return values + + }, + + ()=> { + return { + critical: true + + } + + } ) + const alertValues = (values) => { + const formattedValuesString = JSON.stringify(values, null, 2) + show(formattedValuesString) + } + + return ( +
+

Form

+ + + {({ handleSubmit }) => ( +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+
+ +
+
+ +
+ + + +
+ )} +
+
+ ) +} diff --git a/src/views/Form.module.css b/src/views/Form.module.css index e2b6665..a3acf76 100644 --- a/src/views/Form.module.css +++ b/src/views/Form.module.css @@ -19,6 +19,10 @@ flex-grow: 1; } +.username { + flex-grow: 1; +} + .email { flex-grow: 1; } diff --git a/src/views/Home.js b/src/views/Home.js index 76ef507..f7b0ede 100644 --- a/src/views/Home.js +++ b/src/views/Home.js @@ -1,9 +1,23 @@ +import {useConfig} from '@dhis2/app-runtime' +import i18n from '@dhis2/d2-i18n' import React from 'react' +import { Tag } from '@dhis2-ui/tag' -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')}

+ {/* Todo: find which UI component to use instead of h2 */} + + + Running on API version : {config.apiVersion} + +
-) + + ) + +}