Skip to content

Commit

Permalink
role
Browse files Browse the repository at this point in the history
  • Loading branch information
arily committed Oct 14, 2023
1 parent c4c30e6 commit 7b46557
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/pages/admin/users/[id].vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<script setup lang="ts">
import { CountryCode } from '~/def/country-code'
import { UserRole } from '~/def/user'
const app = useNuxtApp()
const { t } = useI18n()
const route = useRoute('admin-users-id')
const {
data:detail,
} = await app.$client.admin.userManagement.detail.useQuery(route.params.id)
function options<T extends Record<string, string>, TTr extends (key: keyof T, value: T[keyof T]) => string>(priv: T, translate: TTr = ((a: keyof T, b: T[keyof T]) => a) as TTr) {
return Object.entries(priv).map(([label, value]) => ({ label: translate(label, value as T[keyof T]), value }) as { label: ReturnType<TTr>; value: T[keyof T] })
}
</script>

<template>
Expand Down Expand Up @@ -54,5 +59,11 @@ const {
</select>
</div>
</div>
<div class="form-control">
<label class="label">
<span class="label-text">Roles</span>
</label>
<t-multi-select v-model="detail.roles" size="sm" :options="options(UserRole, (_, value) => t(localeKey.role(value)))" />
</div>
</div>
</template>

0 comments on commit 7b46557

Please sign in to comment.