perubahan API update role User Tipe
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import {defineStore} from "pinia";
|
||||
import type {RoleMenuUser} from "~/types/setting/RoleMenuUser";
|
||||
import type {MessagesHandler} from "~/types/messagesHandler";
|
||||
|
||||
const messages = ref<MessagesHandler>({});
|
||||
@@ -9,24 +8,22 @@ export const useSettingStore = defineStore("SettingStore", () => {
|
||||
const listMenu = ref<any>([]);
|
||||
const getMenu = async () => {
|
||||
await $fetch("/api/setting/getListMenu", {
|
||||
method: "GET",
|
||||
// mode: "no-cors",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
method: "GET",
|
||||
})
|
||||
.then((res) => {
|
||||
listMenu.value = res
|
||||
console.log(listMenu.value);
|
||||
// console.log(listMenu.value);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const typeUser = ref<any>([]);
|
||||
const roleMenuById = ref<any>([]);
|
||||
const getRoleMenuById = async (body: Record<string, any>) => {
|
||||
typeUser.value = body;
|
||||
|
||||
await $fetch(`/api/setting/getRoleMenu`, {
|
||||
// mode: "no-cors",
|
||||
headers: {
|
||||
@@ -36,20 +33,19 @@ export const useSettingStore = defineStore("SettingStore", () => {
|
||||
body: JSON.stringify(body),
|
||||
}).then((res) => {
|
||||
roleMenuById.value = res;
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
const listTypeUser = ref<any>([]);
|
||||
const getTypeUser = async () => {
|
||||
await $fetch("/api/setting/getTipeUser", {
|
||||
method: "GET",
|
||||
// mode: 'no-cors',
|
||||
// headers: {
|
||||
// 'Access-Control-Allow-Origin': '*',
|
||||
// Accept: 'application/json',
|
||||
// 'Content-Type': 'application/json',
|
||||
// },
|
||||
method: "GET",
|
||||
})
|
||||
.then((res) => {
|
||||
listTypeUser.value = res
|
||||
@@ -57,12 +53,10 @@ export const useSettingStore = defineStore("SettingStore", () => {
|
||||
};
|
||||
|
||||
const postRoleUserMenu = async (body: Record<string, any>) => {
|
||||
// console.log('asdasdasd', body)
|
||||
const roleUserMenu = body.menus.map((item) => ({
|
||||
type_user_id: item.type_user_id,
|
||||
menu_id: item.menu_id,
|
||||
access: [
|
||||
// item.access
|
||||
{
|
||||
add: parseInt(item.access[0].value),
|
||||
update: parseInt(item.access[1].value),
|
||||
@@ -71,11 +65,11 @@ export const useSettingStore = defineStore("SettingStore", () => {
|
||||
}
|
||||
]
|
||||
}))
|
||||
await $fetch(`/api/setting/deleteRoleMenuUser`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({key: body.menus[0].type_user_id})
|
||||
}).then(async (res) => {
|
||||
// await $fetch(`/api/setting/deleteRoleMenuUser`, {
|
||||
// method: 'POST',
|
||||
// headers: {'Content-Type': 'application/json'},
|
||||
// body: JSON.stringify({key: body.menus[0].type_user_id})
|
||||
// }).then(async (res) => {
|
||||
await $fetch(`/api/setting/postRoleMenuUser`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
@@ -86,11 +80,11 @@ export const useSettingStore = defineStore("SettingStore", () => {
|
||||
messages.value.title = 'Akses User Sudah Disimpan'
|
||||
})
|
||||
.catch((err) => {
|
||||
// console.log(err)
|
||||
console.log(err)
|
||||
messages.value.type = 'error'
|
||||
messages.value.title = 'Akses User Tidak Berhasil Disimpan'
|
||||
})
|
||||
})
|
||||
// })
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user