import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import useWidgetAPI from "utils/proxy/use-widget-api";
export default function Component({ service }) {
const { widget } = service;
const { data: printerStats, error: printerStatsError } = useWidgetAPI(widget, "printer_stats", {
refreshInterval: 1500,
});
const { data: jobStats, error: jobStatsError } = useWidgetAPI(widget, "job_stats", {
refreshInterval: 1500,
});
if (printerStatsError) {
return ;
}
if (jobStatsError) {
return ;
}
const state = printerStats?.state?.text;
const tempTool = printerStats?.temperature?.tool0?.actual;
const tempBed = printerStats?.temperature?.bed?.actual;
if (!printerStats || !state || !tempTool || !tempBed) {
return (
);
}
if (state === "Printing" || state === "Paused") {
const { completion } = jobStats.progress;
if (!jobStats || !completion) {
return (
);
}
return (
);
}
return (
);
}