Skip to content

Commit

Permalink
use createOption from utils
Browse files Browse the repository at this point in the history
  • Loading branch information
arily committed Apr 26, 2024
1 parent 0296913 commit de79fe4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/common/options/roles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { createOptions } from '~/common/utils'
import { UserRole } from '~/def/user'

export const variant: Record<UserRole, { class: string }> = {
Expand Down
5 changes: 1 addition & 4 deletions src/pages/admin/users/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ const { data: result, refresh, pending } = await useAsyncData(async () => {
const pages = computed(() => Math.ceil((result.value?.count || 0) / (result.value?.perPage ?? 10)))
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] })
}
function rewrite() {
const newURL = location.href.replace(location.search, '')
const searchParams = new URLSearchParams(search.value as any)
Expand Down Expand Up @@ -173,7 +170,7 @@ fr-FR:
</label>
<t-multi-select
v-model="search.roles" size="sm"
:options="options(UserRole, (_, value) => $t(localeKey.role(value)))"
:options="createOptions(UserRole, (_, value) => $t(localeKey.role(value)))"
/>
</div>
<div class="col-span-2 form-control disbaled">
Expand Down
1 change: 1 addition & 0 deletions src/pages/me/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const enum ChangePasswordState {
Succeed,
}
// @ts-expect-error I'll use it later
// eslint-disable-next-line antfu/no-const-enum, unused-imports/no-unused-vars
const enum ProfileState {
Errored,
Expand Down

0 comments on commit de79fe4

Please sign in to comment.