fix: fix edit role, fix edit user, fix add user, slicing detail permissions

This commit is contained in:
Mulia Nasution
2023-06-06 20:35:35 +07:00
parent b79a65dfcf
commit 8f138fa858
5 changed files with 367 additions and 24 deletions
+36 -4
View File
@@ -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'
}