Skip to content

Instantly share code, notes, and snippets.

@mtuchi
Created March 13, 2023 14:50
Show Gist options
  • Save mtuchi/17dfcb658213de8bfb50250fd56fffa8 to your computer and use it in GitHub Desktop.
Save mtuchi/17dfcb658213de8bfb50250fd56fffa8 to your computer and use it in GitHub Desktop.
get("users");
fn((state) => {
const globalOrgsUnit = [
{
id: "g8upMTyEZGZ",
city: "Gwenborough",
},
];
return { ...state, globalOrgsUnit };
});
fn((state) => {
const patientsList = state.data;
const globalOrgsUnit = state.globalOrgsUnit;
const getOrgUnit = (city) => {
globalOrgsUnit.map((orgunit) => {
if (city === orgunit.city) {
return orgunit.id;
}
});
};
const mappedPatients = patientsList.map((patient) => {
// console.log(JSON.stringify(patient.address.city, null, 2));
const orgUnit = getOrgUnit(patient.address.city);
console.log(orgUnit);
});
// console.log(JSON.stringify(patientsList, null, 2));
return { ...state, mappedPatients };
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment