From 9371ff771014dd7e7fcf2b87631b2b364f0136aa Mon Sep 17 00:00:00 2001 From: Danel Kungla Date: Wed, 9 Jul 2025 10:01:12 +0300 Subject: [PATCH] feat: update API and database structure for membership confirmation and wallet integration - Refactor API calls to use 'medreport' schema for membership confirmation and account updates - Enhance success notification component to include wallet balance and expiration details - Modify database types to reflect new 'medreport' schema and add product-related tables - Update localization files to support new wallet messages - Adjust SQL migration scripts for proper schema references and function definitions --- packages/features/auth/src/server/api.ts | 42 ++- .../src/components/success-notification.tsx | 15 + packages/supabase/src/database.types.ts | 263 +++++++++----- public/locales/et/common.json | 6 +- ...119_rename_medreport_product_to_medusa.sql | 342 ------------------ ...20250707150416_membership_confirmation.sql | 18 +- 6 files changed, 234 insertions(+), 452 deletions(-) delete mode 100644 supabase/migrations/20250703151119_rename_medreport_product_to_medusa.sql diff --git a/packages/features/auth/src/server/api.ts b/packages/features/auth/src/server/api.ts index 0e6f9ce..ce82491 100644 --- a/packages/features/auth/src/server/api.ts +++ b/packages/features/auth/src/server/api.ts @@ -25,12 +25,11 @@ class AuthApi { throw new Error('User not authenticated'); } - const { data, error } = await this.client.rpc( - 'has_unseen_membership_confirmation', - { + const { data, error } = await this.client + .schema('medreport') + .rpc('has_unseen_membership_confirmation', { p_user_id: user.id, - }, - ); + }); if (error) { throw error; @@ -53,15 +52,17 @@ class AuthApi { throw new Error('User not authenticated'); } - const { error } = await this.client.rpc('update_account', { - p_name: data.firstName, - p_last_name: data.lastName, - p_personal_code: data.personalCode, - p_phone: data.phone || '', - p_city: data.city || '', - p_has_consent_personal_data: data.userConsent, - p_uid: user.id, - }); + const { error } = await this.client + .schema('medreport') + .rpc('update_account', { + p_name: data.firstName, + p_last_name: data.lastName, + p_personal_code: data.personalCode, + p_phone: data.phone || '', + p_city: data.city || '', + p_has_consent_personal_data: data.userConsent, + p_uid: user.id, + }); if (error) { throw error; @@ -86,11 +87,14 @@ class AuthApi { throw new Error('User not authenticated'); } console.log('test', user, data); - const response = await this.client.from('account_params').insert({ - account_id: user.id, - height: data.height, - weight: data.weight, - }); + const response = await this.client + .schema('medreport') + .from('account_params') + .insert({ + account_id: user.id, + height: data.height, + weight: data.weight, + }); if (response.error) { throw response.error; diff --git a/packages/features/notifications/src/components/success-notification.tsx b/packages/features/notifications/src/components/success-notification.tsx index 7c6be5c..17788b2 100644 --- a/packages/features/notifications/src/components/success-notification.tsx +++ b/packages/features/notifications/src/components/success-notification.tsx @@ -11,12 +11,17 @@ export const SuccessNotification = ({ title, titleKey, descriptionKey, + walletProps, buttonProps, }: { showLogo?: boolean; title?: string; titleKey?: string; descriptionKey?: string; + walletProps?: { + amount: string; + expiredAt: string; + }; buttonProps?: { buttonTitleKey: string; href: string; @@ -38,6 +43,16 @@ export const SuccessNotification = ({

+ {walletProps && ( +
+ +

+ +
+ )} {buttonProps && (