Add user list and edit pages.

This commit is contained in:
Yang Luo
2020-10-20 23:14:03 +08:00
parent 88fd1fda47
commit b5eb673c81
19 changed files with 827 additions and 16 deletions

View File

@ -0,0 +1,45 @@
import * as Setting from "../Setting";
export function getUsers(owner) {
return fetch(`${Setting.ServerUrl}/api/get-users?owner=${owner}`, {
method: "GET",
credentials: "include"
}).then(res => res.json());
}
export function getUser(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-user?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include"
}).then(res => res.json());
}
export function updateUser(owner, name, user) {
let newUser = Setting.deepCopy(user);
newUser.ticket = JSON.stringify(user.ticket);
return fetch(`${Setting.ServerUrl}/api/update-user?id=${owner}/${encodeURIComponent(name)}`, {
method: 'POST',
credentials: 'include',
body: JSON.stringify(newUser),
}).then(res => res.json());
}
export function addUser(user) {
let newUser = Setting.deepCopy(user);
newUser.ticket = JSON.stringify(user.ticket);
return fetch(`${Setting.ServerUrl}/api/add-user`, {
method: 'POST',
credentials: 'include',
body: JSON.stringify(newUser),
}).then(res => res.json());
}
export function deleteUser(user) {
let newUser = Setting.deepCopy(user);
newUser.ticket = JSON.stringify(user.ticket);
return fetch(`${Setting.ServerUrl}/api/delete-user`, {
method: 'POST',
credentials: 'include',
body: JSON.stringify(newUser),
}).then(res => res.json());
}