mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-16 13:23:45 +02:00
ui(admin): add user create and user update
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
import http from '@/api/http';
|
||||
import { User, rawDataToUser } from '@/api/admin/users/getUsers';
|
||||
import { Values } from '@/api/admin/users/updateUser';
|
||||
|
||||
export default (name: string, include: string[] = []): Promise<User> => {
|
||||
export type { Values };
|
||||
|
||||
export default (values: Values, include: string[] = []): Promise<User> => {
|
||||
const data = {};
|
||||
Object.keys(values).forEach(k => {
|
||||
// @ts-ignore
|
||||
data[k.replace(/[A-Z]/g, l => `_${l.toLowerCase()}`)] = values[k];
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
http.post('/api/application/users', {
|
||||
name,
|
||||
}, { params: { include: include.join(',') } })
|
||||
http.post('/api/application/users', data, { params: { include: include.join(',') } })
|
||||
.then(({ data }) => resolve(rawDataToUser(data)))
|
||||
.catch(reject);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user