homepage/src/components/widget.jsx

27 lines
782 B
React
Raw Normal View History

import WeatherApi 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";
import Search from "components/widgets/search/search";
2022-08-24 10:44:35 +03:00
const widgetMappings = {
weather: WeatherApi, // This key will be deprecated in the future
weatherapi: WeatherApi,
2022-08-27 13:30:17 +03:00
openweathermap: OpenWeatherMap,
2022-08-24 10:44:35 +03:00
resources: Resources,
search: Search,
2022-08-24 10:44:35 +03:00
};
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>
);
}