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
This commit is contained in:
Danel Kungla
2025-07-09 10:01:12 +03:00
parent 4f36f9c037
commit 9371ff7710
6 changed files with 234 additions and 452 deletions

View File

@@ -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;

View File

@@ -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 = ({
<Trans i18nKey={descriptionKey} />
</p>
</div>
{walletProps && (
<div>
<Trans i18nKey="common.wallet.balance" />
<p></p>
<Trans
i18nKey="common.wallet.expiredAt"
values={{ expiredAt: '12.12.2025' }}
/>
</div>
)}
{buttonProps && (
<Button className="mt-8 w-full">
<Link href={buttonProps.href}>