This commit is contained in:
Brandon McFarlin 2024-12-13 11:57:09 -05:00
parent 27896861c8
commit 79d96af924
2 changed files with 7 additions and 10 deletions

View File

@ -13,12 +13,9 @@ export default function Widget({ options }) {
let { refresh } = options;
if (!refresh) refresh = 1500;
const { data, error } = useSWR(
`/api/widgets/peanut?${new URLSearchParams({ ...options }).toString()}`,
{
refreshInterval: refresh,
},
);
const { data, error } = useSWR(`/api/widgets/peanut?${new URLSearchParams({ ...options }).toString()}`, {
refreshInterval: refresh,
});
if (error || data?.error) {
return <Error options={options} />;
@ -51,20 +48,20 @@ export default function Widget({ options }) {
<Resource
icon={FaCarBattery}
value={t("common.number", {
value: data['ups.load'],
value: data["ups.load"],
style: "unit",
unit: "percent",
maximumFractionDigits: 0,
})}
label={t("peanut.load")}
expandedValue={t("common.number", {
value: data['battery.charge'],
value: data["battery.charge"],
style: "unit",
unit: "percent",
maximumFractionDigits: 0,
})}
expandedLabel={t("peanut.battery")}
percentage={data['ups.load']}
percentage={data["ups.load"]}
expanded={expanded}
/>
</div>

View File

@ -45,7 +45,7 @@ export default async function handler(req, res) {
try {
const upsData = await retrieveFromPeanutAPI(privateWidgetOptions, key);
const data = {
...upsData
...upsData,
};
return res.status(200).send(data);