Refactor: Role 변경 관리자 매니저 에디터 뷰어로 확정
This commit is contained in:
parent
72372ebecd
commit
f258727684
@ -6,13 +6,14 @@ import { Input } from '../ui/input';
|
||||
import { Button } from '../ui/button';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select';
|
||||
|
||||
type Role = 'admin' | 'editor' | 'viewer';
|
||||
type Role = 'admin' | 'manager' | 'editor' | 'viewer';
|
||||
|
||||
const roles: Role[] = ['admin', 'editor', 'viewer'];
|
||||
const roles: Role[] = ['admin', 'manager', 'editor', 'viewer'];
|
||||
|
||||
const roleToStr: { [key in Role]: string } = {
|
||||
admin: '관리자',
|
||||
editor: '사용자',
|
||||
manager: '매니저',
|
||||
editor: '에디터',
|
||||
viewer: '뷰어',
|
||||
};
|
||||
|
||||
|
@ -6,17 +6,17 @@ import { Input } from '../ui/input';
|
||||
import { Button } from '../ui/button';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select';
|
||||
|
||||
type Role = 'admin' | 'editor' | 'viewer';
|
||||
type Role = 'admin' | 'manager' | 'editor' | 'viewer';
|
||||
|
||||
const roles: Role[] = ['admin', 'editor', 'viewer'];
|
||||
const roles: Role[] = ['admin', 'manager', 'editor', 'viewer'];
|
||||
|
||||
const roleToStr: { [key in Role]: string } = {
|
||||
admin: '관리자',
|
||||
manager: '매니저',
|
||||
editor: '에디터',
|
||||
viewer: '뷰어',
|
||||
};
|
||||
|
||||
// Adjusted form schema to match the required Role type
|
||||
const formSchema = z.object({
|
||||
members: z.array(
|
||||
z.object({
|
||||
@ -50,6 +50,12 @@ export default function MemberManageForm({ members, onSubmit }: MemberManageForm
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const roleOrder: Role[] = ['admin', 'manager', 'editor', 'viewer'];
|
||||
|
||||
const sortedGroupedMembers = Object.entries(groupedMembers).sort(
|
||||
([roleA], [roleB]) => roleOrder.indexOf(roleA as Role) - roleOrder.indexOf(roleB as Role)
|
||||
);
|
||||
|
||||
return (
|
||||
<Form {...form}>
|
||||
<form
|
||||
@ -57,7 +63,7 @@ export default function MemberManageForm({ members, onSubmit }: MemberManageForm
|
||||
className="flex flex-col gap-5"
|
||||
>
|
||||
<div className="flex w-[530px] flex-col gap-[var(--size-space-200)]">
|
||||
{Object.entries(groupedMembers).map(([role, groupMembers]) => {
|
||||
{sortedGroupedMembers.map(([role, groupMembers]) => {
|
||||
if (!groupMembers || groupMembers.length === 0) return null;
|
||||
|
||||
return (
|
||||
|
@ -20,8 +20,8 @@ export const Default: Story = {
|
||||
members: [
|
||||
{ email: 'admin1@example.com', role: 'admin' },
|
||||
{ email: 'admin2@example.com', role: 'admin' },
|
||||
{ email: 'viewer1@example.com', role: 'viewer' },
|
||||
{ email: 'viewer2@example.com', role: 'viewer' },
|
||||
{ email: 'manager1@example.com', role: 'manager' },
|
||||
{ email: 'manager2@example.com', role: 'manager' },
|
||||
{ email: 'viewer3@example.com', role: 'viewer' },
|
||||
{ email: 'editor1@example.com', role: 'editor' },
|
||||
{ email: 'editor2@example.com', role: 'editor' },
|
||||
|
@ -1,7 +1,7 @@
|
||||
import MemberManageForm, { MemberManageFormValues } from './MemberManageForm';
|
||||
import XIcon from '@/assets/icons/x.svg?react';
|
||||
|
||||
type Role = 'admin' | 'editor' | 'viewer';
|
||||
type Role = 'admin' | 'manager' | 'editor' | 'viewer';
|
||||
|
||||
interface Member {
|
||||
email: string;
|
||||
|
Loading…
Reference in New Issue
Block a user