MED-109: add doctor role and basic view (#45)
* MED-109: add doctor role and basic view * add role to accounts * remove old super admin and doctor sql
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
DeleteUserSchema,
|
||||
ImpersonateUserSchema,
|
||||
ReactivateUserSchema,
|
||||
UpdateAccountRoleSchema,
|
||||
} from './schema/admin-actions.schema';
|
||||
import { CreateCompanySchema } from './schema/create-company.schema';
|
||||
import { CreateUserSchema } from './schema/create-user.schema';
|
||||
@@ -273,6 +274,32 @@ export const createCompanyAccountAction = enhanceAction(
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* @name updateRoleAction
|
||||
* @description Update application role for user
|
||||
*/
|
||||
export const updateRoleAction = adminAction(
|
||||
enhanceAction(
|
||||
async ({ accountId, role }) => {
|
||||
const service = getAdminAccountsService();
|
||||
const logger = await getLogger();
|
||||
|
||||
logger.info({ accountId }, `Super Admin is updating account role...`);
|
||||
|
||||
await service.updateRole(accountId, role);
|
||||
|
||||
logger.info({ accountId }, `Successfully changed role`);
|
||||
|
||||
revalidateAdmin();
|
||||
|
||||
return { success: true };
|
||||
},
|
||||
{
|
||||
schema: UpdateAccountRoleSchema,
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
function revalidateAdmin() {
|
||||
revalidatePath('/admin', 'layout');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user