Greenstand/treetracker-admin-api

"Tree" page is broken

dadiorchen opened this issue · 1 comments

Screen Shot 2021-01-04 at 3 42 15 PM

The URL to request the tree list is incorrect:

https://admin.treetracker.org/api/admin/api/trees?filter=%22{\%22where\%22:{\%22active\%22:true},\%22order\%22:[\%22id%20asc\%22],\%22limit\%22:25,\%22skip\%22:0,\%22fields\%22:{\%22id\%22:true,\%22timeCreated\%22:true,\%22status\%22:true,\%22planterId\%22:true,\%22treeTags\%22:true}}%22

Maybe we should give a patch to the current release to solve this rather than waiting for the next version.

We're stringifying the filter object twice:

client/src/model/trees.js:144

      const lbFilter = JSON.stringify({
        where: {...where, active: true},
        order: [`${orderBy} ${order}`],
        limit: rowsPerPage,
        skip: page * rowsPerPage,
        fields: {
          id: true,
          timeCreated: true,
          status: true,
          planterId: true,
          treeTags: true,
        },
      })

      const query = `${process.env.REACT_APP_API_ROOT}/api/${getOrganization()}trees?filter=${JSON.stringify(lbFilter)}`