Skip to content

Staging#167

Merged
Riyad-Murad merged 2 commits intomainfrom
staging
May 20, 2025
Merged

Staging#167
Riyad-Murad merged 2 commits intomainfrom
staging

Conversation

@Riyad-Murad
Copy link
Owner

@Riyad-Murad Riyad-Murad commented May 20, 2025

Summary by Sourcery

Enable providers to edit their profiles via a revamped UI that validates inputs, filters empty fields, and shows success or error toasts before redirecting. Introduce a dropdown-based ProfileMenu in the sidebar and update styles. Also refine README diagrams and add API reference.

New Features:

  • Add editable provider profile form with controlled InputField and ActionButton components
  • Introduce ProviderProfileService to update profile with toast notifications and post-update navigation
  • Implement ProfileMenu dropdown in sidebar for profile access and logout

Bug Fixes:

  • Fix provider report API endpoint by removing unnecessary userId parameter

Enhancements:

  • Refactor provider profile page layout and styling
  • Filter out empty fields before sending updateProfile payload
  • Clean up InputField component by removing outdated commented code
  • Replace LogoutButton with ProfileMenu in the provider sidebar

Documentation:

  • Update README with renamed diagrams, add 'Remarkable Features' section and Postman API documentation link

Riyad-Murad and others added 2 commits May 20, 2025 03:31
provider_profile_and_user_dev: Added ProviderProfile Component Code a…
@sourcery-ai
Copy link

sourcery-ai bot commented May 20, 2025

Reviewer's Guide

This PR revamps the provider profile feature by replacing static markup with a dynamic, state-driven form and a dedicated service for updates, introduces a new ProfileMenu for user actions, cleans up redundant code, fixes a prediction service endpoint, and reorganizes documentation sections and diagrams.

File-Level Changes

Change Details Files
Refactored ProviderProfile component to a controlled form with service integration
  • Added form state, handleChange, and handleSubmit hooks
  • Replaced static inputs with InputField and ActionButton components
  • Connected updateProfile call to ProviderProfileService
  • Updated markup classes and structure for layout
amp-client/src/Pages/ProviderPages/ProviderProfile/ProviderProfile.jsx
amp-client/src/Pages/ProviderPages/ProviderProfile/styles.css
Implemented updateProfile logic in ProviderProfileService
  • Filtered out empty fields before API request
  • Handled success and error with toast notifications
  • Redirected to dashboard on successful update
amp-client/src/Pages/ProviderPages/Services/ProviderProfile/ProviderProfile.js
Introduced ProfileMenu component for profile/logout actions
  • Created ProfileMenu with toggleable dropdown and logout hook
  • Replaced sidebar link and LogoutButton with ProfileMenu
  • Added styling for dropdown and interactive states
amp-client/src/Components/CommonComponents/ProfileMenu/ProfileMenu.jsx
amp-client/src/Components/CommonComponents/ProfileMenu/styles.css
amp-client/src/Components/ProviderComponents/ProviderSidebar/ProviderSidebar.jsx
Cleaned up InputField component by removing commented legacy code
  • Stripped out unused V2 and alternative implementations
  • Exported only the final functional component
amp-client/src/Components/CommonComponents/InputField/InputField.jsx
Fixed API endpoint in ProviderPowerPredictionService
  • Removed userId path variable from report request URL
amp-client/src/Pages/ProviderPages/Services/ProviderPowerPredictionService/ProviderPowerPredictionService.js
Reorganized README sections and updated diagrams
  • Renamed Component Diagram to System Architect Diagram
  • Added Remarkable Features and Postman API doc link
  • Reordered diagram embeds and deployment headings
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Riyad-Murad Riyad-Murad merged commit 23a22dd into main May 20, 2025
1 of 6 checks passed
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Riyad-Murad - I've reviewed your changes - here's some feedback:

  • Consider removing the large block of commented-out code in InputField.jsx to keep the component clean and maintainable.
  • The fixed 300px margin-left in your profile wrapper CSS could break across different layouts—consider using a more responsive approach (e.g., flex/grid or theme-based spacing).
  • The profile form currently allows submitting without any validation or loading feedback; adding basic client-side validation and a disabled/loading state on submit would improve the UX.
Here's what I looked at during the review
  • 🟡 General issues: 4 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.


<div className="provider-profile-card">
<h2 className="provider-profile-subtitle">Edit Provider Profile</h2>
<form className="provider-profile-form">
Copy link

Choose a reason for hiding this comment

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

suggestion (bug_risk): Attach handleSubmit to form onSubmit instead of button onClick

Also update the button to type="submit" so pressing Enter submits the form and you don’t mix click and submit events.

Suggested implementation:

          <form className="provider-profile-form" onSubmit={handleSubmit}>
            <button
              type="submit"
              className="provider-profile-submit"
            >

import ActionButton from "../../../Components/CommonComponents/ActionButton/ActionButton";

const ProviderProfile = () => {
const [formData, setFormData] = useState({
Copy link

Choose a reason for hiding this comment

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

suggestion: Profile form fields initialized as empty

Fetch existing profile data on mount to pre-fill the form and avoid forcing users to re-enter unchanged values.

name: "",
email: "",
password: "",
phone_number: "",
Copy link

Choose a reason for hiding this comment

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

suggestion: Use consistent camelCase naming for JavaScript fields

phone_number is snake_case; change it to phoneNumber and adjust the API mapping as needed.

Comment on lines +26 to +27
toast.success("Profile updated successfully.");
setTimeout(() => navigate("/provider/dashboard"), 1000);
Copy link

Choose a reason for hiding this comment

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

suggestion: Avoid setTimeout for post-update navigation

A fixed timeout can lead to inconsistent UX—navigate in the toast’s onClose callback or immediately after the success response.

Suggested change
toast.success("Profile updated successfully.");
setTimeout(() => navigate("/provider/dashboard"), 1000);
toast.success("Profile updated successfully.", {
onClose: () => navigate("/provider/dashboard"),
});

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.

1 participant