2024-08-28 17:25:11 +08:00

54 lines
1.1 KiB
TypeScript

declare type UserRole = 'root' | 'ro' | 'fo' | 'staff'
declare type UserPermission = {
id: number;
username: string;
role: string;
manual_payment: boolean;
bill_page: boolean;
apply_page: boolean;
complete_button: boolean;
confirm_button: boolean;
apply_button: boolean;
permission_edit: boolean;
}
declare type UserProfile = {
id: string | number;
token: string;
email: string;
username: string;
department: string;
exp: number;
expiration_time: string;
iat: number;
iss: string;
nbf: number;
type: string;
roles: UserRole[];
role: UserRole;
permissions:UserPermission | null;
origin_role?: UserRole;
}
declare interface AuthProps {
isLoggedIn: boolean;
isInitialized?: boolean;
user?: UserProfile | null;
token?: string | null;
}
declare type AuthContextType = {
isLoggedIn: boolean;
isInitialized?: boolean;
user?: UserProfile | null | undefined;
logout: () => Promise<void>;
mockLogin: () => Promise<void>;
login: (code: string, state: string) => Promise<void>;
updateUser: (user: Partial<UserProfile>) => Promise<void>;
};
declare type PermissionUserList = {
role_name: string;
username_list: string[];
}