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

(refactor): KHP3 Add Dynamic Attribute Handling and enhance "Sync" & "Edit" Functionalities for Providers #565

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

its-kios09
Copy link
Collaborator

Requirements

  • This PR has a title that briefly describes the work done, including the ticket number if there is a ticket.
  • My work conforms to the OpenMRS 3.0 Styleguide.
  • I checked for feature overlap with existing widgets.

Summary

The button is enabled only if at least one of the following provider attributes has a value:

  • National ID (providerNationalId)
  • Passport Number (passPortNumber)
  • Registration Number (registrationNumber)

Dynamic Provider Payload Construction:

  • Attributes in the providerPayload are added only if the corresponding data fields are provided. And new attributes are created only if their values are not null or undefined.

Screenshots

syncandeift

None.

Related Issue

None.

Other

None.

Copy link
Collaborator

@Omoshlawi Omoshlawi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank @its-kios09 , seems good except for the small issues on translations

mutate((key) => {
return typeof key === 'string' && key.startsWith('/ws/rest/v1/provider');
});
mutate((key) => typeof key === 'string' && key.startsWith('/ws/rest/v1/provider'));
showSnackbar({
title: 'Success',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldnt it be better we made this translatable using trasnlation, simil to Failure titles?

render={({ field }) => (
<TextInput
{...field}
placeholder="License number"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make translatable

render={({ field }) => (
<TextInput
{...field}
placeholder="Registration number"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

showSnackbar({
title: 'Failure',
kind: 'error',
subtitle: t(
'errorMsg',
`Error ${provider ? 'upating' : 'creating'} provider! ${error?.responseBody?.error?.message}`,
`Error ${provider ? 'updating' : 'creating'} provider! ${error?.responseBody?.error?.message}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not going to work well. We should be using the translate third parameter e.g

  t('errorMessage' 'Error {{message}}' , {message: error.responseBody.error.message})

render={({ field }) => (
<TextInput
{...field}
id="form__national__id"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
id="form__national__id"
id="form__national__id"

We should be following standard convention here e.g formNationalId

{...field}
id="form__national__id"
placeholder={t('nationalIdPlaceholder', 'Enter National ID')}
labelText={t('nationalID', 'National ID*')}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should leverage this pattern from carbon

/>
)}
/>
)}

<Column>
<span className={styles.form__gender}>{t('gender', 'Gender*')}</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<span className={styles.form__gender}>{t('gender', 'Gender*')}</span>
<span className={styles.formGender}>{t('gender', 'Gender*')}</span>

mutate((key) => {
return typeof key === 'string' && key.startsWith('/ws/rest/v1/provider');
});
mutate((key) => typeof key === 'string' && key.startsWith('/ws/rest/v1/provider'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mutate((key) => typeof key === 'string' && key.startsWith('/ws/rest/v1/provider'));
import { restBaseUrl } from '@openmrs/esm-framework';
mutate((key) => typeof key === 'string' && key.startsWith(`restBaseUrl/provider`));

@@ -221,7 +220,9 @@ const ProviderForm: React.FC<ProvideModalProps> = ({ closeWorkspace, provider, u
person: personPayload,
roles: data.roles,
};

let _user;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets avoid naming variable like this

@@ -53,7 +57,7 @@ function CustomActionMenu({ provider }: CustomActionMenuProps) {
<OverflowMenu flipped={document?.dir === 'rtl'} aria-label="overflow-menu">
<OverflowMenuItem itemText="Edit" onClick={() => handleUpdateProvider(provider)} />
<MenuItemDivider />
<OverflowMenuItem itemText="Sync" onClick={handleOpenModal} disabled={!providerNationalId} />
<OverflowMenuItem itemText="Sync" onClick={handleOpenModal} disabled={!canSync} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<OverflowMenuItem itemText="Sync" onClick={handleOpenModal} disabled={!canSync} />
<OverflowMenuItem itemText="Sync" onClick={handleOpenModal} disabled={!isSyncEnabled} />

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

Successfully merging this pull request may close these issues.

3 participants