Skip to content

Commit

Permalink
Consider null sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
rzats committed May 22, 2024
1 parent 8771297 commit 7dbe224
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/modes/indicator/IndicatorAbout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
*/
export let sensor;
function exportData() {
sensor.set(sensor.value);
function setExportMode() {
// switch to export mode
currentMode.set(modeByID.export);
}
function buildExportURL() {
let exportURL = '';
if (sensor.key.split('-').length >= 2) {
if (sensor && sensor.key.split('-').length >= 2) {
// account for dashes in the sensor
let [first, ...rest] = sensor.key.split('-');
rest = rest.join('-');
Expand All @@ -35,7 +34,6 @@
exportURL += `&geo_type=${region.level}&geo_value=${region.propertyId}`;
}
if (date) {
console.log(date);
exportURL += `&start_day=${formatDateISO(date.value)}&end_day=${formatDateISO(date.value)}`;
}
return exportURL;
Expand All @@ -60,9 +58,7 @@
</li>
{/each}
<li>
<a href={`../${modeByID.export.id}/?${buildExportURL()}`} on:click|preventDefault={exportData}
>Export Data</a
>
<a href={`../export/?${buildExportURL()}`} on:click={setExportMode}>Export Data</a>
</li>
</ul>
{/if}
Expand Down

0 comments on commit 7dbe224

Please sign in to comment.