refac
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
import {
|
||||
getCalendars,
|
||||
getCalendarEvents,
|
||||
deleteCalendar,
|
||||
type CalendarModel,
|
||||
type CalendarEventModel
|
||||
} from '$lib/apis/calendar';
|
||||
@@ -111,6 +112,21 @@
|
||||
visibleCalendarIds = next;
|
||||
}
|
||||
|
||||
async function handleDeleteCalendar(id: string) {
|
||||
try {
|
||||
const result = await deleteCalendar(localStorage.token, id);
|
||||
if (result) {
|
||||
toast.success($i18n.t('Calendar deleted'));
|
||||
await loadCalendars();
|
||||
await refresh();
|
||||
} else {
|
||||
toast.error($i18n.t('Failed to delete calendar'));
|
||||
}
|
||||
} catch (err) {
|
||||
toast.error(`${err}`);
|
||||
}
|
||||
}
|
||||
|
||||
function handleCreateEvent(e: CustomEvent<{ start_at: number }>) {
|
||||
editEvent = null;
|
||||
defaultStartAt = e.detail.start_at;
|
||||
@@ -334,6 +350,7 @@
|
||||
{visibleCalendarIds}
|
||||
{currentDate}
|
||||
onToggle={toggleCalendar}
|
||||
onDeleteCalendar={handleDeleteCalendar}
|
||||
onDateSelect={handleDateSelect}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user