feat(auth): add user and role management
This commit is contained in:
28
packages/web/src/hooks/useRole.ee.ts
Normal file
28
packages/web/src/hooks/useRole.ee.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import * as React from 'react';
|
||||
import { useLazyQuery } from '@apollo/client';
|
||||
import { IRole } from '@automatisch/types';
|
||||
|
||||
import { GET_ROLE } from 'graphql/queries/get-role.ee';
|
||||
|
||||
type QueryResponse = {
|
||||
getRole: IRole;
|
||||
}
|
||||
|
||||
export default function useRole(roleId?: string) {
|
||||
const [getRole, { data, loading }] = useLazyQuery<QueryResponse>(GET_ROLE);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (roleId) {
|
||||
getRole({
|
||||
variables: {
|
||||
id: roleId
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [roleId]);
|
||||
|
||||
return {
|
||||
role: data?.getRole,
|
||||
loading
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user