[feat] negodata: 권한 3단계(개발자 신설)·개발자 메뉴 그룹·디자인 시스템 페이지

- UserRole 1=일반 2=최고관리자 3=개발자(내부 운영). 개발자 계정은 회원 목록·총계에서 제외해 고객사에 노출하지 않음
- 계정 생성 시 권한 선택(일반/최고관리자) 추가, 개발자는 앱에서 부여 불가(DB 시드 전용)
- 사이드바 '개발자' 그룹 신설 — 회사 설정·디자인 시스템을 개발자에게만 노출
- /dev/design 디자인 시스템 페이지: 색 토큰·타이포·버튼·배지·입력·반경, 목록 화면 구조, 반응형 기준, URL 상태 규칙, 회사 커스터마이징 훅
- 공급사 재협상 요청(#15) 플로우 문서 — sessions.custom 기반(DDL 0)
This commit is contained in:
minaChoi committed 2026-07-23 15:41:36 +09:00
1 parent db07a60cfa
commit cfee6e89d0
20 files changed
+469 -43

No files matched your search

@@ -11,4 +11,5 @@ export interface ReqCreateCompanyUser {
name?: string;
email?: string;
contact_number?: string;
role?: number;
}
@@ -6,9 +6,9 @@
*/
/**
* users.role 코드값. negodata 유저는 전부 회사 직원(관리자측) —
의미 있는 구분은 '직원 계정 관리 권한 유무' 하나뿐이라 2단계로 둔다.
1=일반, 2=최고관리자(직원 계정 생성·관리).
* users.role 코드값.
1=일반, 2=최고관리자(고객사 최상위), 3=개발자(우리 내부 운영 계정).
개발자 계정은 고객사에 존재를 노출하지 않는다 — 회원 목록에서 빼고 총계에도 넣지 않는다.
*/
export type UserRole = typeof UserRole[keyof typeof UserRole];
@@ -17,4 +17,5 @@ export type UserRole = typeof UserRole[keyof typeof UserRole];
export const UserRole = {
USER: 1,
OWNER: 2,
DEVELOPER: 3,
} as const;
+12 -2
View File
@@ -7,6 +7,7 @@ import LoginPage from '../pages/login';
import DashboardPage from '../pages/dashboard';
import StatisticsPage from '../pages/statistics';
import ForbiddenPage from '../pages/forbidden';
import DevDesignPage from '../pages/dev-design';
import NotFoundPage from '../pages/not-found';
import ProductsPage from '../pages/products';
import PartnersPage from '../pages/partners';
@@ -88,16 +89,25 @@ export const router = createBrowserRouter([
path: 'members',
loader: async () => {
await initAuth();
return hasRole('최고관리자') ? null : redirect('/forbidden');
return hasRole('최고관리자', '개발자') ? null : redirect('/forbidden');
},
Component: MembersPage,
},
{
// 개발자 전용. 디자인 토큰·컴포넌트 기준 화면.
path: 'dev/design',
loader: async () => {
await initAuth();
return hasRole('개발자') ? null : redirect('/forbidden');
},
Component: DevDesignPage,
},
{
// 최고관리자 전용. 회사 브랜딩/용어/커스텀필드 설정. (자식 loader 는 부모와 병렬 → initAuth 대기 필수)
path: 'settings',
loader: async () => {
await initAuth();
return hasRole('최고관리자') ? null : redirect('/forbidden');
return hasRole('최고관리자', '개발자') ? null : redirect('/forbidden');
},
Component: SettingsPage,
},
@@ -13,6 +13,7 @@ const PAGE_TO_PATH: Record<PageType, string> = {
CARDS: '/cards',
MEMBERS: '/members',
SETTINGS: '/settings',
DESIGN: '/dev/design',
NOTIFICATIONS: '/notifications',
};
@@ -26,6 +26,7 @@ import {
Sun,
Moon,
Building,
Palette,
ChevronRight,
Menu,
X,
@@ -41,9 +42,9 @@ interface LayoutProps {
type SidebarUser = ReturnType<typeof useAuth>['user'];
type MenuItem = { type: PageType; label: string; icon: ElementType; id: string; ownerOnly?: boolean };
type MenuItem = { type: PageType; label: string; icon: ElementType; id: string; ownerOnly?: boolean; devOnly?: boolean };
// ownerOnly 항목은 최고관리자에게만 노출된다(렌더 시 user.role 로 필터).
// ownerOnly = 최고관리자 이상, devOnly = 개발자(내부 운영)만. 렌더 시 user.role 로 필터한다.
// 그룹 라벨은 사이드바 섹션 헤더로 노출(접힘 상태에선 숨김).
const menuGroups: { label?: string; items: MenuItem[] }[] = [
{
@@ -65,13 +66,26 @@ const menuGroups: { label?: string; items: MenuItem[] }[] = [
label: '관리',
items: [
{ type: 'MEMBERS', label: '회원관리', icon: UserCog, id: 'sidebar-members', ownerOnly: true },
{ type: 'SETTINGS', label: '회사 설정', icon: Building, id: 'sidebar-settings', ownerOnly: true },
],
},
{
label: '개발자',
items: [
{ type: 'SETTINGS', label: '회사 설정', icon: Building, id: 'sidebar-settings', devOnly: true },
{ type: 'DESIGN', label: '디자인 시스템', icon: Palette, id: 'sidebar-design', devOnly: true },
],
},
];
const menuItems: MenuItem[] = menuGroups.flatMap((g) => g.items);
// 메뉴 노출 판정 — devOnly 는 개발자만, ownerOnly 는 최고관리자 이상.
const canSee = (item: MenuItem, role?: string): boolean => {
if (item.devOnly) return role === '개발자';
if (item.ownerOnly) return role === '최고관리자' || role === '개발자';
return true;
};
const pageLabelMap: Record<PageType, string> = {
DASHBOARD: '대시보드',
STATISTICS: '통계',
@@ -81,6 +95,7 @@ const pageLabelMap: Record<PageType, string> = {
CARDS: '협상카드관리',
MEMBERS: '회원관리',
SETTINGS: '회사 설정',
DESIGN: '디자인 시스템',
NOTIFICATIONS: '알림',
};
@@ -100,7 +115,7 @@ export default function Layout({ children, currentPage, setPage, onLogout }: Lay
// 사이드바 펼침 여부(라벨/프로필 노출 기준). 모바일 드로어는 항상 펼친 상태로 본다.
const expanded = isMobileOpen || isSidebarOpen;
const visibleItems = menuItems.filter((item) => !item.ownerOnly || user?.role === '최고관리자');
const visibleItems = menuItems.filter((item) => canSee(item, user?.role));
// ⌘K / Ctrl+K 로 빠른 이동 열기
useEffect(() => {
@@ -196,7 +211,7 @@ export default function Layout({ children, currentPage, setPage, onLogout }: Lay
{/* Nav Items */}
<nav className="mt-1 px-3 overflow-y-auto">
{menuGroups.map((group, gi) => {
const items = group.items.filter((item) => !item.ownerOnly || user?.role === '최고관리자');
const items = group.items.filter((item) => canSee(item, user?.role));
if (items.length === 0) return null;
return (
<div key={group.label ?? gi} className="space-y-0.5">
@@ -10,6 +10,8 @@ import { Input } from '@/components/ui/input';
import { PhoneInput } from '@/components/ui/phone-input';
import { Sheet } from '@/components/ui/sheet';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
import { UserRole } from '@/api/generated/model';
import { USER_ROLE_LABEL } from '@/lib/enumLabels';
import {
UserStatus,
USER_STATUS_LABEL,
@@ -27,6 +29,7 @@ const schema = z.object({
email: z.string().trim().email('이메일 형식을 확인해 주십시오.').or(z.literal('')),
contactNumber: z.string().trim(),
status: z.number(),
role: z.number(),
});
type FormValues = z.infer<typeof schema>;
@@ -51,9 +54,10 @@ function buildDefaults(mode: 'create' | 'edit', member: Member | null): FormValu
email: member.email ?? '',
contactNumber: normalizePhone(member.contact_number ?? ''),
status: member.status,
role: member.role,
};
}
return { id: '', password: '', passwordConfirm: '', name: '', email: '', contactNumber: '', status: UserStatus.ACTIVE };
return { id: '', password: '', passwordConfirm: '', name: '', email: '', contactNumber: '', status: UserStatus.ACTIVE, role: UserRole.USER };
}
const inputClass = 'text-foreground text-xs';
@@ -101,6 +105,7 @@ export function MemberFormSheet({
name: v.name.trim() || undefined,
email: v.email.trim() || undefined,
contact_number: v.contactNumber.trim() || undefined,
role: v.role,
});
showToast('신규 계정이 생성되었습니다.', 'success');
onClose();
@@ -174,6 +179,32 @@ export function MemberFormSheet({
<Typography as="label" variant="label">이름</Typography>
<Input id="form-member-name" type="text" {...register('name')} className={inputClass} placeholder="김직원" />
</div>
{/* 권한 (create 전용) — 최고관리자는 앱에서 부여 불가 */}
{mode === 'create' && (
<div className="space-y-1">
<Typography as="label" variant="label">권한</Typography>
<Controller
control={control}
name="role"
render={({ field }) => (
<Select value={String(field.value)} onValueChange={(v) => field.onChange(Number(v))}>
<SelectTrigger id="form-member-role" className="w-full">
<SelectValue>
{(value) => USER_ROLE_LABEL[Number(value) as UserRole] ?? ''}
</SelectValue>
</SelectTrigger>
<SelectContent>
{[UserRole.USER, UserRole.OWNER].map((r) => (
<SelectItem key={r} value={String(r)}>
{USER_ROLE_LABEL[r]}
</SelectItem>
))}
</SelectContent>
</Select>
)}
/>
</div>
)}
{/* 상태 (edit 전용) */}
{mode === 'edit' && (
<div className="space-y-1">
@@ -27,6 +27,7 @@ export interface ReqCreateCompanyUser {
name?: string;
email?: string;
contact_number?: string;
role?: number; // 1=일반 2=관리자. 최고관리자(3)는 앱에서 부여 불가
}
export interface ReqUpdateCompanyUser {
+1
View File
@@ -23,6 +23,7 @@ export const DELIVERY_TYPE_OPTIONS = Object.values(DeliveryType).map((value) =>
export const USER_ROLE_LABEL: Record<UserRole, string> = {
[UserRole.USER]: '일반',
[UserRole.OWNER]: '최고관리자',
[UserRole.DEVELOPER]: '개발자',
};
export const SUPPLIER_TYPE_LABEL: Record<SupplierType, string> = {
+193
View File
@@ -0,0 +1,193 @@
import { PageContainer } from '@/components/layout/PageContainer';
import { Typography, typographyVariants } from '@/components/ui/typography';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import { Input } from '@/components/ui/input';
import { StatusPill } from '@/features/quotations/components/QuotationDetailSheet/StatusPill';
import { cn } from '@/lib/utils';
// 개발자 전용 디자인 시스템 페이지(/dev/design).
// 토큰·타이포·컴포넌트 변형을 한 화면에서 대조해 새 화면을 만들 때 기준을 맞춘다.
// 여기 없는 스타일을 새로 만들지 말고, 필요하면 토큰/변형을 먼저 늘린다.
const COLOR_TOKENS: { name: string; className: string; note: string }[] = [
{ name: 'primary', className: 'bg-primary', note: '주요 액션·선택 상태' },
{ name: 'secondary', className: 'bg-secondary', note: '보조 버튼' },
{ name: 'muted', className: 'bg-muted', note: '표 헤더·비활성 배경' },
{ name: 'card', className: 'bg-card border border-border', note: '카드 면' },
{ name: 'destructive', className: 'bg-destructive', note: '삭제·경고' },
{ name: 'success', className: 'bg-success', note: '낙찰·성공' },
{ name: 'warning', className: 'bg-warning', note: '주의' },
{ name: 'info', className: 'bg-info', note: '정보' },
];
const TYPO_VARIANTS = ['h1', 'h2', 'h3', 'h4', 'body', 'small', 'muted', 'label', 'mono', 'caption', 'link'] as const;
const BUTTON_VARIANTS = ['default', 'outline', 'secondary', 'ghost', 'destructive', 'link'] as const;
const BUTTON_SIZES = ['sm', 'default', 'lg'] as const;
const RADII: { name: string; className: string; use: string }[] = [
{ name: 'rounded-md', className: 'rounded-md', use: '입력·작은 버튼' },
{ name: 'rounded-lg', className: 'rounded-lg', use: '카드·테이블 컨테이너' },
{ name: 'rounded-full', className: 'rounded-full', use: '배지·아바타' },
];
export default function DevDesignPage() {
return (
<PageContainer>
<Section title="색 토큰" desc="직접 hex 를 쓰지 말고 토큰 클래스를 쓴다. 다크모드가 토큰에서 갈린다.">
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
{COLOR_TOKENS.map((c) => (
<div key={c.name} className="space-y-1.5">
<div className={cn('h-14 w-full rounded-lg', c.className)} />
<Typography as="span" variant="label" className="block">{c.name}</Typography>
<Typography as="span" variant="caption" className="block">{c.note}</Typography>
</div>
))}
</div>
</Section>
<Section title="타이포그래피" desc="모든 텍스트는 Typography 컴포넌트로 쓴다. 여기 없는 크기를 직접 박지 않는다.">
<div className="space-y-3">
{TYPO_VARIANTS.map((v) => (
<div key={v} className="flex flex-wrap items-baseline gap-3 border-b border-border/50 pb-2">
<code className="w-24 shrink-0 font-mono text-[11px] text-muted-foreground">{v}</code>
<Typography variant={v}>다람쥐 헌 쳇바퀴에 타고파 · Negotium 0123</Typography>
</div>
))}
</div>
</Section>
<Section title="버튼" desc="variant × size 조합. 아이콘은 lucide-react 를 쓰고 크기는 13~16px.">
<div className="space-y-3">
{BUTTON_VARIANTS.map((v) => (
<div key={v} className="flex flex-wrap items-center gap-2">
<code className="w-24 shrink-0 font-mono text-[11px] text-muted-foreground">{v}</code>
{BUTTON_SIZES.map((size) => (
<Button key={size} variant={v} size={size}>{size}</Button>
))}
<Button variant={v} disabled>disabled</Button>
</div>
))}
</div>
</Section>
<Section title="배지 · 상태" desc="배지는 정적 라벨, StatusPill 은 진행 상태(색이 의미를 가진다).">
<div className="flex flex-wrap items-center gap-2">
<Badge>default</Badge>
<Badge variant="secondary">secondary</Badge>
<Badge variant="outline">outline</Badge>
<Badge variant="destructive">destructive</Badge>
</div>
<div className="mt-3 flex flex-wrap items-center gap-2">
<StatusPill tone="zinc">대기</StatusPill>
<StatusPill tone="blue">진행중</StatusPill>
<StatusPill tone="emerald">완료</StatusPill>
<StatusPill tone="amber">주의</StatusPill>
<StatusPill tone="rose">거절</StatusPill>
</div>
</Section>
<Section title="입력" desc="폼은 react-hook-form + zod. 라벨은 Typography variant='label'.">
<div className="grid gap-3 sm:grid-cols-2">
<div className="space-y-1">
<Typography as="label" variant="label">기본</Typography>
<Input placeholder="입력하세요" />
</div>
<div className="space-y-1">
<Typography as="label" variant="label">비활성</Typography>
<Input placeholder="비활성" disabled />
</div>
</div>
</Section>
<Section title="반경" desc="위계별로 갈린다 — 섞어 쓰면 화면이 흐트러진다.">
<div className="flex flex-wrap gap-4">
{RADII.map((r) => (
<div key={r.name} className="space-y-1.5">
<div className={cn('h-14 w-24 border border-border bg-muted', r.className)} />
<Typography as="span" variant="label" className="block">{r.name}</Typography>
<Typography as="span" variant="caption" className="block">{r.use}</Typography>
</div>
))}
</div>
</Section>
<Section title="목록 화면 구조" desc="툴바와 테이블을 한 카드로 붙인다(포털형). 페이지마다 새로 짜지 말 것.">
<pre className="overflow-x-auto rounded-lg border border-border bg-muted/40 p-3 font-mono text-[11px] leading-relaxed text-foreground">{`<PageContainer>
<div className="overflow-hidden rounded-lg border border-border bg-card">
<PageToolbar className="rounded-none border-0 border-b border-border" actions={...}>
<SearchInput ... /> {/* 필터 Select 도 여기 */}
</PageToolbar>
<XxxTable className="rounded-none border-0" ... />
</div>
</PageContainer>`}</pre>
<Typography variant="caption" className="mt-2 block">
상품·협력사·견적·협상카드·회원 5개 목록이 이 구조를 공유한다.
</Typography>
</Section>
<Section title="반응형 기준" desc="목록 화면은 lg(1024px)에서 표 ↔ 카드로 갈린다.">
<ul className="space-y-1.5">
{[
'DataTable: lg 이상 표(가로 넘치면 overflow-x-auto), 미만 카드 리스트',
'PageToolbar: lg 이상 한 줄, 미만 검색/필터·액션 2줄(각각 flex-wrap)',
'견적 상세 협상현황: lg 이상 13컬럼 표, 미만 세션별 카드',
'컨테이너 쿼리(@container)는 쓰지 않는다 — 감싸는 래퍼가 생기면 전환 지점이 흔들린다',
].map((t) => (
<li key={t} className="flex gap-2">
<span className="text-muted-foreground">·</span>
<Typography as="span" variant="small">{t}</Typography>
</li>
))}
</ul>
</Section>
<Section title="링크" desc="react-router Link 에는 typographyVariants({ variant: 'link' }) 를 합성한다.">
<a href="#" className={cn(typographyVariants({ variant: 'link' }), 'text-sm font-semibold')}>
링크 텍스트 예시
</a>
</Section>
<Section title="화면 상태 · URL" desc="시트/모달/탭 상태는 URL 쿼리로 남긴다 — 새로고침·링크 공유·빠른이동(⌘K)에서 살아난다.">
<ul className="space-y-1.5">
{[
'상세 시트: ?detail=<id> 신규: ?new 모달: ?modal=<key>',
'탭: ?tab=<key> (회사 설정), ?guide=<key> (이용안내)',
'useOverlay().open(key, id) 또는 <Link to="?detail=..."> 둘 다 쓰인다 — 키 이름 바꿀 땐 양쪽 grep',
].map((t) => (
<li key={t} className="flex gap-2">
<span className="text-muted-foreground">·</span>
<Typography as="span" variant="small" className="font-mono text-[11px]">{t}</Typography>
</li>
))}
</ul>
</Section>
<Section title="회사 커스터마이징" desc="라벨·숨김은 코드가 아니라 회사 설정(DB)에서 온다. 하드코딩 금지.">
<ul className="space-y-1.5">
{[
"용어: const label = useLabels(); label('item.price') — 카탈로그(catalog.ts)에 키를 먼저 추가",
"숨김: const isHidden = useHiddenFields(); isHidden('selling_price') — 목록·폼·엑셀 3곳 모두 반영",
'브랜딩: useBranding() — 서비스명·로고·색상',
].map((t) => (
<li key={t} className="flex gap-2">
<span className="text-muted-foreground">·</span>
<Typography as="span" variant="small" className="font-mono text-[11px]">{t}</Typography>
</li>
))}
</ul>
</Section>
</PageContainer>
);
}
function Section({ title, desc, children }: { title: string; desc: string; children: React.ReactNode }) {
return (
<section className="rounded-lg border border-border bg-card p-4">
<Typography variant="h4">{title}</Typography>
<Typography variant="caption" className="mt-0.5 mb-4 block">{desc}</Typography>
{children}
</section>
);
}
+1 -1
View File
@@ -1,6 +1,6 @@
import {create} from 'zustand';
export type UserRole = '최고관리자' | '일반';
export type UserRole = '개발자' | '최고관리자' | '일반';
export interface AuthUser {
userId: string;
+1 -1
View File
@@ -37,4 +37,4 @@ export interface NegotiationCard {
usedCount: number; // 카드 사용 세션 수(표본)
}
export type PageType = 'DASHBOARD' | 'STATISTICS' | 'PRODUCTS' | 'PARTNERS' | 'QUOTATION' | 'CARDS' | 'MEMBERS' | 'SETTINGS' | 'NOTIFICATIONS';
export type PageType = 'DASHBOARD' | 'STATISTICS' | 'PRODUCTS' | 'PARTNERS' | 'QUOTATION' | 'CARDS' | 'MEMBERS' | 'SETTINGS' | 'DESIGN' | 'NOTIFICATIONS';