From 9c7cea2b8474f20f8ebc8c1a671ad8bff7f3605c Mon Sep 17 00:00:00 2001 From: kmartial Date: Tue, 16 Apr 2024 16:34:07 +0000 Subject: [PATCH] Task 3 Form --- src/navigation/Navigation.js | 8 ++- src/views/Attributes.js | 29 +++++++++- src/views/Form.js | 104 +++++++++++++++++++++++++++++++++-- src/views/Form.module.css | 4 ++ 4 files changed, 137 insertions(+), 8 deletions(-) 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..d919a7a 100644 --- a/src/views/Form.js +++ b/src/views/Form.js @@ -1,4 +1,5 @@ -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' @@ -11,10 +12,12 @@ 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) @@ -29,15 +32,108 @@ export const 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; }