Skip to content

Feat/pocd 355 add instruction component - #202

Merged
edwin-joseph-cko merged 29 commits into
epic/POCD-348-apm-sdkfrom
feat/POCD-355-add-instruction-component
Jul 18, 2025
Merged

Feat/pocd 355 add instruction component#202
edwin-joseph-cko merged 29 commits into
epic/POCD-348-apm-sdkfrom
feat/POCD-355-add-instruction-component

Conversation

@edwin-joseph-cko

@edwin-joseph-cko edwin-joseph-cko commented Jul 14, 2025

Copy link
Copy Markdown
Contributor

Description

This PR enhances the existing APM system by introducing a comprehensive StateManager and improving the overall architecture. Building upon the foundation established in previous PRs, this update adds centralised state management and enhances the developer experience.

The changes address specific limitations in the current APM implementation:

  • Lack of centralised state management across components
  • Inconsistent re-rendering behaviour when state changes
  • Limited component reusability and state persistence
  • Poor developer experience with complex state synchronisation

Solution

🏗️ StateManager System

  • Centralized State Management: Introduced a singleton StateManager with React-like hooks (useComponentState)
  • Automatic Re-rendering: State changes trigger parent view updates automatically
  • Batched Updates: Multiple state changes in one frame result in a single re-render
  • Lifecycle Management: Automatic cleanup when views unmount, preventing memory leaks
  • IE 11 Compatibility: Full support for legacy browsers with polyfills

🎨 New UI Components

  • CancelButton: Dedicated component for payment cancellation flow
  • StatusTick: Visual indicator for payment status (pending/completed/idle)
  • CancelRequest View: Confirmation screen for payment cancellation

🔄 API & Polling Improvements

  • Polling Cancellation: Added proper cancellation support with POLLING_CANCELLED flag
  • State Persistence: Better handling of pending payment states across sessions
  • Type Safety: Improved TypeScript types with conditional types and utility types
  • Flow-specific Logic: Enhanced getCurrentStep method for different payment flows

📚 Documentation & Examples

  • Comprehensive Documentation: Added detailed guides for StateManager usage
  • Migration Guide: Step-by-step instructions for adopting new patterns
  • Updated Examples: Enhanced examples demonstrating new state management patterns

Demo

Sequence.01.mp4

Checklist

  • I bumped the version of the project using yarn bump-version
  • I have checked the code for any potential issues
  • I tested my changes in the browser

Notes

Breaking Changes

This PR introduces architectural improvements that enhance the existing APM system:

  • State Management: Components now use StateManager instead of manual state handling
  • Event Handling: Some event patterns have been updated for better consistency
  • API Changes: Polling behaviour has been improved with cancellation support

Migration Path

A comprehensive migration guide is provided in docs/migration-guide-native-apm-to-apm.md that covers:

  • Adopting new state management patterns
  • Component lifecycle management best practices
  • Event handling updates

Performance Improvements

  • Batched Updates: Reduced unnecessary re-renders through intelligent batching
  • Memory Management: Automatic cleanup prevents memory leaks
  • Efficient Polling: Better cancellation support reduces unnecessary API calls

Browser Compatibility

  • IE 11 Support: Full compatibility maintained with polyfills
  • Modern Browsers: Enhanced performance and features for modern browsers

Jira Issue

POCD-355 - Add instruction components and improve APM architecture

- Add StateManager class with singleton pattern for global state management
- Implement useComponentState hook for React-like state management
- Add component lifecycle management and automatic cleanup
- Include comprehensive documentation and migration guide
- Support IE 11 compatibility with batched updates
- Add TypeScript support with generic state types
- Add CancelButton element for payment cancellation
- Add StatusTick element for displaying payment status
- Add CancelRequest view for payment cancellation confirmation
- Support cancel event emission and navigation
- Integrate with existing APM event system
- Simplify FormFieldResult type using conditional types
- Add Prettify helper type for better IntelliSense
- Improve type safety with TransformFormField utility
- Clean up type definitions for better maintainability
- Remove duplicate type definitions
- Add POLLING_CANCELLED flag for proper polling control
- Implement polling cancellation in API methods
- Add hasReturnedFirstPending flag for better state tracking
- Improve getCurrentStep method with flow-specific logic
- Add pending state persistence in storage
- Clean up pending state on success
- Improve type safety in Context configuration
- Migrate all APM elements to use new StateManager system
- Replace manual DOM manipulation with declarative state management
- Add useComponentState hooks to all interactive elements
- Improve element lifecycle management and cleanup
- Enhance type safety across all element components
- Standardize element state management patterns
- Update all APM views to work with new StateManager system
- Improve view rendering with declarative component patterns
- Add support for new cancel functionality in views
- Update form utilities to work with new state management
- Enhance render-elements utility for better component integration
- Update Main layout to support new UI components
- Improve view lifecycle management and state persistence
- Update Page class to support new StateManager integration
- Enhance Theme system for better component styling
- Improve utility functions for new state management patterns
- Update references to include new components and types
- Enhance event listener system for better state synchronization
- Update main APM index to export new functionality
- Improve core infrastructure for better component lifecycle management
- Update APM UI system documentation to reflect new StateManager
- Enhance migration guide with new component patterns
- Update example to demonstrate new state management
- Document new cancel functionality and UI components
- Improve developer experience with better examples and guides
… management

- Add flexbox layout to the container in Theme for better spacing
- Update NextStepProps to support multiple config types and refactor state management functions
- Remove unused button in Success view for cleaner UI
- Eliminate OTP state clearing in form submission for better state handling
@edwin-joseph-cko
edwin-joseph-cko force-pushed the feat/POCD-355-add-instruction-component branch from 733629c to 0cb952f Compare July 14, 2025 13:15
- Replace interface definitions with type aliases for Authorization and Tokenization response types
- Enhance type definitions for better readability and maintainability
- Minor formatting fix in Components.ts for consistency
…ps view

- Update setFormState function to return null for improved type safety
- Capture form state in a local variable for better readability during submission
- Refactor error handling in render method for clearer logic
@edwin-joseph-cko
edwin-joseph-cko force-pushed the feat/POCD-355-add-instruction-component branch from 43e5aa7 to fa24b2c Compare July 14, 2025 13:52
@edwin-joseph-cko
edwin-joseph-cko marked this pull request as ready for review July 16, 2025 14:22
…erience

- Update APM index to include new Forage authorization and tokenization options
- Refactor API response types to support redirect state handling
- Improve error handling and state management in API methods
- Enhance theme system for better color scheme support and dynamic styling
- Update form utilities to prevent unnecessary re-renders and improve performance
- Refactor layout components to support new responsive design patterns
- Add support for new HTML elements in APM views for better accessibility
…direct

- Emit events for redirect initiation and completion to enhance tracking
- Implement error handling for redirect failures with detailed error information
- Simplify cancel button logic in the render method for better clarity
Base automatically changed from feat/POCD-363-add-select to epic/POCD-348-apm-sdk July 17, 2025 13:15

@adam-kazmierczak-cko adam-kazmierczak-cko left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

After reviewing about 20%, I feel I am done 🙈

I would rather test this as there's so much code, it would take me more time to review than it took you to write it

I think its way too much in one go

@edwin-joseph-cko
edwin-joseph-cko merged commit d7ec5c8 into epic/POCD-348-apm-sdk Jul 18, 2025
2 checks passed
@edwin-joseph-cko
edwin-joseph-cko deleted the feat/POCD-355-add-instruction-component branch July 18, 2025 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants