feat(MED-97): update benefit stats view in dashboards

This commit is contained in:
2025-09-26 13:47:32 +03:00
parent fdc2e3e064
commit 1aeee0bc30
23 changed files with 518 additions and 374 deletions

View File

@@ -1,23 +1,25 @@
import { Database } from '@kit/supabase/database';
export type ApplicationRole =
Database['medreport']['Tables']['accounts']['Row']['application_role'];
export type ApplicationRole = Account['application_role'];
export enum ApplicationRoleEnum {
User = 'user',
Doctor = 'doctor',
SuperAdmin = 'super_admin',
}
export type AccountWithParams =
Database['medreport']['Tables']['accounts']['Row'] & {
accountParams:
| (Pick<
Database['medreport']['Tables']['account_params']['Row'],
'weight' | 'height'
> & {
isSmoker:
| Database['medreport']['Tables']['account_params']['Row']['is_smoker']
| null;
})
| null;
};
export type AccountParams =
Database['medreport']['Tables']['account_params']['Row'];
export type Account = Database['medreport']['Tables']['accounts']['Row'];
export type AccountWithParams = Account & {
accountParams:
| (Pick<AccountParams, 'weight' | 'height'> & {
isSmoker: AccountParams['is_smoker'] | null;
})
| null;
};
export type CompanyParams =
Database['medreport']['Tables']['company_params']['Row'];
export type BmiThresholds = Database['medreport']['Tables']['bmi_thresholds']['Row'];

View File

@@ -9,6 +9,7 @@
"devDependencies": {
"@hookform/resolvers": "^5.0.1",
"@kit/next": "workspace:*",
"@kit/accounts": "workspace:*",
"@kit/shared": "workspace:*",
"@kit/supabase": "workspace:*",
"@kit/tsconfig": "workspace:*",

View File

@@ -11,7 +11,7 @@ import { EllipsisVertical } from 'lucide-react';
import { useForm } from 'react-hook-form';
import { z } from 'zod';
import { Database } from '@kit/supabase/database';
import type { Account } from '@kit/accounts/types/accounts';
import { Button } from '@kit/ui/button';
import { Checkbox } from '@kit/ui/checkbox';
import {
@@ -44,8 +44,6 @@ import { AdminDeleteUserDialog } from './admin-delete-user-dialog';
import { AdminImpersonateUserDialog } from './admin-impersonate-user-dialog';
import { AdminResetPasswordDialog } from './admin-reset-password-dialog';
type Account = Database['medreport']['Tables']['accounts']['Row'];
const FiltersSchema = z.object({
type: z.enum(['all', 'team', 'personal']),
query: z.string().optional(),

View File

@@ -1,6 +1,6 @@
import { z } from 'zod';
import { Database } from '@kit/supabase/database';
import { ApplicationRole } from '@kit/accounts/types/accounts';
const ConfirmationSchema = z.object({
confirmation: z.custom<string>((value) => value === 'CONFIRM'),
@@ -19,9 +19,7 @@ export const DeleteAccountSchema = ConfirmationSchema.extend({
accountId: z.string().uuid(),
});
type ApplicationRoleType =
Database['medreport']['Tables']['accounts']['Row']['application_role'];
export const UpdateAccountRoleSchema = z.object({
accountId: z.string().uuid(),
role: z.string() as z.ZodType<ApplicationRoleType>,
role: z.string() as z.ZodType<ApplicationRole>,
});

View File

@@ -3,6 +3,7 @@ import 'server-only';
import { SupabaseClient } from '@supabase/supabase-js';
import { Database } from '@kit/supabase/database';
import type { ApplicationRole } from '@kit/accounts/types/accounts';
export function createAdminAccountsService(client: SupabaseClient<Database>) {
return new AdminAccountsService(client);
@@ -25,7 +26,7 @@ class AdminAccountsService {
async updateRole(
accountId: string,
role: Database['medreport']['Tables']['accounts']['Row']['application_role'],
role: ApplicationRole,
) {
const { error } = await this.adminClient
.schema('medreport')

View File

@@ -1,9 +1,7 @@
import { z } from 'zod';
import { getLogger } from '@kit/shared/logger';
import { Database } from '@kit/supabase/database';
type Account = Database['medreport']['Tables']['accounts']['Row'];
import type { Account } from '@kit/accounts/types/accounts';
export function createAccountWebhooksService() {
return new AccountWebhooksService();