Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

704 B
Raw Blame
import type { CalendarEvent } from '@app/features/calendar/types';
import { eventDisplayTitle } from '@app/features/calendar/utils/event-forward-summary';
import { toast } from '@core/component/Toast/Toast';
import { downloadFile } from '@filesystem/download';
import { fetchCalendarEventIcs } from '@queries/calendar/ics';

/** Save an event as an `.ics` file named after its title. */
export async function downloadCalendarEventIcs(
  event: Pick<CalendarEvent, 'eventId' | 'title'>
) {
  const file = await fetchCalendarEventIcs(event.eventId);
  if (file.isErr()) {
    toast.failure('Failed to download event');
    return;
  }
  await downloadFile(file.value, `${eventDisplayTitle(event)}.ics`);
}