Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the organzation component in the /catpure page #1766

Open
dadiorchen opened this issue Feb 29, 2024 · 1 comment
Open

Implement the organzation component in the /catpure page #1766

dadiorchen opened this issue Feb 29, 2024 · 1 comment

Comments

@dadiorchen
Copy link
Collaborator

The capture page, here the planting organization is wrong:

Image

We need to use the stakeholder endpoint in query API to fetch the stakeholder, (organization here)

https://github.com/Greenstand/treetracker-query-api/blob/ebf9d2cf474fc5ed8479809d54140ce5f80e3170/docs/api/spec/query-api.yaml#L273-L284

Please write the integration test and mock the data, please verify the organization info on the result page (the info return from your mock object)

@khalatevarun
Copy link
Contributor

async function serverSideData(params) {
  const { captureid } = params;
  const tree = await getCapturesById(captureid);
  const { planting_organization_id, grower_account_id, lat, lon } = tree;
  const grower = await getGrowerById(grower_account_id);
  const country = await getCountryByLatLon(lat, lon);
  let organization; // = await getStakeHolderById(planting_organization_id);

  if (planting_organization_id) {
    log.warn('load org from planting_orgniazation_id');
    organization = await getStakeHolderById(planting_organization_id);
  } else if (grower.organization_id) {
    log.warn('load org from planter. organization_id');
    organization = await getStakeHolderById(grower.organization_id);
  } else {
    log.warn('can not load org for tree:', tree, grower);
  }

  return {
    tree,
    grower,
    organization,
    country,
  };
}

we are already using the getStakeHolderById function to fetch the stakeholder if planting_organization_id is null

@dadiorchen the handling is already done, is there any thing else that needs to be changed in the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🌱 Backlog
Development

No branches or pull requests

2 participants