Skip to content

Commit

Permalink
Enumを使用してロールを参照するように修正
Browse files Browse the repository at this point in the history
  • Loading branch information
KentaHizume committed Jan 7, 2025
1 parent 116974d commit 0dac261
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* ユーザーのロールを表す文字列列挙型です。
*/
export enum Roles {
ADMIN = 'Admin',
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {
GetCatalogCategoriesResponse,
} from '@/generated/api-client';
import { useAuthenticationStore } from '@/stores/authentication/authentication';
import { Roles } from '@/shared/constants/roles';
const router = useRouter();
const customErrorHandler = useCustomErrorHandler();
Expand Down Expand Up @@ -213,7 +214,7 @@ onMounted(async () => {
<button
type="button"
class="rounded bg-blue-600 px-4 py-2 font-bold text-white hover:bg-blue-800 disabled:bg-blue-500 disabled:opacity-50"
:disabled="isInvalid() || !authenticationStore.isInRole('Admin')"
:disabled="isInvalid() || !authenticationStore.isInRole(Roles.ADMIN)"
@click="AddItem()"
>
追加
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type {
} from '@/generated/api-client';
import { useCustomErrorHandler } from '@/shared/error-handler/use-custom-error-handler';
import { useAuthenticationStore } from '@/stores/authentication/authentication';
import { Roles } from '@/shared/constants/roles';
const customErrorHandler = useCustomErrorHandler();
const authenticationStore = useAuthenticationStore();
Expand Down Expand Up @@ -62,7 +63,7 @@ const isInvalid = () => {
};
const hasAdminRole = () => {
return authenticationStore.isInRole('Admin');
return authenticationStore.isInRole(Roles.ADMIN);
};
/**
Expand Down

0 comments on commit 0dac261

Please sign in to comment.