()
| 126 | return; |
| 127 | } |
| 128 | const fetchTs = async () => { |
| 129 | setNdviTsLoading(true); |
| 130 | try { |
| 131 | const polygon = field.coordinates[0]; |
| 132 | const { data, error } = await supabase.functions.invoke("ndvi-timeseries", { |
| 133 | body: { polygon }, |
| 134 | }); |
| 135 | if (error) throw error; |
| 136 | if (hasNdviPayload(data)) { |
| 137 | setNdviTimeSeries(data); |
| 138 | setLocalCache(GEE_ANALYTICS_CACHE_KEY, cacheKey, data); |
| 139 | } else if (isFallbackPayload(data)) { |
| 140 | setNdviTimeSeries(cached ?? null); |
| 141 | } else { |
| 142 | setNdviTimeSeries(null); |
| 143 | } |
| 144 | } catch (e) { |
| 145 | console.error("NDVI time-series error:", e); |
| 146 | setNdviTimeSeries(cached ?? null); |
| 147 | } finally { setNdviTsLoading(false); } |
| 148 | }; |
| 149 | fetchTs(); |
| 150 | }, [field.id]); |
| 151 |
no test coverage detected