ubkerp.transport.module
v0.1.1
Published
UBK ERP reusable Transport Module for React Native apps
Downloads
32
Maintainers
Readme
ubkerp.transport.module
Reusable React Native Transport Module for UBKERP (UBK INFOTECH PVT LTD). This package keeps authentication external and makes API + UI reusable.
Setup (library)
cd transport-module
npm i
npm run buildInstall (consumer app)
npm i ubkerp.transport.moduleUsage
A) Direct token
<TransportProvider apiBaseUrl="https://domain.com/api" authToken={token}>
<StudentRouteDetailsScreen />
</TransportProvider>B) Async token callback (recommended)
<TransportProvider
apiBaseUrl="https://domain.com/api"
getAuthToken={async () => {
return await AsyncStorage.getItem('token');
}}>
<StudentRouteDetailsScreen />
</TransportProvider>C) Custom headers (optional)
<TransportProvider
apiBaseUrl="https://domain.com/api"
headers={{
Authorization: token,
}}>
<StudentRouteDetailsScreen />
</TransportProvider>API Configuration
TransportProvider configures a dedicated Axios instance:
- Dynamic
apiBaseUrl - Dynamic headers (static
headers+ token injection) - Axios interceptors
- Token refresh support (optional
refreshAuthToken) - Retry mechanism (configurable via
retry) - Global API error handling (optional
onApiError)
Exports
export {
TransportProvider,
useTransport,
TransportDashboard,
StudentRouteDetailsScreen,
} from '@ubkerp/transport-module';Example
Use the screen exports in your consumer app navigation.
Migration Strategy (incremental)
This library is designed to migrate your existing Transport module without rewriting the business logic.
Current Source Files (in ERP app)
src/screens/TransportRoute/TransportRoute.jsx→ dashboard/hub UIsrc/screens/TransportRoute/RouteTransport.jsx→ student route details UI + API callsrc/screens/TransportRoute/TransportFee.jsx→ transport fee UI + receipts (large; migrate after RouteDetails)src/api/fee_show_data.js→fee_show_data2()transport fee APIsrc/api/apiService.js→ generic GET/POST wrapperssrc/styles/TransportRoute/TransportRoute.styles.jsx→ stylessrc/routes/StackNavigator.js→ navigation registration (must stay in consumer app)
Move Order (recommended)
- Services first (no UI)
- Move API calls into
transport-module/src/services/** - Keep endpoints unchanged; only remove hardcoded
API_BASE_URLusage
- Types
- Introduce strong TypeScript models in
transport-module/src/types/**
- Provider
- Add
TransportProviderto replace internal AuthContext dependency
- Screens
- Move screens into
transport-module/src/screens/** - Remove
useNavigation()from screens; expose callbacks/props instead
- Shared UI components
- Extract cards, loading/empty/error states into
src/components/**
Refactoring Needed (safe + minimal)
- Replace
API_BASE_URLimports withTransportProvider(apiBaseUrl) - Replace AuthContext with external token injection (
authToken/getAuthToken/headers) - Keep request paths identical (example:
/student/studentAPP/TransportDetails/studentRoutedetails)
Dependency Mapping (Transport module)
- Must be provided by consumer (peer deps):
react,react-native - Included by library:
axios - Optional consumer-level dependencies depending on migrated screens:
- If you keep
native-base,react-native-fast-image,@fortawesome/*, they should be added as peerDependencies later when those screens are migrated
- If you keep
Breaking Changes Prevention
- Preserve endpoint paths and payload shapes
- Avoid changing response parsing; wrap only for reusability
- Keep UI props backward compatible by adding optional props instead of changing required ones
Next Modules (planned)
- Transport Fee (fee_show_data2 + TransportFee screen)
- Vehicle / Driver / Route management (if present in ERP app)
- Pickup point + allocation screens
- GPS tracking + bus attendance + reports
