Merge branch 'main' into MED-122

This commit is contained in:
2025-07-18 16:11:50 +03:00
28 changed files with 6608 additions and 391 deletions

View File

@@ -14,7 +14,8 @@
"./personal-account-settings": "./src/components/personal-account-settings/index.ts",
"./components": "./src/components/index.ts",
"./hooks/*": "./src/hooks/*.ts",
"./api": "./src/server/api.ts"
"./api": "./src/server/api.ts",
"./types/*": "./src/types/*.ts"
},
"dependencies": {
"nanoid": "^5.1.5"

View File

@@ -2,6 +2,8 @@ import { SupabaseClient } from '@supabase/supabase-js';
import { Database } from '@kit/supabase/database';
import { UserAnalysis } from '../types/accounts';
/**
* Class representing an API for interacting with user accounts.
* @constructor
@@ -169,6 +171,51 @@ class AccountsApi {
return response.data?.customer_id;
}
async getUserAnalysis(): Promise<UserAnalysis | null> {
const authUser = await this.client.auth.getUser();
const { data, error: userError } = authUser;
if (userError) {
console.error('Failed to get user', userError);
throw userError;
}
const { user } = data;
const { data: analysisResponses } = await this.client
.schema('medreport')
.from('analysis_responses')
.select('*')
.eq('user_id', user.id);
if (!analysisResponses) {
return null;
}
const analysisResponseIds = analysisResponses.map((r) => r.id);
const { data: analysisResponseElements } = await this.client
.schema('medreport')
.from('analysis_response_elements')
.select('*')
.in('analysis_response_id', analysisResponseIds);
if (!analysisResponseElements) {
return null;
}
const elementMap = new Map(
analysisResponseElements.map((e) => [e.analysis_response_id, e]),
);
return analysisResponses
.filter((r) => elementMap.has(r.id))
.map((r) => ({
...r,
element: elementMap.get(r.id)!,
}));
}
}
export function createAccountsApi(client: SupabaseClient<Database>) {

View File

@@ -0,0 +1,6 @@
import { Database } from '@kit/supabase/database';
export type UserAnalysis =
(Database['medreport']['Tables']['analysis_responses']['Row'] & {
element: Database['medreport']['Tables']['analysis_response_elements']['Row'];
})[];

View File

@@ -1,14 +1,16 @@
import Medusa from "@medusajs/js-sdk"
import Medusa from "@medusajs/js-sdk";
// Defaults to standard port for Medusa server
let MEDUSA_BACKEND_URL = "http://localhost:9000"
let MEDUSA_BACKEND_URL = "http://localhost:9000";
if (process.env.MEDUSA_BACKEND_URL) {
MEDUSA_BACKEND_URL = process.env.MEDUSA_BACKEND_URL
MEDUSA_BACKEND_URL = process.env.MEDUSA_BACKEND_URL;
}
export const sdk = new Medusa({
export const SDK_CONFIG = {
baseUrl: MEDUSA_BACKEND_URL,
debug: process.env.NODE_ENV === "development",
publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
})
};
export const sdk = new Medusa(SDK_CONFIG);

View File

@@ -1,13 +1,13 @@
"use server"
"use server";
import { sdk } from "@lib/config"
import { HttpTypes } from "@medusajs/types"
import { getCacheOptions } from "./cookies"
import { sdk, SDK_CONFIG } from "@lib/config";
import { HttpTypes } from "@medusajs/types";
import { getCacheOptions } from "./cookies";
export const retrieveCollection = async (id: string) => {
const next = {
...(await getCacheOptions("collections")),
}
};
return sdk.client
.fetch<{ collection: HttpTypes.StoreCollection }>(
@@ -17,19 +17,19 @@ export const retrieveCollection = async (id: string) => {
cache: "force-cache",
}
)
.then(({ collection }) => collection)
}
.then(({ collection }) => collection);
};
export const listCollections = async (
queryParams: Record<string, string> = {}
): Promise<{ collections: HttpTypes.StoreCollection[]; count: number }> => {
const next = {
...(await getCacheOptions("collections")),
}
queryParams.limit = queryParams.limit || "100"
queryParams.offset = queryParams.offset || "0"
};
queryParams.limit = queryParams.limit || "100";
queryParams.offset = queryParams.offset || "0";
console.log("SDK_CONFIG: ", SDK_CONFIG.baseUrl);
return sdk.client
.fetch<{ collections: HttpTypes.StoreCollection[]; count: number }>(
"/store/collections",
@@ -39,15 +39,15 @@ export const listCollections = async (
cache: "force-cache",
}
)
.then(({ collections }) => ({ collections, count: collections.length }))
}
.then(({ collections }) => ({ collections, count: collections.length }));
};
export const getCollectionByHandle = async (
handle: string
): Promise<HttpTypes.StoreCollection> => {
const next = {
...(await getCacheOptions("collections")),
}
};
return sdk.client
.fetch<HttpTypes.StoreCollectionListResponse>(`/store/collections`, {
@@ -55,5 +55,5 @@ export const getCollectionByHandle = async (
next,
cache: "force-cache",
})
.then(({ collections }) => collections[0])
}
.then(({ collections }) => collections[0]);
};

File diff suppressed because it is too large Load Diff

View File

@@ -37,16 +37,12 @@ function PageWithSidebar(props: PageProps) {
<div
className={
props.contentContainerClassName ??
'mx-auto flex h-screen w-full flex-col overflow-y-auto bg-inherit'
'mx-auto flex h-screen w-full flex-col bg-inherit'
}
>
{MobileNavigation}
<div
className={
'bg-background flex flex-1 flex-col overflow-y-auto px-4 lg:px-0'
}
>
<div className={'bg-background flex flex-1 flex-col px-4 lg:px-0'}>
{Children}
</div>
</div>
@@ -75,7 +71,7 @@ function PageWithHeader(props: PageProps) {
const { Navigation, Children, MobileNavigation } = getSlotsFromPage(props);
return (
<div className={cn('flex h-screen flex-1 flex-col z-900', props.className)}>
<div className={cn('z-900 flex h-screen flex-1 flex-col', props.className)}>
<div
className={
props.contentContainerClassName ?? 'flex flex-1 flex-col space-y-4'
@@ -83,7 +79,7 @@ function PageWithHeader(props: PageProps) {
>
<div
className={cn(
'bg-bg-background border-1 light:border-border dark:border-border dark:shadow-primary/10 flex h-15 items-center justify-between px-4 py-1 lg:justify-start lg:shadow-xs border-b',
'bg-bg-background light:border-border dark:border-border dark:shadow-primary/10 flex h-15 items-center justify-between border-1 border-b px-4 py-1 lg:justify-start lg:shadow-xs',
{
'sticky top-0 z-1000 backdrop-blur-md': props.sticky ?? true,
},