"use client"; import React, { useState, useEffect } from "react"; export default function UtilitiesPage() { const [firstEnergyUser, setFirstEnergyUser] = useState(""); const [firstEnergyPass, setFirstEnergyPass] = useState(""); const [peoplesGasUser, setPeoplesGasUser] = useState(""); const [peoplesGasPass, setPeoplesGasPass] = useState(""); const [status, setStatus] = useState(""); useEffect(() => { fetch('/proxy/utility/api/credentials') .then(r => r.json()) .then(data => { if (data.success) { setFirstEnergyUser(data.firstEnergyUser || ""); setPeoplesGasUser(data.peoplesGasUser || ""); } }) .catch(console.error); }, []); const handleSave = async (e) => { e.preventDefault(); setStatus("Saving..."); try { const res = await fetch('/proxy/utility/api/credentials', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ firstEnergyUser, firstEnergyPass, peoplesGasUser, peoplesGasPass }) }); const data = await res.json(); if (data.success) { setStatus("✅ Credentials saved securely."); setFirstEnergyPass(""); setPeoplesGasPass(""); } else { setStatus("❌ Failed to save."); } } catch (err) { setStatus("❌ Network error."); } }; const handleRun = async () => { setStatus("Starting scraper..."); try { await fetch('/proxy/utility/api/run', { method: 'POST' }); setStatus("✅ Scraper triggered in background!"); } catch (e) { setStatus("❌ Failed to run scraper."); } }; return (
The Utility Agent securely automates retrieving your daily energy and gas usage data. It uses these credentials locally in your private cluster and sends a summary to your WhatsApp gateway.