@openmrs/esm-styleguide 6.0.1-pre.2569 → 6.0.1-pre.2575

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,4 +45,4 @@ WARNING in webpack performance recommendations:
45
45
  You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
46
46
  For more info visit https://webpack.js.org/guides/code-splitting/
47
47
 
48
- webpack 5.88.0 compiled with 3 warnings in 29884 ms
48
+ webpack 5.88.0 compiled with 3 warnings in 28662 ms
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-styleguide",
3
- "version": "6.0.1-pre.2569",
3
+ "version": "6.0.1-pre.2575",
4
4
  "license": "MPL-2.0",
5
5
  "description": "The styleguide for OpenMRS SPA",
6
6
  "browser": "dist/openmrs-esm-styleguide.js",
@@ -63,12 +63,12 @@
63
63
  "rxjs": "6.x"
64
64
  },
65
65
  "devDependencies": {
66
- "@openmrs/esm-error-handling": "6.0.1-pre.2569",
67
- "@openmrs/esm-extensions": "6.0.1-pre.2569",
68
- "@openmrs/esm-navigation": "6.0.1-pre.2569",
69
- "@openmrs/esm-react-utils": "6.0.1-pre.2569",
70
- "@openmrs/esm-state": "6.0.1-pre.2569",
71
- "@openmrs/esm-translations": "6.0.1-pre.2569",
66
+ "@openmrs/esm-error-handling": "6.0.1-pre.2575",
67
+ "@openmrs/esm-extensions": "6.0.1-pre.2575",
68
+ "@openmrs/esm-navigation": "6.0.1-pre.2575",
69
+ "@openmrs/esm-react-utils": "6.0.1-pre.2575",
70
+ "@openmrs/esm-state": "6.0.1-pre.2575",
71
+ "@openmrs/esm-translations": "6.0.1-pre.2575",
72
72
  "@types/geopattern": "^1.2.9",
73
73
  "autoprefixer": "^9.8.8",
74
74
  "css-minimizer-webpack-plugin": "^1.2.0",
@@ -35,14 +35,25 @@ const GenderIcon = ({ gender }: GenderIconProps) => {
35
35
  return <IconComponent fill="#525252" />;
36
36
  };
37
37
 
38
- const getGender = (gender: string): string => {
39
- const key = gender.toLowerCase() as Gender;
40
- return getCoreTranslation(key, gender);
38
+ const GENDER_MAP = {
39
+ male: 'Male',
40
+ female: 'Female',
41
+ other: 'Other',
42
+ unknown: 'Unknown',
43
+ } as const;
44
+
45
+ const getGender = (gender: string) => {
46
+ const normalizedGender = gender.toLowerCase() as Gender;
47
+ const iconKey = GENDER_MAP[normalizedGender] ?? 'Unknown';
48
+ return {
49
+ displayText: getCoreTranslation(normalizedGender, gender),
50
+ iconKey,
51
+ };
41
52
  };
42
53
 
43
54
  export function PatientBannerPatientInfo({ patient }: PatientBannerPatientInfoProps) {
44
55
  const name = `${patient?.name?.[0]?.given?.join(' ')} ${patient?.name?.[0]?.family}`;
45
- const gender = patient?.gender && getGender(patient.gender);
56
+ const genderInfo = patient?.gender && getGender(patient.gender);
46
57
 
47
58
  const extensionState = useMemo(() => ({ patientUuid: patient.id, patient }), [patient.id, patient]);
48
59
 
@@ -52,10 +63,10 @@ export function PatientBannerPatientInfo({ patient }: PatientBannerPatientInfoPr
52
63
  <div className={styles.flexRow}>
53
64
  <span className={styles.patientName}>{name}</span>
54
65
 
55
- {gender && (
66
+ {genderInfo && (
56
67
  <div className={styles.gender}>
57
- <GenderIcon gender={gender as keyof typeof GENDER_ICONS} />
58
- <span>{gender}</span>
68
+ <GenderIcon gender={genderInfo.iconKey} />
69
+ <span>{genderInfo.displayText}</span>
59
70
  </div>
60
71
  )}
61
72
 
@@ -74,4 +74,16 @@ describe('PatientBannerPatientInfo', () => {
74
74
  expect(screen.getByText(/national id/i)).toBeInTheDocument();
75
75
  expect(screen.getByText(/123456789/i)).toBeInTheDocument();
76
76
  });
77
+
78
+ it('renders the correct gender icon based on patient gender', () => {
79
+ render(<PatientBannerPatientInfo patient={mockPatient} />);
80
+
81
+ expect(screen.getByText('', { selector: 'use[href="#omrs-icon-gender-male"]' })).toBeInTheDocument();
82
+
83
+ const patientWithUnknownGender = { ...mockPatient, gender: 'unknown' };
84
+
85
+ render(<PatientBannerPatientInfo patient={patientWithUnknownGender} />);
86
+
87
+ expect(screen.getByText('', { selector: 'use[href="#omrs-icon-gender-unknown"]' })).toBeInTheDocument();
88
+ });
77
89
  });