Greenstand / treetracker-admin-client

The Admin Panel is the part of the Treetracker project for verifying, processing and managing data collected by the Treetracker app
GNU Affero General Public License v3.0
33 stars 193 forks source link

Earnings: Name of growers are all undefined #1092

Closed SuspenseFallback closed 1 year ago

SuspenseFallback commented 1 year ago

See image.

Screenshot 2023-04-24 at 9 21 43 AM
nivekgtc commented 1 year ago

Please, assign this issue to me!

sleddd commented 1 year ago

@nivekgtc @nmcharlton Not sure if this is helpful, but I took a quick look at this and realized the earnings API itself was returning 'undefined undefined' as grower. I then dug into the earnings api in the models/earnings.js file and noticed it was pulling from data returned via the stakeholders api in line 101 where it shows: "grower: ${growerResponse?.first_name} ${growerResponse?.last_name}," and that pulls data from line 89: const growerResponse = await getStakeholderById(worker_id);

Could it be that the stakeholder info does not have a first or last name?

I also saw that in this commit: https://github.com/Greenstand/treetracker-earnings-api/commit/58e97130f79c8b20a8c45f69250ee10fb5f74ead

The earnings model called: growerResponse.data.stakeholders[0]?.last_name

Does the earnings model just need to adjust how it accesses that first and last name?

I could not test without installing postgre etc and since this is already assigned, I am going to move on to one of the good first issues, but I thought I would share what I found in case it was helpful.

This is a screenshot of the Earnings API response used in the EarningsTable.js - note the grower field. Screen Shot 2023-05-18 at 2 24 26 PM

This is a screenshot of the location for grower in models/Earnings.js in the earnings api. Screen Shot 2023-05-18 at 2 32 49 PM