Skip to content

Commit

Permalink
fix: due date nullable
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed Aug 9, 2023
1 parent 71943eb commit efed517
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions apps/files_reminders/src/services/reminderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,32 @@ import axios from '@nextcloud/axios'
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,
}
}

export const setReminder = async (fileId: number, dueDate: Date): Promise<[]> => {
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
}

0 comments on commit efed517

Please sign in to comment.