mirror of
https://github.com/MadeBaruna/paimon-moe.git
synced 2025-02-18 03:16:30 +01:00
Add delete reminder
This commit is contained in:
parent
70ced1dfa7
commit
aaede53065
1 changed files with 31 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { stores } from '@sapper/app';
|
import { stores } from '@sapper/app';
|
||||||
import { mdiCalendarCheck, mdiLoading } from '@mdi/js';
|
import { mdiCalendarCheck, mdiDelete, mdiLoading } from '@mdi/js';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { t, locale } from 'svelte-i18n';
|
import { t, locale } from 'svelte-i18n';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
@ -67,7 +67,31 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
currentReminder = dayjs(data.time);
|
if (data.time) {
|
||||||
|
currentReminder = dayjs(data.time);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadingCurrent = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteCurrentReminder() {
|
||||||
|
console.log('delete reminder');
|
||||||
|
const url = new URL(`${__paimon.env.API_HOST}/reminder`);
|
||||||
|
const query = new URLSearchParams({ token: $firebaseToken, type: 'transformer' });
|
||||||
|
url.search = query.toString();
|
||||||
|
|
||||||
|
loadingCurrent = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await fetch(url, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
});
|
||||||
|
|
||||||
|
currentReminder = null;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
|
@ -174,10 +198,13 @@
|
||||||
{$t('reminder.checking')}
|
{$t('reminder.checking')}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if currentReminder !== null}
|
{#if !loadingCurrent && currentReminder !== null}
|
||||||
<div class="bg-background mb-4 p-4 rounded-xl">
|
<div class="bg-background mb-4 p-4 rounded-xl relative">
|
||||||
<p class="text-gray-400">{$t('reminder.current')}</p>
|
<p class="text-gray-400">{$t('reminder.current')}</p>
|
||||||
<p class="text-gray-400">{currentReminder.format('YYYY-MM-DD HH:mm')} ({currentReminder.fromNow()})</p>
|
<p class="text-gray-400">{currentReminder.format('YYYY-MM-DD HH:mm')} ({currentReminder.fromNow()})</p>
|
||||||
|
<Button size="sm" on:click={deleteCurrentReminder} className="absolute top-0 right-0 mt-1 mr-1 text-gray-400">
|
||||||
|
<Icon path={mdiDelete} />
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<p class="mb-1 ml-1">
|
<p class="mb-1 ml-1">
|
||||||
|
|
Loading…
Add table
Reference in a new issue