Handle no scheduled alarm case
This commit is contained in:
parent
764ac78063
commit
192e751405
@ -65,7 +65,11 @@ export async function getAlarmSingle(aid) {
|
||||
export async function getNextAlarm() {
|
||||
const res = await fetch(`api/alarms/next`, {headers: {'Accept': 'application/json'}})
|
||||
if (res.status == 200) {
|
||||
return new Date(await res.json());
|
||||
const data = await res.json();
|
||||
if (data)
|
||||
return new Date(data);
|
||||
else
|
||||
return data;
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
|
@ -69,7 +69,10 @@
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
{:then nextalarm}
|
||||
Prochain réveil :
|
||||
{#if nextalarm === null}
|
||||
<Icon name="x-octagon" /> Pas de prochain réveil programmé
|
||||
{:else}
|
||||
<Icon name="alarm-fill" /> Prochain réveil :
|
||||
{#if nextalarm.getDay() == new Date().getDay() && nextalarm.getMonth() == new Date().getMonth() && nextalarm.getFullYear() == new Date().getFullYear()}
|
||||
aujourd'hui à
|
||||
<DateFormat date={nextalarm} timeStyle="long" />
|
||||
@ -87,6 +90,7 @@
|
||||
{:else}
|
||||
<DateFormat date={nextalarm} dateStyle="short" timeStyle="long" />
|
||||
{/if}
|
||||
{/if}
|
||||
{/await}
|
||||
</div>
|
||||
{#await isActiveP then isActive}
|
||||
|
Loading…
x
Reference in New Issue
Block a user