feat(MED-50): use account_params in dashboard

This commit is contained in:
2025-07-24 08:38:12 +03:00
parent 66760adc06
commit 349e3e3143
5 changed files with 57 additions and 18 deletions

View File

@@ -4,6 +4,10 @@ import { Database } from '@kit/supabase/database';
import { UserAnalysis } from '../types/accounts';
export type AccountWithParams = Database['medreport']['Tables']['accounts']['Row'] & {
account_params: Pick<Database['medreport']['Tables']['account_params']['Row'], 'weight' | 'height'> | null;
};
/**
* Class representing an API for interacting with user accounts.
* @constructor
@@ -17,11 +21,11 @@ class AccountsApi {
* @description Get the account data for the given ID.
* @param id
*/
async getAccount(id: string) {
async getAccount(id: string): Promise<AccountWithParams> {
const { data, error } = await this.client
.schema('medreport')
.from('accounts')
.select('*')
.select('*, account_params: account_params (weight, height)')
.eq('id', id)
.single();

View File

@@ -203,7 +203,15 @@ export type Database = {
recorded_at?: string
weight?: number | null
}
Relationships: []
Relationships: [
{
foreignKeyName: "account_params_account_id_fkey"
columns: ["account_id"]
isOneToOne: true
referencedRelation: "accounts"
referencedColumns: ["id"]
},
]
}
accounts: {
Row: {
@@ -297,13 +305,7 @@ export type Database = {
user_id?: string
}
Relationships: [
{
foreignKeyName: "accounts_memberships_account_id_fkey"
columns: ["account_id"]
isOneToOne: false
referencedRelation: "accounts"
referencedColumns: ["id"]
},
{
foreignKeyName: "accounts_memberships_account_id_fkey"
columns: ["account_id"]