Merge branch 'develop' of https://github.com/MR-medreport/MRB2B into MED-103
This commit is contained in:
@@ -206,14 +206,7 @@ class AuthCallbackService {
|
||||
return;
|
||||
}
|
||||
|
||||
// If user already has Medusa account, we're done
|
||||
if (accountData?.medusa_account_id) {
|
||||
console.log('Keycloak user already has Medusa account:', accountData.medusa_account_id);
|
||||
return;
|
||||
}
|
||||
|
||||
const { medusaLoginOrRegister } = await import('../../features/medusa-storefront/src/lib/data/customer');
|
||||
|
||||
const medusaAccountId = await medusaLoginOrRegister({
|
||||
email: user.email,
|
||||
supabaseUserId: user.id,
|
||||
@@ -221,20 +214,24 @@ class AuthCallbackService {
|
||||
lastName: accountData?.last_name ?? '-',
|
||||
});
|
||||
|
||||
// Update the account with the Medusa account ID
|
||||
const { error: updateError } = await this.client
|
||||
.schema('medreport')
|
||||
.from('accounts')
|
||||
.update({ medusa_account_id: medusaAccountId })
|
||||
.eq('primary_owner_user_id', user.id)
|
||||
.eq('is_personal_account', true);
|
||||
const currentMedusaAccountId = accountData?.medusa_account_id;
|
||||
if (!currentMedusaAccountId || currentMedusaAccountId !== medusaAccountId) {
|
||||
const { error: updateError } = await this.client
|
||||
.schema('medreport')
|
||||
.from('accounts')
|
||||
.update({ medusa_account_id: medusaAccountId })
|
||||
.eq('primary_owner_user_id', user.id)
|
||||
.eq('is_personal_account', true);
|
||||
|
||||
if (updateError) {
|
||||
console.error('Error updating account with Medusa ID:', updateError);
|
||||
return;
|
||||
if (updateError) {
|
||||
console.error('Error updating account with Medusa ID:', updateError);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Successfully set up Medusa account for Keycloak user:', medusaAccountId);
|
||||
} else {
|
||||
console.log('Keycloak user already has Medusa account:', accountData.medusa_account_id);
|
||||
}
|
||||
|
||||
console.log('Successfully set up Medusa account for Keycloak user:', medusaAccountId);
|
||||
} catch (error) {
|
||||
console.error('Error setting up Medusa account for Keycloak user:', error);
|
||||
}
|
||||
|
||||
@@ -688,8 +688,11 @@ export type Database = {
|
||||
norm_upper: number | null
|
||||
norm_upper_included: boolean | null
|
||||
original_response_element: Json
|
||||
response_time: string
|
||||
response_value: number
|
||||
response_time: string | null
|
||||
response_value: number | null
|
||||
response_value_is_negative: boolean | null
|
||||
response_value_is_within_norm: boolean | null
|
||||
status: string | null
|
||||
unit: string | null
|
||||
updated_at: string | null
|
||||
}
|
||||
@@ -706,8 +709,11 @@ export type Database = {
|
||||
norm_upper?: number | null
|
||||
norm_upper_included?: boolean | null
|
||||
original_response_element: Json
|
||||
response_time: string
|
||||
response_value: number
|
||||
response_time?: string | null
|
||||
response_value?: number | null
|
||||
response_value_is_negative?: boolean | null
|
||||
response_value_is_within_norm?: boolean | null
|
||||
status?: string | null
|
||||
unit?: string | null
|
||||
updated_at?: string | null
|
||||
}
|
||||
@@ -724,8 +730,11 @@ export type Database = {
|
||||
norm_upper?: number | null
|
||||
norm_upper_included?: boolean | null
|
||||
original_response_element?: Json
|
||||
response_time?: string
|
||||
response_value?: number
|
||||
response_time?: string | null
|
||||
response_value?: number | null
|
||||
response_value_is_negative?: boolean | null
|
||||
response_value_is_within_norm?: boolean | null
|
||||
status?: string | null
|
||||
unit?: string | null
|
||||
updated_at?: string | null
|
||||
}
|
||||
@@ -1373,6 +1382,8 @@ export type Database = {
|
||||
has_analysis_results: boolean
|
||||
has_error: boolean
|
||||
id: string
|
||||
medipost_external_order_id: string | null
|
||||
medipost_private_message_id: string | null
|
||||
medusa_order_id: string | null
|
||||
response_xml: string | null
|
||||
xml: string | null
|
||||
@@ -1383,6 +1394,8 @@ export type Database = {
|
||||
has_analysis_results?: boolean
|
||||
has_error?: boolean
|
||||
id?: string
|
||||
medipost_external_order_id?: string | null
|
||||
medipost_private_message_id?: string | null
|
||||
medusa_order_id?: string | null
|
||||
response_xml?: string | null
|
||||
xml?: string | null
|
||||
@@ -1393,6 +1406,8 @@ export type Database = {
|
||||
has_analysis_results?: boolean
|
||||
has_error?: boolean
|
||||
id?: string
|
||||
medipost_external_order_id?: string | null
|
||||
medipost_private_message_id?: string | null
|
||||
medusa_order_id?: string | null
|
||||
response_xml?: string | null
|
||||
xml?: string | null
|
||||
|
||||
Reference in New Issue
Block a user