Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/v1.1.9bugs #256

Merged
merged 3 commits into from
Apr 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
ensure numeric value or dash to next hour forecast integers
paavovaananen-cgi committed Apr 14, 2022
commit 6fadcaeec635c700606c292bfb00a58e4fc130b9
16 changes: 11 additions & 5 deletions src/components/weather/NextHourForecastPanel.tsx
Original file line number Diff line number Diff line change
@@ -65,6 +65,11 @@ const NextHourForecastPanel: React.FC<NextHourForecastPanelProps> = ({
const sunrise = moment(`${nextHourForecast.sunrise}Z`);
const sunset = moment(`${nextHourForecast.sunset}Z`);

const numericOrDash = (val: number | undefined | null): string => {
if (!Number.isInteger(val)) return '-';
return `${val}`;
};

return (
<View style={styles.container}>
<View style={styles.alignCenter} accessible accessibilityRole="header">
@@ -93,7 +98,7 @@ const NextHourForecastPanel: React.FC<NextHourForecastPanelProps> = ({
<View style={[styles.row, styles.alignStart]}>
<Text
style={[styles.temperatureText, { color: colors.primaryText }]}>
{`${nextHourForecast.temperature}`}
{numericOrDash(nextHourForecast.temperature)}
</Text>
<Text style={[styles.unitText, { color: colors.primaryText }]}>
°C
@@ -106,8 +111,9 @@ const NextHourForecastPanel: React.FC<NextHourForecastPanelProps> = ({
{activeParameters.includes('uvCumulated') && (
<Text style={[styles.text, { color: colors.hourListText }]}>
{'UV '}
<Text
style={styles.bold}>{`${nextHourForecast.uvCumulated}`}</Text>
<Text style={styles.bold}>
{numericOrDash(nextHourForecast.uvCumulated)}
</Text>
</Text>
)}
</View>
@@ -122,7 +128,7 @@ const NextHourForecastPanel: React.FC<NextHourForecastPanelProps> = ({
]}>
{t('feelsLike')}{' '}
<Text style={[styles.bold, styles.feelsLikeText]}>
{`${nextHourForecast.feelsLike}`}
{numericOrDash(nextHourForecast.feelsLike)}
</Text>
<Text style={styles.feelsLikeText}>°C</Text>
</Text>
@@ -180,7 +186,7 @@ const NextHourForecastPanel: React.FC<NextHourForecastPanelProps> = ({
styles.bold,
{ color: colors.hourListText },
]}>
{`${nextHourForecast.windSpeedMS} `}
{numericOrDash(nextHourForecast.windSpeedMS)}
</Text>
</View>
<View style={styles.row}>