2020-03-31 13:16:03 +02:00
|
|
|
import api from "builderStore/api"
|
2020-03-23 15:26:38 +01:00
|
|
|
|
2020-06-19 18:19:30 +02:00
|
|
|
export async function createUser(user) {
|
2020-06-18 17:59:31 +02:00
|
|
|
const CREATE_USER_URL = `/api/users`
|
2020-04-23 15:37:08 +02:00
|
|
|
const response = await api.post(CREATE_USER_URL, user)
|
2020-05-14 16:12:30 +02:00
|
|
|
return await response.json()
|
2020-03-24 17:17:10 +01:00
|
|
|
}
|
|
|
|
|
2020-10-09 19:49:23 +02:00
|
|
|
export async function saveRecord(record, tableId) {
|
|
|
|
const SAVE_RECORDS_URL = `/api/${tableId}/records`
|
2020-08-17 22:01:43 +02:00
|
|
|
const response = await api.post(SAVE_RECORDS_URL, record)
|
|
|
|
|
2020-03-23 15:26:38 +01:00
|
|
|
return await response.json()
|
|
|
|
}
|
|
|
|
|
2020-06-19 18:19:30 +02:00
|
|
|
export async function deleteRecord(record) {
|
2020-10-09 19:49:23 +02:00
|
|
|
const DELETE_RECORDS_URL = `/api/${record.tableId}/records/${record._id}/${record._rev}`
|
2020-03-23 15:26:38 +01:00
|
|
|
const response = await api.delete(DELETE_RECORDS_URL)
|
|
|
|
return response
|
2020-03-27 12:28:30 +01:00
|
|
|
}
|
|
|
|
|
2020-08-17 22:01:43 +02:00
|
|
|
export async function fetchDataForView(view) {
|
|
|
|
const FETCH_RECORDS_URL = `/api/views/${view.name}`
|
2020-03-12 15:23:29 +01:00
|
|
|
|
2020-03-23 15:26:38 +01:00
|
|
|
const response = await api.get(FETCH_RECORDS_URL)
|
|
|
|
return await response.json()
|
2020-05-07 11:53:34 +02:00
|
|
|
}
|