MED-89: add analysis view with doctor summary (#68)
* add analysis view with doctor summary * remove console.log, also return null if analysis data missing * replace orders table eye with button
This commit is contained in:
22
app/home/(user)/_lib/server/load-user-analyses.ts
Normal file
22
app/home/(user)/_lib/server/load-user-analyses.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { cache } from 'react';
|
||||
|
||||
import { createAccountsApi } from '@kit/accounts/api';
|
||||
import { UserAnalysis } from '@kit/accounts/types/accounts';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
export type UserAnalyses = Awaited<ReturnType<typeof loadUserAnalyses>>;
|
||||
|
||||
/**
|
||||
* @name loadUserAnalyses
|
||||
* @description
|
||||
* Load the user's analyses. It's a cached per-request function that fetches the user workspace data.
|
||||
* It can be used across the server components to load the user workspace data.
|
||||
*/
|
||||
export const loadUserAnalyses = cache(analysesLoader);
|
||||
|
||||
async function analysesLoader(): Promise<UserAnalysis | null> {
|
||||
const client = getSupabaseServerClient();
|
||||
const api = createAccountsApi(client);
|
||||
|
||||
return api.getUserAnalyses();
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { cache } from 'react';
|
||||
|
||||
import { createAccountsApi } from '@kit/accounts/api';
|
||||
import { UserAnalysis } from '@kit/accounts/types/accounts';
|
||||
import { AnalysisResultDetails } from '@kit/accounts/types/accounts';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
export type UserAnalyses = Awaited<ReturnType<typeof loadUserAnalysis>>;
|
||||
@@ -9,14 +9,15 @@ export type UserAnalyses = Awaited<ReturnType<typeof loadUserAnalysis>>;
|
||||
/**
|
||||
* @name loadUserAnalysis
|
||||
* @description
|
||||
* Load the user's analyses. It's a cached per-request function that fetches the user workspace data.
|
||||
* It can be used across the server components to load the user workspace data.
|
||||
* Load the user's analysis based on id. It's a cached per-request function that fetches the user's analysis data.
|
||||
*/
|
||||
export const loadUserAnalysis = cache(analysisLoader);
|
||||
|
||||
async function analysisLoader(): Promise<UserAnalysis | null> {
|
||||
async function analysisLoader(
|
||||
analysisOrderId: number,
|
||||
): Promise<AnalysisResultDetails | null> {
|
||||
const client = getSupabaseServerClient();
|
||||
const api = createAccountsApi(client);
|
||||
|
||||
return api.getUserAnalysis();
|
||||
return api.getUserAnalysis(analysisOrderId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user