1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-23 09:32:29 +01:00
Pterodactyl-Panel/resources/scripts/state/permissions.ts
2020-07-04 18:30:50 -07:00

32 lines
843 B
TypeScript

import { action, Action, thunk, Thunk } from 'easy-peasy';
import getSystemPermissions from '@/api/getSystemPermissions';
export interface PanelPermissions {
[key: string]: {
description: string;
keys: { [k: string]: string };
};
}
export interface GloablPermissionsStore {
data: PanelPermissions;
setPermissions: Action<GloablPermissionsStore, PanelPermissions>;
getPermissions: Thunk<GloablPermissionsStore, void, Record<string, unknown>, any, Promise<void>>;
}
const permissions: GloablPermissionsStore = {
data: {},
setPermissions: action((state, payload) => {
state.data = payload;
}),
getPermissions: thunk(async (actions) => {
const permissions = await getSystemPermissions();
actions.setPermissions(permissions);
}),
};
export default permissions;