27 lines
784 B
React
Raw Normal View History

2022-09-25 19:43:00 +03:00
import { useTranslation } from "next-i18next";
import ErrorBoundary from "components/errorboundry";
2025-02-18 16:16:53 -08:00
2022-09-25 19:43:47 +03:00
import components from "widgets/components";
2022-08-24 10:44:35 +03:00
export default function Widget({ widget, service }) {
2022-09-08 11:48:16 +03:00
const { t } = useTranslation("common");
const ServiceWidget = components[widget.type];
2022-08-24 10:44:35 +03:00
const fullService = Object.apply({}, service);
fullService.widget = widget;
2022-08-24 10:44:35 +03:00
if (ServiceWidget) {
return (
<ErrorBoundary>
<ServiceWidget service={fullService} />
</ErrorBoundary>
);
2022-08-24 10:44:35 +03:00
}
return (
2025-03-02 08:42:57 -08:00
<div className="bg-theme-200/50 dark:bg-theme-900/20 rounded-sm m-1 flex-1 flex flex-col items-center justify-center p-1 service-missing">
<div className="font-thin text-sm">{t("widget.missing_type", { type: widget.type })}</div>
2022-08-24 10:44:35 +03:00
</div>
);
}