2020-12-28 10:08:08 -07:00
|
|
|
import http from '@/api/http';
|
2021-01-06 16:38:39 -07:00
|
|
|
import { Role, rawDataToRole } from '@/api/admin/roles/getRoles';
|
2020-12-28 10:08:08 -07:00
|
|
|
|
|
|
|
export default (name: string, description?: string): Promise<Role> => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
http.post('/api/application/roles', {
|
|
|
|
name, description,
|
|
|
|
})
|
2021-01-06 16:38:39 -07:00
|
|
|
.then(({ data }) => resolve(rawDataToRole(data)))
|
2020-12-28 10:08:08 -07:00
|
|
|
.catch(reject);
|
|
|
|
});
|
|
|
|
};
|