-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(admin): add user role management #4248
base: master
Are you sure you want to change the base?
Conversation
apps/ui/pages/admin.vue
Outdated
|
||
const users = ref<IUser[]>([]); | ||
const userCount = ref(0); | ||
const totalPages = ref(0); | ||
getUsers(); | ||
|
||
function updateCurrentPage(newPage: number) { | ||
currentPage.value = newPage; | ||
getUsers(); | ||
} | ||
|
||
const users = computed(() => data.value?.data._admin.users || []); | ||
const userCount = computed(() => data.value?.data._admin.userCount ?? 0); | ||
async function getUsers() { | ||
const { data, error } = await useFetch<IAdminResponse>("/api/graphql", { | ||
method: "post", | ||
body: { | ||
query: `{ _admin { users(limit: ${LIMIT}${offset.value}) { email, settings, {key, value} } userCount } }`, | ||
}, | ||
}); | ||
if (error.value) { | ||
console.log("Error loading users: ", error.value); | ||
// todo handle error see catalogue error page | ||
} | ||
users.value = data.value?.data._admin.users || []; | ||
userCount.value = data.value?.data._admin.userCount ?? 0; | ||
const divided = userCount.value / LIMIT; | ||
totalPages.value = | ||
userCount.value % LIMIT > 0 ? Math.floor(divided) + 1 : divided; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should should work, but by keeping the useFetch at the page level and using the 'refresh' or computed there is no need for a separate getUsers func and the setup code . This has the added value of exposing the dat, status, error refs at the page level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds cool, didn't get it to work that way though with the pagination.
Quality Gate passedIssues Measures |
What are the main changes you did:
how to test:
Other tests:
todo: