Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 1x 1x 1x 1x 1x 2x 1x 1x 1x 1x 1x 1x 1x | import api from './client'
export const habitsApi = {
list: () => api.get('/habits').then(r => r.data),
get: (id) => api.get(`/habits/${id}`).then(r => r.data),
create: (data) => api.post('/habits', data).then(r => r.data),
update: (id, data) => api.put(`/habits/${id}`, data).then(r => r.data),
delete: (id) => api.delete(`/habits/${id}`),
log: (id, data = {}) => api.post(`/habits/${id}/log`, data).then(r => r.data),
getLogs: (id, days = 30) => api.get(`/habits/${id}/logs?days=${days}`).then(r => r.data),
deleteLog: (habitId, logId) => api.delete(`/habits/${habitId}/logs/${logId}`),
getStats: () => api.get('/habits/stats').then(r => r.data),
getHabitStats: (id) => api.get(`/habits/${id}/stats`).then(r => r.data),
// Freezes
getFreezes: (habitId) => api.get(`/habits/${habitId}/freezes`).then(r => r.data),
addFreeze: (habitId, data) => api.post(`/habits/${habitId}/freezes`, data).then(r => r.data),
deleteFreeze: (habitId, freezeId) => api.delete(`/habits/${habitId}/freezes/${freezeId}`),
}
|