@pfba_spartaxx/documents-ui
v1.0.15
Published
A lightweight, premium React library for managing Spartaxx documents with clean architecture, scoped CSS, and environment-aware API configuration.
Readme
Spartaxx Documents UI Package
A lightweight, premium React library for managing Spartaxx documents with clean architecture, scoped CSS, and environment-aware API configuration.
🚀 Installation
Install the package via npm:
npm install @pfba_spartaxx/documents-uiPeer Dependencies: Ensure you have the following installed in your host project:
react&react-dom(>= 17.0.0)axiosreact-bootstrapreact-icons
🛠️ Usage
1. Global Configuration
Wrap your application (or the specific layout) with the DocumentProvider. This sets up the environment and user context globally.
import { DocumentProvider } from '@pfba_spartaxx/documents-ui';
import '@pfba_spartaxx/documents-ui/style.css'; // Import the scoped styles
const config = {
mode: 'uat', // 'uat' | 'prod'
user: {
userId: 1234,
clientId: 5678,
clientNumber: 'C1001',
userName: 'John Doe'
},
// Optional: Override specific API URLs if needed
overrides: {
spartaxxApi: 'https://custom-api.com'
}
};
function App() {
return (
<DocumentProvider config={config}>
<YourDashboard />
</DocumentProvider>
);
}2. Rendering Documents
Use the PackageDocumentsContainer to handle data readiness checks automatically. It will show a loading spinner until both clientData and user context are ready.
import { PackageDocumentsContainer } from '@pfba_spartaxx/documents-ui';
const DocumentsView = ({ rowData }) => {
return (
<div className="my-container">
<PackageDocumentsContainer
clientData={rowData}
initialTab="Required"
/>
</div>
);
};🔍 API Configuration
The package automatically routes requests based on the mode provided in the config:
| Environment | Spartaxx API | Customer API | PaperWise API |
| :--- | :--- | :--- | :--- |
| UAT | spartaxxv2uatapi.poconnor.com | uat-pfbaapi.spartaxx.com | uat-pwapi.spartaxx.com |
| PROD | hubapi.spartaxx.com | pfbaapi.spartaxx.com | pwapi.spartaxx.com |
🛠️ Local Development & Testing
To test changes locally without publishing to npm:
In this package directory:
npm run build npm linkIn your host application:
npm link @pfba_spartaxx/documents-uiTo update after changes: Simply run
npm run buildin the library; the host app will reflect changes via the link.
📑 Features & Architecture
- Clean logic: No legacy cookie or sessionStorage hacks.
- CSS Isolation: All classes prefixed with
spx-to avoid layout breaks in the host app. - Detailed Logging: Every API call, payload, and response is logged with
[SPX-DOCS-UI]prefix for easy debugging in the console. - Responsive Design: Mobile-friendly tab system and sticky action footers.
