Skip to content

Provider profile and users dev#158

Merged
Riyad-Murad merged 2 commits intostagingfrom
provider_profile_and_users_dev
May 19, 2025
Merged

Provider profile and users dev#158
Riyad-Murad merged 2 commits intostagingfrom
provider_profile_and_users_dev

Conversation

@Riyad-Murad
Copy link
Owner

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

Summary by Sourcery

Revamp provider and client forecast pages by standardizing styling and layout with reusable ActionButton components, refactor data fetching into service hooks that manage loading state, enhance AI prompt formatting for structured JSON outputs, and update project documentation with refreshed diagrams and feature descriptions

New Features:

  • Add ActionButton component with support for CSS classes and conditional inline styling
  • Expose fetchProviderPredictionReport and fetchPowerPlanReport service methods that handle loading state internally

Enhancements:

  • Refactor Provider and Client power pages to a unified header–card–grid layout with generate/download actions and loading overlays
  • Standardize CSS naming conventions and theme across provider and client modules, applying consistent container, card, grid, and button styles
  • Move loading state toggling into service hooks, simplifying component logic in pages
  • Revise AI prompt builders for provider and client to enforce a strict JSON output structure and clearer section guidelines

Documentation:

  • Update README with new component and flow diagrams, remove outdated credentials list, and refine feature descriptions

@sourcery-ai
Copy link

sourcery-ai bot commented May 19, 2025

Reviewer's Guide

This PR standardizes and modernizes the provider and client power report modules by refactoring CSS naming and layouts, migrating fetch and loading logic into service hooks, integrating a reusable ActionButton, updating AI prompt templates for structured JSON output, and reorganizing project documentation.

Sequence Diagram for Provider Power Forecast Generation

sequenceDiagram
    actor Provider
    Provider->>ProviderPowerPredictionPage: Interacts with page
    ProviderPowerPredictionPage->>ActionButton: Clicks "Generate Forecast"
    ActionButton->>ProviderPowerPredictionPage: Calls onClick handler (fetchProviderPredictionReport)
    ProviderPowerPredictionPage->>ProviderPredictionService: fetchProviderPredictionReport(userId, setReportData)
    ProviderPredictionService->>ReduxStore: dispatch(toggleLoad(true))
    ProviderPredictionService->>BackendAPI: GET /providers/providerReport/{userId}
    BackendAPI-->>ProviderPredictionService: Forecast Data / Error
    alt Forecast Successful
        ProviderPredictionService->>ProviderPowerPredictionPage: setReportData(data)
    else Forecast Failed
        ProviderPredictionService->>ProviderPowerPredictionPage: setReportData(null)
        ProviderPredictionService->>Console: logs error
    end
    ProviderPredictionService->>ReduxStore: dispatch(toggleLoad(false))
    ProviderPowerPredictionPage-->>Provider: Displays Forecast Data or Loading/Error
Loading

Sequence Diagram for Client Power Plan Generation

sequenceDiagram
    actor Client
    Client->>ClientPowerPlanPage: Interacts with page
    ClientPowerPlanPage->>ActionButton: Clicks "Generate My Plan"
    ActionButton->>ClientPowerPlanPage: Calls onClick handler (fetchPowerPlanReport)
    ClientPowerPlanPage->>ClientPowerPlanService: fetchPowerPlanReport(userId, setReportData)
    ClientPowerPlanService->>ReduxStore: dispatch(toggleLoad(true))
    ClientPowerPlanService->>BackendAPI: GET /clients/clientReport/{userId}
    BackendAPI-->>ClientPowerPlanService: Plan Data / Error
    alt Plan Successful
        ClientPowerPlanService->>ClientPowerPlanPage: setReportData(data)
    else Plan Failed
        ClientPowerPlanService->>ClientPowerPlanPage: setReportData(null)
        ClientPowerPlanService->>Console: logs error
    end
    ClientPowerPlanService->>ReduxStore: dispatch(toggleLoad(false))
    ClientPowerPlanPage-->>Client: Displays Plan Data or Loading/Error
Loading

Class Diagram for Updated Provider Power Prediction Feature

