# @opensrp/inventory

> Module to manage inventory, and service points

Latest version **0.0.9** (published 2021-07-26) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @opensrp/inventory
pnpm add @opensrp/inventory
yarn add @opensrp/inventory
bun add @opensrp/inventory
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.9 |
| Published | 2021-07-26 |
| First published | 2021-02-18 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 200.7 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| Author | OpenSRP Engineering |
| Maintainers | opensrp-admin |

## Links

- npm: https://www.npmjs.com/package/@opensrp/inventory
- Repository: https://github.com/opensrp/web
- Homepage: https://github.com/opensrp/web#readme
- Issues: https://github.com/opensrp/web/issues
- npm.io page: https://npm.io/package/@opensrp/inventory

## Dependencies (7)

- [axios](https://npm.io/package/axios.md) ^0.21.1
- [date-fns](https://npm.io/package/date-fns.md) 2.11.1
- [react-i18next](https://npm.io/package/react-i18next.md) ^11.8.10
- [@opensrp/pkg-config](https://npm.io/package/@opensrp/pkg-config.md) ^0.0.9
- [@opensrp/react-utils](https://npm.io/package/@opensrp/react-utils.md) ^0.0.12
- [@opensrp/product-catalogue](https://npm.io/package/@opensrp/product-catalogue.md) ^0.0.9
- [@opensrp/location-management](https://npm.io/package/@opensrp/location-management.md) ^0.0.15

## Recent versions

- 0.0.9 (latest) — 2021-07-26
- 0.0.8 — 2021-06-30
- 0.0.7 — 2021-06-17
- 0.0.6 — 2021-06-10
- 0.0.5 — 2021-02-24
- 0.0.4 — 2021-02-23
- 0.0.2 — 2021-02-18

## README

# inventory

Provides UI components and utils for managing inventory items per service point

## Installation

```sh
yarn add @opensrp/inventory
```

```typescript
import '@opensrp/inventory/dist/index.css';
```

## Usage

### Inventory Add/Edit form

Use this component to create a view for adding a new inventory item or editing an existing inventory item

![Add inventory form](public/assets/img/add-inventory.png)

To add a view for adding a new inventory item:

```tsx
import { ConnectedInventoryAddEdit, ROUTE_PARAM_SERVICE_POINT_ID } from '@opensrp/inventory';


const props = {
	openSRPBaseURL: 'https://opensrp-stage.smartregister.org/opensrp/rest',
  cancelURL: '/inventory',
  redirectURL: '/inventory',
}

<Route path={`/service-point/:${ROUTE_PARAM_SERVICE_POINT_ID}/inventory-item/add`}>
  <ConnectedInventoryAddEdit {...props} />
</Route>
```

**N/B** You can declare any path but make sure to include the param `ROUTE_PARAM_SERVICE_POINT_ID` in your path e.g `/foo/:${ROUTE_PARAM_SERVICE_POINT_ID}` in order to match the service point to add the inventory to

To add a view for editing an existing inventory item:

```tsx
import {
ConnectedInventoryAddEdit,
ROUTE_PARAM_SERVICE_POINT_ID,
ROUTE_PARAM_INVENTORY_ITEM_ID
} from '@opensrp/inventory';


const props = {
	openSRPBaseURL: 'https://opensrp-stage.smartregister.org/opensrp/rest',
  servicePointProfileURL: '/inventory/service-point',
}

<Route path={`/service-point/:${ROUTE_PARAM_SERVICE_POINT_ID}/inventory-item/edit/:${ROUTE_PARAM_INVENTORY_ITEM_ID}`}>
  <ConnectedInventoryAddEdit {...props} />
</Route>
```

**N/B** You can declare any path but make sure to include the params `ROUTE_PARAM_SERVICE_POINT_ID`, `ROUTE_PARAM_INVENTORY_ITEM_ID` in your path e.g `/foo/:${ROUTE_PARAM_SERVICE_POINT_ID}/:${ROUTE_PARAM_INVENTORY_ITEM_ID}` in order to match the service point to add the inventory to and inventory item being editted respectively.

`ConnectedInventoryAddEdit` component takes the following props:

- **opensrpBaseURL:**(string)

  - **required**
  - Opensrp API base URL

- **servicePointProfileURL:**(string)

  - **Optional**
  - Route to the service point profile view to redirect to after pressing `Cancel` button on the form to abort and exit the view or after successful submission.
  - If not provided the default is `/inventory/profile/<id>` where `id` is the id of the service point
  - If provided, the id of the service point will be added to the route name e.g if you passed `/inventory/service-point` as the `servicePointProfileURL`, the redirect will be to `/inventory/service-point/<id>`
  -

### Inventory List

To add a view for inventory list:

```tsx
import { ConnectedServicePointList } from '@opensrp/inventory';

const props = {
	openSRPBaseURL: 'https://opensrp-stage.smartregister.org/opensrp/rest',
}

<Route path={`/inventory`}>
  <ConnectedServicePointList {...props} />
</Route>
```

`ConnectedServicePointList` component takes the following props:

- **opensrpBaseURL:**(string)

  - **required**
  - Opensrp API base URL

### Service Point Profile

To add a view for service point profile:

```tsx
import { ServicePointProfile, INVENTORY_SERVICE_POINT_PROFILE_PARAM } from '@opensrp/inventory';

const props = {
	openSRPBaseURL: 'https://opensrp-stage.smartregister.org/opensrp/rest',
}

<Route path={`/inventory/:${ROUTE_PARAM_INVENTORY_ITEM_ID}`}>
  <ServicePointProfile {...props} />
</Route>
```

**N/B** You can declare any path but make sure to include the param `ROUTE_PARAM_INVENTORY_ITEM_ID` in your path e.g `/foo/:${ROUTE_PARAM_INVENTORY_ITEM_ID}`

`ServicePointProfile` component takes the following props:

- **opensrpBaseURL:**(string)

  - **required**
  - Opensrp API base URL

### Bulk Upload

To add a view for uploading inventories:

```tsx
import { BulkUpload } from '@opensrp/inventory';

const props = {
	openSRPBaseURL: 'https://opensrp-stage.smartregister.org/opensrp/rest',
}

<Route path={`/inventory/upload`}>
  <BulkUpload {...props} />
</Route>
```

`BulkUpload` component takes the following props:

- **opensrpBaseURL:**(string)

  - **required**
  - Opensrp API base URL

---
_Source: https://npm.io/package/@opensrp/inventory · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
