2022-09-25 19:43:00 +03:00
|
|
|
import { useTranslation } from "next-i18next";
|
2022-10-05 13:43:22 +03:00
|
|
|
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
|
|
|
|
2024-11-27 02:33:40 -08:00
|
|
|
export default function Widget({ widget, service }) {
|
2022-09-08 11:48:16 +03:00
|
|
|
const { t } = useTranslation("common");
|
|
|
|
|
2024-11-27 02:33:40 -08:00
|
|
|
const ServiceWidget = components[widget.type];
|
2022-08-24 10:44:35 +03:00
|
|
|
|
2024-11-27 02:33:40 -08:00
|
|
|
const fullService = Object.apply({}, service);
|
|
|
|
fullService.widget = widget;
|
2022-08-24 10:44:35 +03:00
|
|
|
if (ServiceWidget) {
|
2022-10-05 13:43:22 +03:00
|
|
|
return (
|
|
|
|
<ErrorBoundary>
|
2024-11-27 02:33:40 -08:00
|
|
|
<ServiceWidget service={fullService} />
|
2022-10-05 13:43:22 +03:00
|
|
|
</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">
|
2024-11-27 02:33:40 -08:00
|
|
|
<div className="font-thin text-sm">{t("widget.missing_type", { type: widget.type })}</div>
|
2022-08-24 10:44:35 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|