classDiagram
  class ProviderPowerPrediction {
    <<Component>>
    -reportData: Object
    -loading: Boolean
    -userId: String
    +constructor()
    +render()
  }
  ProviderPowerPrediction --|> React.Component
  ProviderPowerPrediction ..> ActionButton : uses
  ProviderPowerPrediction ..> ProviderPredictionService_Hook : uses "fetchProviderPredictionReport()"

  class ActionButton {
    <<Component>>
    +text: String
    +className: String  // New prop
    +onClick: Function
    +backgroundColor: String
    +color: String
    +width: String
    +margin: String
    -useInlineStyles: Boolean // New internal logic
    +constructor()
    +render()
  }
  ActionButton --|> React.Component

  class ProviderPredictionService_Hook {
    <<Hook>>
    +fetchProviderPredictionReport(userId, setReportData): Promise~void~ // Logic moved here
  }
  ProviderPredictionService_Hook ..> ReduxStore : dispatches toggleLoad
  ProviderPredictionService_Hook ..> BackendAPI : GET /providers/providerReport/{userId}

  class ReduxStore {
    <<Store>>
    +loadingState: Boolean
    +toggleLoad(Boolean)
  }
  class BackendAPI {
    <<Service>>
    +providerReport(userId): Promise~JSON~
  }
Loading

Updated Class Diagram for ClientPrompt Utility (PHP)

classDiagram
  class ClientPrompt {
    <<Utility>>
    +static clientBuildPromptFromMetrics(slaveId): string // Prompt template updated for JSON output
  }
Loading

File-Level Changes

Change Details Files
Refactor and standardize CSS for provider and client report pages
  • Renamed classes with uniform 'provider-' and 'client-' prefixes
  • Adjusted container padding, backgrounds, margins, and border-radii
  • Introduced card, grid, and overlay layouts with shadows and keyframes
  • Unified action button and spinner styling
amp-client/src/Pages/ProviderPages/ProviderPowerPrediction/styles.css
amp-client/src/Pages/ClientPages/ClientPowerPlan/styles.css
Refactor ProviderPowerPrediction component to use service hook and ActionButton
  • Removed manual dispatch in component and delegated loading to fetchProviderPredictionReport service
  • Replaced buttons with ActionButton for generate and download actions
  • Reorganized JSX into header, generate card, loading overlay, and detailed report sections
  • Renamed state from predictionData to reportData
amp-client/src/Pages/ProviderPages/ProviderPowerPrediction/ProviderPowerPrediction.jsx
Refactor ClientPowerPlan component with ActionButton and service abstraction
  • Integrated ActionButton for generate and download actions
  • Restructured component JSX into header, generate card, loading overlay, and report card
  • Leveraged fetchPowerPlanReport service and userId from Redux
  • Managed reportData and loading states consistently
amp-client/src/Pages/ClientPages/ClientPowerPlan/ClientPowerPlan.jsx
Reorganize and update project README content
  • Replaced and repositioned ERD, component diagram, and flow diagram sections
  • Streamlined system highlights and feature descriptions
  • Refined markdown formatting and headings
  • Reintroduced default test user data at end
README.md
Enhance AI prompt templates to enforce structured JSON output
  • Updated instruction text sections with explicit JSON schema fields
  • Added example JSON structure in prompts
  • Removed obsolete commented code blocks
amp-laravel/app/Utils/ClientPrompt.php
amp-laravel/app/Utils/ProviderPrompt.php
Extend ActionButton component to support className and conditional styling
  • Added className prop and useInlineStyles flag
  • Applied inline styles only when no className is provided
  • Preserved width and margin props for backwards compatibility
amp-client/src/Components/CommonComponents/ActionButton/ActionButton.jsx
Convert ProviderPowerPredictionService into hook with integrated loading logic
  • Changed default export to a hook returning fetchProviderPredictionReport
  • Used Redux dispatch(toggleLoad) inside service for loading state
  • Bound userId parameter in endpoint URL and setReportData callback
amp-client/src/Pages/ProviderPages/Services/ProviderPowerPredictionService/ProviderPowerPredictionService.js

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 239c1ba into staging May 19, 2025
1 check passed
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