@classytic/bd-areas
v1.0.0
Published
Bangladesh delivery areas with multi-provider support (RedX, Pathao, Steadfast) - 8 divisions, 64 districts, 2836+ areas
Downloads
30
Maintainers
Readme
@classytic/bd-areas
Bangladesh delivery areas with multi-provider support. Contains 8 divisions, 64 districts, and 2836 areas with provider-specific IDs for RedX, Pathao, and Steadfast.
Installation
npm install @classytic/bd-areasFeatures
- Complete BD Coverage: 8 divisions, 64 districts, 2836 delivery areas
- Multi-Provider Support: Area IDs for RedX, Pathao, Steadfast
- TypeScript First: Full type definitions
- Tree-Shakeable: Import only what you need
- Browser + Node: Works in both environments
Usage
Frontend - Cascading Dropdowns
import {
getDivisions,
getDistrictsByDivision,
getAreasByDistrict,
searchAreas,
} from '@classytic/bd-areas';
// Get all divisions for first dropdown
const divisions = getDivisions();
// [{ id: 'dhaka', name: 'Dhaka', nameLocal: 'ঢাকা' }, ...]
// When user selects a division, get districts
const districts = getDistrictsByDivision('dhaka');
// [{ id: 'dhaka', name: 'Dhaka', divisionId: 'dhaka', ... }, ...]
// When user selects a district, get areas
const areas = getAreasByDistrict('dhaka');
// [{ internalId: 1, name: 'Mohammadpur', providers: { redx: 1 }, ... }, ...]
// Autocomplete search
const results = searchAreas('mirpur');Backend - Area Resolution
import {
getArea,
resolveArea,
getAreaByProvider,
convertProviderId,
} from '@classytic/bd-areas';
// Get area by internal ID (from your database)
const area = getArea(1);
// { internalId: 1, name: 'Mohammadpur', providers: { redx: 1 }, ... }
// Get full area with division/district objects
const resolved = resolveArea(1);
// { ...area, division: { id: 'dhaka', name: 'Dhaka', ... }, district: { ... } }
// Get area by provider-specific ID
const areaFromRedx = getAreaByProvider('redx', 1);
// Convert between provider IDs
const pathaoId = convertProviderId('redx', 1, 'pathao');API Reference
Division Functions
| Function | Description |
|----------|-------------|
| getDivisions() | Get all 8 divisions |
| getDivisionById(id) | Get division by ID |
| getDivisionByName(name) | Get division by name |
District Functions
| Function | Description |
|----------|-------------|
| getDistrictsByDivision(divisionId) | Get districts in a division |
| getDistrictById(id) | Get district by ID |
| getAllDistricts() | Get all 64 districts |
Area Functions
| Function | Description |
|----------|-------------|
| getArea(internalId) | Get area by internal ID |
| getAreaByProvider(provider, providerId) | Get area by provider-specific ID |
| getAreasByDistrict(districtId) | Get areas in a district |
| getAreasByDivision(divisionId) | Get areas in a division |
| getAreasByPostCode(postCode) | Get areas by postal code |
| getAllAreas() | Get all 2836 areas |
| searchAreas(query, limit?) | Search areas by name/postcode/district |
| resolveArea(internalId) | Get area with full division/district objects |
| convertProviderId(from, id, to) | Convert between provider area IDs |
Statistics
import { getStats } from '@classytic/bd-areas';
const stats = getStats();
// {
// divisions: 8,
// districts: 64,
// areas: 2836,
// providerCoverage: { redx: 2836, pathao: 0, steadfast: 0 },
// byDivision: [{ division: 'Dhaka', districts: 13, areas: 1295 }, ...]
// }Types
interface Division {
id: string;
name: string;
nameLocal: string; // Bengali name
}
interface District {
id: string;
name: string;
divisionId: string;
divisionName: string;
}
interface Area {
internalId: number; // Use this in your database
name: string;
postCode: number | null;
zoneId: number;
districtId: string;
districtName: string;
divisionId: string;
divisionName: string;
providers: {
redx?: number;
pathao?: number;
steadfast?: number;
};
}Best Practices
Store Internal ID in Your Database
// When saving customer address
const area = searchAreas('mohammadpur')[0];
await saveAddress({
areaId: area.internalId, // Store this
areaName: area.name,
district: area.districtName,
division: area.divisionName,
});Get Provider ID When Making API Calls
// When creating shipment with RedX
const area = getArea(savedAddress.areaId);
const redxAreaId = area.providers.redx;
await redxClient.createParcel({
deliveryAreaId: redxAreaId,
// ...
});License
MIT © Classytic
