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() {
|
export async function getNextAlarm() {
|
||||||
const res = await fetch(`api/alarms/next`, {headers: {'Accept': 'application/json'}})
|
const res = await fetch(`api/alarms/next`, {headers: {'Accept': 'application/json'}})
|
||||||
if (res.status == 200) {
|
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 {
|
} else {
|
||||||
throw new Error((await res.json()).errmsg);
|
throw new Error((await res.json()).errmsg);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,10 @@
|
|||||||
<span class="visually-hidden">Loading...</span>
|
<span class="visually-hidden">Loading...</span>
|
||||||
</div>
|
</div>
|
||||||
{:then nextalarm}
|
{: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()}
|
{#if nextalarm.getDay() == new Date().getDay() && nextalarm.getMonth() == new Date().getMonth() && nextalarm.getFullYear() == new Date().getFullYear()}
|
||||||
aujourd'hui à
|
aujourd'hui à
|
||||||
<DateFormat date={nextalarm} timeStyle="long" />
|
<DateFormat date={nextalarm} timeStyle="long" />
|
||||||
@ -87,6 +90,7 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<DateFormat date={nextalarm} dateStyle="short" timeStyle="long" />
|
<DateFormat date={nextalarm} dateStyle="short" timeStyle="long" />
|
||||||
{/if}
|
{/if}
|
||||||
|
{/if}
|
||||||
{/await}
|
{/await}
|
||||||
</div>
|
</div>
|
||||||
{#await isActiveP then isActive}
|
{#await isActiveP then isActive}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user