25 lines
845 B
React
Raw Normal View History

import dynamic from "next/dynamic";
2022-08-24 10:44:35 +03:00
const widgetMappings = {
weatherapi: dynamic(() => import("components/widgets/weather/weather")),
openweathermap: dynamic(() => import("components/widgets/openweathermap/weather")),
resources: dynamic(() => import("components/widgets/resources/resources")),
search: dynamic(() => import("components/widgets/search/search")),
greeting: dynamic(() => import("components/widgets/greeting/greeting")),
datetime: dynamic(() => import("components/widgets/datetime/datetime")),
2022-08-24 10:44:35 +03:00
};
export default function Widget({ widget }) {
2022-09-16 10:53:12 +03:00
const InfoWidget = widgetMappings[widget.type];
2022-08-24 10:44:35 +03:00
2022-09-16 10:53:12 +03:00
if (InfoWidget) {
return <InfoWidget options={widget.options} />;
2022-08-24 10:44:35 +03:00
}
return (
<div className="flex-none flex flex-row items-center justify-center">
Missing <strong>{widget.type}</strong>
</div>
);
}