fix: fix edit role, fix edit user, fix add user, slicing detail permissions
This commit is contained in:
@@ -92,32 +92,64 @@ import DxDataGrid, {
|
||||
DxRequiredRule
|
||||
} from "devextreme-vue/data-grid";
|
||||
import CustomStore from "devextreme/data/custom_store";
|
||||
import { ref } from "vue"
|
||||
import notify from 'devextreme/ui/notify';
|
||||
|
||||
const URL = process.env.VUE_APP_ROOT_API+'/roles';
|
||||
const data = ref([])
|
||||
|
||||
const dataSource = new CustomStore({
|
||||
key: 'id',
|
||||
|
||||
load: () => {
|
||||
return fetch(URL+process.env.VUE_APP_PAGE_SIZE)
|
||||
load: async () => {
|
||||
return await fetch(URL+process.env.VUE_APP_PAGE_SIZE)
|
||||
.then((response) => response.json())
|
||||
.then((response) => {
|
||||
data.value = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(() => { throw new Error('Terdapat kesalahan memuat data'); });
|
||||
},
|
||||
|
||||
insert: (values) => {
|
||||
return fetch(URL, {
|
||||
fetch(URL, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(values),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then((resp) => {
|
||||
return resp.json()
|
||||
}).then(resp => {
|
||||
if (resp.code) {
|
||||
notify({
|
||||
message: resp.title,
|
||||
position: {
|
||||
my: 'center top',
|
||||
at: 'center top',
|
||||
},
|
||||
}, 'error', 3000);
|
||||
} else {
|
||||
notify({
|
||||
message: 'Data Berhasil Dibuat',
|
||||
position: {
|
||||
my: 'center top',
|
||||
at: 'center top',
|
||||
},
|
||||
}, 'success', 3000);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
update: (key, values) => {
|
||||
const findData = data.value.find(item => item.id === key)
|
||||
const payload = {
|
||||
...findData,
|
||||
...values
|
||||
}
|
||||
return fetch(URL + "/" + encodeURIComponent(key), {
|
||||
method: "PUT",
|
||||
body: JSON.stringify(values),
|
||||
body: JSON.stringify(payload),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user