import api from './index'

export type ReminderStatus = 'pending' | 'done'

export interface Reminder {
  id: string
  title: string
  note: string | null
  reminder_at: string
  status: ReminderStatus
  is_dismissed: boolean
  created_at: string
  updated_at: string
}

export interface ReminderListResponse {
  items: Reminder[]
}

export const reminderApi = {
  list(date: string) {
    return api.get<ReminderListResponse>('/api/reminders', { params: { date_str: date } })
  },

  create(data: { title: string; reminder_at: string; note?: string }) {
    return api.post<Reminder>('/api/reminders', data)
  },

  update(id: string, data: Partial<Pick<Reminder, 'title' | 'note' | 'reminder_at' | 'status' | 'is_dismissed'>>) {
    return api.patch<Reminder>(`/api/reminders/${id}`, data)
  },

  delete(id: string) {
    return api.delete(`/api/reminders/${id}`)
  },
}
