Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance <LabelValue /> component to display formatted values based on data type #254

Open
sudhacheran opened this issue Dec 18, 2024 · 1 comment

Comments

@sudhacheran
Copy link
Collaborator

sudhacheran commented Dec 18, 2024

Enhance the existing <LabelValue /> component to dynamically format and display values based on their data type. The component should accept the following props:

The component should accept the following props:
value (optional): The data to be displayed.
type (required): The type of the data (string, number, date, or boolean).
label (optional): A label to display alongside the value.
path (optional): The path in the data object (from DB) where the value can be found.
decimalPlaces (optional, default: 1): The number of decimal places to use when formatting numeric values.
prefix (optional): A string to prepend to the value (e.g., a currency symbol).
suffix (optional): A string to append to the value (e.g., a percentage symbol).

The component should handle various data types such as strings, numbers, dates, and booleans, and render them appropriately (e.g., numbers with decimal places, dates in a readable format, booleans as 'Yes'/'No')

Functional details
Strings: Display the value as is, or show '' (nothing) if the string is empty, null, or undefined.
Numbers: Apply the specified number of decimal places.
Dates: Display the date in a readable format (e.g., MM/DD/YYYY)
Booleans: Show 'Yes' for true and 'No' for false
Optional prefix and suffix:
For all data types, support optional prefix and suffix props. These can be used to add additional context around the value (e.g., currency symbol or unit symbols).

Unit Testing
Test the component with various data types (strings, numbers, dates, booleans) and verify the correct rendering of values.
Ensure the component behaves correctly when value is null, undefined, or empty.
Validate that decimalPlaces, prefix, and suffix are applied correctly.

@sudhacheran
Copy link
Collaborator Author

All the templates need to be updated to include this new component instead of handling it manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant