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

Fixes greyed out 'Active Manage Bed' button in Location Management Page #8814 #8827

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

abhip161
Copy link
Contributor

Proposed Changes

image

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

@abhip161 abhip161 requested a review from a team as a code owner October 18, 2024 13:54
Copy link

netlify bot commented Oct 18, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit e3515fb
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67188da2a2c63a0008927e50
😎 Deploy Preview https://deploy-preview-8827--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@rithviknishad rithviknishad left a comment

Choose a reason for hiding this comment

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

isn't this the proper fix?

@@ -289,7 +289,7 @@ const Location = ({
border
className={cn(
"mt-3 flex w-full items-center justify-between",
totalBeds != null && "opacity-50",
totalBeds != null && "opacity-100",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
totalBeds != null && "opacity-100",
totalBeds == null && "opacity-50",

Copy link
Contributor Author

@abhip161 abhip161 Oct 18, 2024

Choose a reason for hiding this comment

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

hey @rithviknishad
if opacity-50 manage bed button will greyed out

if you want
opacity behaves correctly based on the totalBeds condition ??

When totalBeds is null, the button will have opacity-50, making it look greyed out.

When totalBeds has a value, the button will display with opacity-100, appearing fully visible.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should disable the button, why hack the class? Set disabled: true?

@rithviknishad rithviknishad added the question Further information is requested label Oct 18, 2024
@bodhish bodhish removed the question Further information is requested label Oct 21, 2024
@abhip161
Copy link
Contributor Author

Hey @bodhish ,
Could you please take a look at this asset?

Screen.Recording.2024-10-21.114442.mp4

Let me know if it can be modified or improved. Thanks!

@rithviknishad
Copy link
Member

rithviknishad commented Oct 21, 2024

The button seems to be disabled if beds count is 0. How would I be able to add a bed for that location now?

null/undefined means data is still being fetched.
0 means no bed.

we should disable only for null/undefined right?

@abhip161
Copy link
Contributor Author

Hey @rithviknishad ,
I’ve updated the code to disable the button only when totalBeds is null or undefined,
.Please check it out!

image

@rithviknishad
Copy link
Member

Now that it's disabled if null, we don't need to add conditional classes like @bodhish suggested right?

@abhip161
Copy link
Contributor Author

hey @rithviknishad ,
I see your point about simplifying the classes since the button is disabled when totalBeds is null. However, I think keeping the conditional classes for opacity is helpful for providing visual feedback. It allows users to see that the button is inactive (with reduced opacity) when there are no beds available, enhancing usability.

But I'm open to further discussion if you think a simpler approach would be better. Let me know your thoughts!

@rithviknishad
Copy link
Member

rithviknishad commented Oct 21, 2024

The ButtonV2 component already applies necessary classes for it when disabled.

https://github.com/ohcnetwork/care_fe/blob/develop/src/Components/Common/components/ButtonV2.tsx#L101

@abhip161
Copy link
Contributor Author

hey @rithviknishad ,
Thanks for pointing that out! the ButtonV2 component already handles the necessary styles when it's disabled
I’ll update the code accordingly to rely on the built-in styles from ButtonV2. Thanks for your guidance!
image

@samholics
Copy link

Tested working fine @nihal467

@nihal467
Copy link
Member

LGTM

src/Components/Facility/LocationManagement.tsx Outdated Show resolved Hide resolved
)}
href={`location/${id}/beds`}
className={cn("mt-3 flex w-full items-center justify-between")}
href={totalBeds != null ? `location/${id}/beds` : undefined}
Copy link
Member

Choose a reason for hiding this comment

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

Intresting, why are we having a button when its a link 🤔

Copy link
Member

Choose a reason for hiding this comment

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

@bodhish the button component does wrap it in a Link component if href is present

image

@abhip161
Copy link
Contributor Author

hey @rithviknishad could you check this out?
Screenshot 2024-10-22 143024
why are we having a button when its a link ??
mentioned that we're using a button, but it's meant for navigation (like a link). Should we wrap it inside a component instead of using directly?

@abhip161
Copy link
Contributor Author

abhip161 commented Oct 22, 2024

hey @rithviknishad
Since ButtonV2 automatically handles the link behavior when href is provided,
don't need to manually wrap the button in a Link

image

<ButtonV2 id="manage-bed-button" variant="secondary" border className="mt-3 flex w-full items-center justify-between" href={location/${id}/beds} disabled={totalBeds == null} > Manage Beds <span className="flex items-center justify-center gap-2"> <CareIcon icon="l-bed" className="text-lg" /> {totalBeds ?? "--"} </span> </ButtonV2>

Let me know if this looks good!

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Oct 23, 2024
Copy link

👋 Hi, @abhip161,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@bodhish bodhish added reviewed reviewed by a core member and removed needs review labels Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge conflict pull requests with merge conflict reviewed reviewed by a core member tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Active Manage Bed button in Location Management Page is greyed out
5 participants