mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-10 15:28:47 +00:00
updates to handle more than one weather widget
This commit is contained in:
parent
dc6b172df9
commit
7b6cbb4ee1
4 changed files with 50 additions and 28 deletions
|
@ -3,33 +3,37 @@ import { BiError } from "react-icons/bi";
|
|||
|
||||
import Icon from "./icon";
|
||||
|
||||
export default function Weather({ options }) {
|
||||
export default function WeatherApi({ options }) {
|
||||
const { data, error } = useSWR(
|
||||
`/api/widgets/weather?lat=${options.latitude}&lon=${options.longitude}&apiKey=${options.apiKey}&duration=${options.cache}`
|
||||
);
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<div className="flex flex-row items-center">
|
||||
<BiError className="w-8 h-8 text-theme-800 dark:text-theme-200" />
|
||||
<div className="flex flex-col ml-3 text-left">
|
||||
<span className="text-theme-800 dark:text-theme-200 text-sm">API</span>
|
||||
<span className="text-theme-800 dark:text-theme-200 text-xs">Error</span>
|
||||
<div className="flex flex-col">
|
||||
<div className="flex flex-row items-center justify-end">
|
||||
<div className="flex flex-col items-center">
|
||||
<BiError className="w-8 h-8 text-theme-800 dark:text-theme-200" />
|
||||
<div className="flex flex-col ml-3 text-left">
|
||||
<span className="text-theme-800 dark:text-theme-200 text-sm">API</span>
|
||||
<span className="text-theme-800 dark:text-theme-200 text-xs">Error</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return <div className="flex flex-row items-center"></div>;
|
||||
return <div className="flex flex-row items-center justify-end"></div>;
|
||||
}
|
||||
|
||||
if (data.error) {
|
||||
return <div className="flex flex-row items-center"></div>;
|
||||
return <div className="flex flex-row items-center justify-end"></div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className=" flex flex-col">
|
||||
<div className="flex flex-col">
|
||||
<div className="flex flex-row items-center justify-end">
|
||||
<div className="flex flex-col items-center">
|
||||
<Icon condition={data.current.condition.code} timeOfDay={data.current.is_day ? "day" : "night"} />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue