homepage/src/components/widget.jsx

24 lines
632 B
React
Raw Normal View History

2022-08-24 10:44:35 +03:00
import Weather from "components/widgets/weather/weather";
2022-08-27 13:30:17 +03:00
import OpenWeatherMap from "components/widgets/openweathermap/weather";
2022-08-24 10:44:35 +03:00
import Resources from "components/widgets/resources/resources";
const widgetMappings = {
weather: Weather,
2022-08-27 13:30:17 +03:00
openweathermap: OpenWeatherMap,
2022-08-24 10:44:35 +03:00
resources: Resources,
};
export default function Widget({ widget }) {
const ServiceWidget = widgetMappings[widget.type];
if (ServiceWidget) {
return <ServiceWidget options={widget.options} />;
}
return (
<div className="flex-none flex flex-row items-center justify-center">
Missing <strong>{widget.type}</strong>
</div>
);
}