Files
nice-app-web/src/types/auth.ts
focp212@naver.com 05238b04c1 첫 커밋
2025-09-05 15:36:48 +09:00

62 lines
1.2 KiB
TypeScript

export interface LoginCredentials {
email: string;
password: string;
}
export interface RegisterData {
email: string;
password: string;
name: string;
phone?: string;
}
export interface UserInfo {
id: string;
email: string;
name: string;
phone?: string;
role: UserRole;
createdAt: string;
updatedAt: string;
}
export enum UserRole {
ADMIN = 'admin',
USER = 'user',
MERCHANT = 'merchant'
}
export interface JWTPayload {
userId: string;
email: string;
role: UserRole;
iat: number;
exp: number;
}
export interface AuthState {
isAuthenticated: boolean;
user: UserInfo | null;
token: string | null;
isLoading: boolean;
}
export interface AuthContextType extends AuthState {
login: (credentials: LoginCredentials) => Promise<void>;
register: (data: RegisterData) => Promise<void>;
logout: () => void;
refreshToken: () => Promise<void>;
hasRole: (role: UserRole) => boolean;
hasPermission: (permission: string) => boolean;
}
// Type aliases for React Query hooks
export type User = UserInfo;
export interface UserPermission {
id: string;
name: string;
description?: string;
resource: string;
action: string;
}