import { generateOcsUrl } from '@nextcloud/router'
interface Reminder {
- dueDate: Date
+ dueDate: null | Date
}
export const getReminder = async (fileId: number): Promise<Reminder> => {
const url = generateOcsUrl('/apps/files_reminders/api/v1/get/{fileId}', { fileId })
const response = await axios.get(url)
+ const dueDate = response.data.dueDate ? new Date(response.data.dueDate) : null
return {
- dueDate: new Date(response.data.ocs.data.dueDate),
+ dueDate,
}
}
const url = generateOcsUrl('/apps/files_reminders/api/v1/set/{fileId}', { fileId })
const response = await axios.put(url, {
- dueDate: dueDate.toISOString(),
+ dueDate: dueDate.toISOString(), // timezone of string is always UTC
})
- return response.data.ocs.data
+ return response.data
}
export const clearReminder = async (fileId: number): Promise<[]> => {
const url = generateOcsUrl('/apps/files_reminders/api/v1/remove/{fileId}', { fileId })
const response = await axios.delete(url)
- return response.data.ocs.data
+ return response.data
}