import { Action, ActionPanel, Detail, Icon, List, getPreferenceValues, openExtensionPreferences } from "@raycast/api"; import { GoogleMailNotificationListItem } from "./integrations/google-mail/listitem/GoogleMailNotificationListItem"; import { TodoistNotificationListItem } from "./integrations/todoist/listitem/TodoistNotificationListItem"; import { GithubNotificationListItem } from "./integrations/github/listitem/GithubNotificationListItem"; import { LinearNotificationListItem } from "./integrations/linear/listitem/LinearNotificationListItem"; import { SlackNotificationListItem } from "./integrations/slack/listitem/SlackNotificationListItem"; import { Notification, NotificationListItemProps, NotificationSourceKind } from "./notification"; import { NotificationActions } from "./action/NotificationActions"; import { Page, UniversalInboxPreferences } from "./types"; import { useFetch } from "@raycast/utils"; import { useState } from "react"; export default function Command() { const preferences = getPreferenceValues(); if ( preferences.apiKey === undefined || preferences.apiKey === "" || preferences.universalInboxBaseUrl === undefined || preferences.universalInboxBaseUrl === "" ) { return ( } /> ); } const [notificationKind, setNotificationKind] = useState(""); const { isLoading, data, mutate } = useFetch>( `${preferences.universalInboxBaseUrl.replace(/\/$/, "")}/api/notifications?status=Unread,Read&with_tasks=true${ notificationKind ? "¬ification_kind=" + notificationKind : "" }`, { headers: { Authorization: `Bearer ${preferences.apiKey}`, }, }, ); return ( } > {data?.content.length === 0 ? ( ) : ( data?.content.map((notification: Notification) => { return ; }) )} ); } function NotificationListItem({ notification, mutate }: NotificationListItemProps) { switch (notification.kind) { case NotificationSourceKind.Github: return ; case NotificationSourceKind.Linear: return ; case NotificationSourceKind.GoogleMail: return ; case NotificationSourceKind.Slack: return ; case NotificationSourceKind.Todoist: return ; default: return ; } } function DefaultNotificationListItem({ notification, mutate }: NotificationListItemProps) { return ( } mutate={mutate} /> } /> ); } interface NotificationKindDropdownProps { value: string; onNotificationKindChange: (newValue: string) => void; } function NotificationKindDropdown({ value, onNotificationKindChange }: NotificationKindDropdownProps) { return ( ); }