@homefile/components-v2 2.15.0 → 2.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { parseISO, format } from 'date-fns';
|
|
2
2
|
export function mapForecastToWidget(periods, location) {
|
|
3
3
|
var _a, _b, _c, _d;
|
|
4
|
-
if (!periods.length)
|
|
5
|
-
|
|
6
|
-
}
|
|
4
|
+
if (!periods.length)
|
|
5
|
+
return {};
|
|
7
6
|
// --- HEADER DATE ---
|
|
8
7
|
const todayDate = parseISO(periods[0].startTime);
|
|
9
8
|
const headerDate = format(todayDate, 'EEEE, MMMM do')
|
|
@@ -14,7 +13,6 @@ export function mapForecastToWidget(periods, location) {
|
|
|
14
13
|
const night0 = (_c = (_b = periods.find((p) => !p.isDaytime &&
|
|
15
14
|
format(parseISO(p.startTime), 'yyyy-MM-dd') ===
|
|
16
15
|
format(parseISO(day0.startTime), 'yyyy-MM-dd'))) !== null && _b !== void 0 ? _b : periods.find((p) => !p.isDaytime)) !== null && _c !== void 0 ? _c : day0;
|
|
17
|
-
console.log({ night0 });
|
|
18
16
|
const currentTemp = day0.temperature;
|
|
19
17
|
const currentIcon = day0.icon;
|
|
20
18
|
const highTemp = day0.temperature;
|
|
@@ -32,7 +30,7 @@ export function mapForecastToWidget(periods, location) {
|
|
|
32
30
|
format(parseISO(p.startTime), 'yyyy-MM-dd'));
|
|
33
31
|
const low = (_a = night === null || night === void 0 ? void 0 : night.temperature) !== null && _a !== void 0 ? _a : p.temperature;
|
|
34
32
|
const icon = p.icon;
|
|
35
|
-
const day = format(parseISO(p.startTime), 'EEE').toUpperCase();
|
|
33
|
+
const day = format(parseISO(p.startTime), 'EEE').toUpperCase();
|
|
36
34
|
return { day, icon, high: p.temperature, low };
|
|
37
35
|
});
|
|
38
36
|
return {
|
package/package.json
CHANGED
|
@@ -5,9 +5,7 @@ export function mapForecastToWidget(
|
|
|
5
5
|
periods: ForecastPeriodI[],
|
|
6
6
|
location: string
|
|
7
7
|
): WeatherWidgetI {
|
|
8
|
-
if (!periods.length) {
|
|
9
|
-
throw new Error('Nenhum período disponível para mapping')
|
|
10
|
-
}
|
|
8
|
+
if (!periods.length) return {} as WeatherWidgetI
|
|
11
9
|
|
|
12
10
|
// --- HEADER DATE ---
|
|
13
11
|
const todayDate = parseISO(periods[0].startTime)
|
|
@@ -27,8 +25,6 @@ export function mapForecastToWidget(
|
|
|
27
25
|
periods.find((p) => !p.isDaytime) ??
|
|
28
26
|
day0
|
|
29
27
|
|
|
30
|
-
console.log({ night0 })
|
|
31
|
-
|
|
32
28
|
const currentTemp = day0.temperature
|
|
33
29
|
const currentIcon = day0.icon
|
|
34
30
|
const highTemp = day0.temperature
|
|
@@ -52,7 +48,7 @@ export function mapForecastToWidget(
|
|
|
52
48
|
)
|
|
53
49
|
const low = night?.temperature ?? p.temperature
|
|
54
50
|
const icon = p.icon
|
|
55
|
-
const day = format(parseISO(p.startTime), 'EEE').toUpperCase()
|
|
51
|
+
const day = format(parseISO(p.startTime), 'EEE').toUpperCase()
|
|
56
52
|
return { day, icon, high: p.temperature, low }
|
|
57
53
|
})
|
|
58
54
|
|