Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
@codetanzania/emis-api-states
Advanced tools
Simplify API calls and state management on top of redux and others.
Using npm
npm install @codetanzania/emis-api-states
Using yarn
yarn add @codetanzania/emis-api-states
All actions exposed by emis-api-states
are wrapped with dispatch function, so the is no need to dispatch them again just invoke them.
The following is the list of all resources exposed by this library.
activity
adjustment
agency
alert
alertSource
assessment
district
feature
focalPerson
incident
incidentType
indicator
item
itemCategory
itemUnit
plan
procedure
question
questionnaire
region
resource
role
stock
warehouse
For each resource you can get it's exposed actions as follows;
Replace activities/activity with the name of the module you want
import {
clearActivityFilters,
clearActivitiesSort,
closeActivityForm,
deleteActivity,
filterActivities,
getActivities,
getActivity,
selectActivity,
openActivityForm,
paginateActivities,
postActivity,
putActivity,
refreshActivities,
searchActivities,
sortActivities,
} from '@codetanzania/emis-api-states';
The structure of the store for each resource is
const store = {
activities: {
list: [],
selected: null,
page: 1,
total: 0,
size: 0,
pages: 1,
loading: false,
posting: false,
showForm: false,
schema: null,
filter: null,
sort: null,
q: undefined
},
alerts: {
list: [],
selected: null,
page: 1,
total: 0,
size: 0,
pages: 1,
loading: false,
posting: false,
showForm: false,
schema: null,
filter: null,
sort: null,
q: undefined
},
...
};
This is a wrapper around react-redux Provider
component. You can use it as follows
import { render } from 'react-dom';
import { StoreProvider } from '@codetanzania/emis-api-states';
// store provider
render(
<StoreProvider>
<App />
</StoreProvider>,
document.getElementById('root')
);
This is a wrapper around react-redux connect
HOC with little improvement over it. You can use it as follows
import {Connect} from '@codetanzania/emis-api-states';
// for component
function ActivityList({ activities }){
return(
// jsx stuff
);
}
// connect AlertList component to store
export Connect(AlertList, {
activities: 'activities.list'
});
Some of these actions accepts two callback functions which will be executed on Success and Error scenarios as shown below;
import { getActivities, getActivity } from '@codetanzania/emis-api-states';
getActivities();
getActivity(activityId);
import { postActivity } from '@codetanzania/emis-api-states';
postActivity(activity, onSuccess, onError);
Note the
activity
here should have a valid_id
property
import { putActivity } from '@codetanzania/emis-api-states';
putActivity(activity, onSuccess, onError);
import { deleteActivity } from '@codetanzania/emis-api-states';
deleteActivity(activityId, onSuccess, onError);
import { searchActivities } from '@codetanzania/emis-api-states';
searchActivities(searchQueryString);
import {
filterActivities,
clearActivityFilters,
} from '@codetanzania/emis-api-states';
filterActivities({ plan: planId }, onSuccess, onError);
// clearing filters
clearActivityFilters(onSuccess, onError);
// keep some filters from being cleared. This won't reset plan field in filter object
clearActivityFilters(onSuccess, onError, ['plan']);
import { paginateActivities } from '@codetanzania/emis-api-state';
paginateActivity(pageNumber);
import {
sortActivities,
clearActivitiesSort,
} from '@codetanzania/emis-api-state';
sortActivities({ name: 1 }, onSuccess, onError);
// clear sort
clearActivitiesSort(onSuccess, onError);
Note: This library depends on emis-api-client to work, so in order to specify API URL add
.env
file on your project root folder and specify your API URL underREACT_APP_EMIS_API_URL=[specify API BASE URL here]
MIT License
Copyright (c) 2018 - present Code Tanzania & Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0.12.1 (2019-11-03)
FAQs
EMIS Redux state management library
The npm package @codetanzania/emis-api-states receives a total of 3 weekly downloads. As such, @codetanzania/emis-api-states popularity was classified as not popular.
We found that @codetanzania/emis-api-states demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.