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:
Helena
2025-08-13 12:28:50 +03:00
committed by GitHub
parent ce7b04fda8
commit 3c6c86c7c8
32 changed files with 562 additions and 35 deletions

View File

@@ -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');
}