()
| 94 | return; |
| 95 | } |
| 96 | const fetchGee = async () => { |
| 97 | setGeeLoading(true); |
| 98 | try { |
| 99 | const polygon = field.coordinates[0]; |
| 100 | const { data, error } = await supabase.functions.invoke("gee-analytics", { |
| 101 | body: { polygon, analyses: ["land_use", "vegetation", "suitability"] }, |
| 102 | }); |
| 103 | if (error) throw error; |
| 104 | if (hasGeeAnalyticsPayload(data)) { |
| 105 | setGeeData(data); |
| 106 | setLocalCache(GEE_ANALYTICS_CACHE_KEY, field.id, data); |
| 107 | } else if (isFallbackPayload(data)) { |
| 108 | setGeeData(cached ?? null); |
| 109 | } else { |
| 110 | setGeeData(null); |
| 111 | } |
| 112 | } catch (e) { |
| 113 | console.error("GEE analytics error:", e); |
| 114 | setGeeData(cached ?? null); |
| 115 | } finally { setGeeLoading(false); } |
| 116 | }; |
| 117 | fetchGee(); |
| 118 | }, [field.id]); |
| 119 |
no test coverage detected