@blackcode_sa/metaestetics-api 1.4.14 → 1.4.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +37 -16
- package/dist/index.mjs +37 -16
- package/package.json +1 -1
- package/src/services/auth.service.ts +49 -6
- package/src/services/clinic/clinic-group.service.ts +1 -0
- package/src/services/clinic/utils/clinic-group.utils.ts +0 -12
package/dist/index.d.mts
CHANGED
|
@@ -1771,9 +1771,13 @@ declare class AuthService extends BaseService {
|
|
|
1771
1771
|
* Can either create a new clinic group or join an existing one with a token
|
|
1772
1772
|
*
|
|
1773
1773
|
* @param data - Clinic admin signup data
|
|
1774
|
-
* @returns
|
|
1774
|
+
* @returns Object containing the created user, clinic group, and clinic admin
|
|
1775
1775
|
*/
|
|
1776
|
-
signUpClinicAdmin(data: ClinicAdminSignupData): Promise<
|
|
1776
|
+
signUpClinicAdmin(data: ClinicAdminSignupData): Promise<{
|
|
1777
|
+
user: User;
|
|
1778
|
+
clinicGroup: ClinicGroup;
|
|
1779
|
+
clinicAdmin: ClinicAdmin;
|
|
1780
|
+
}>;
|
|
1777
1781
|
/**
|
|
1778
1782
|
* Prijavljuje korisnika sa email-om i lozinkom
|
|
1779
1783
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1771,9 +1771,13 @@ declare class AuthService extends BaseService {
|
|
|
1771
1771
|
* Can either create a new clinic group or join an existing one with a token
|
|
1772
1772
|
*
|
|
1773
1773
|
* @param data - Clinic admin signup data
|
|
1774
|
-
* @returns
|
|
1774
|
+
* @returns Object containing the created user, clinic group, and clinic admin
|
|
1775
1775
|
*/
|
|
1776
|
-
signUpClinicAdmin(data: ClinicAdminSignupData): Promise<
|
|
1776
|
+
signUpClinicAdmin(data: ClinicAdminSignupData): Promise<{
|
|
1777
|
+
user: User;
|
|
1778
|
+
clinicGroup: ClinicGroup;
|
|
1779
|
+
clinicAdmin: ClinicAdmin;
|
|
1780
|
+
}>;
|
|
1777
1781
|
/**
|
|
1778
1782
|
* Prijavljuje korisnika sa email-om i lozinkom
|
|
1779
1783
|
*/
|
package/dist/index.js
CHANGED
|
@@ -3968,15 +3968,6 @@ async function updateClinicGroup(db, groupId, data, app) {
|
|
|
3968
3968
|
console.error("[CLINIC_GROUP] Error processing logo for update:", error);
|
|
3969
3969
|
}
|
|
3970
3970
|
}
|
|
3971
|
-
if (updatedData.contactInfo) {
|
|
3972
|
-
updatedData.contactInfo = {
|
|
3973
|
-
...updatedData.contactInfo,
|
|
3974
|
-
email: updatedData.contactInfo.email || "",
|
|
3975
|
-
phoneNumber: updatedData.contactInfo.phoneNumber || "",
|
|
3976
|
-
alternativePhoneNumber: updatedData.contactInfo.alternativePhoneNumber || "",
|
|
3977
|
-
website: updatedData.contactInfo.website || ""
|
|
3978
|
-
};
|
|
3979
|
-
}
|
|
3980
3971
|
updatedData = {
|
|
3981
3972
|
...updatedData,
|
|
3982
3973
|
updatedAt: import_firestore15.Timestamp.now()
|
|
@@ -4268,7 +4259,8 @@ var ClinicGroupService = class extends BaseService {
|
|
|
4268
4259
|
description: setupData.description,
|
|
4269
4260
|
logo: logoUrl,
|
|
4270
4261
|
calendarSyncEnabled: setupData.calendarSyncEnabled,
|
|
4271
|
-
autoConfirmAppointments: setupData.autoConfirmAppointments
|
|
4262
|
+
autoConfirmAppointments: setupData.autoConfirmAppointments,
|
|
4263
|
+
businessIdentificationNumber: setupData.businessIdentificationNumber
|
|
4272
4264
|
};
|
|
4273
4265
|
console.log("[CLINIC_GROUP] Updating clinic group with setup data");
|
|
4274
4266
|
return this.updateClinicGroup(groupId, updateData);
|
|
@@ -5200,7 +5192,7 @@ var AuthService = class extends BaseService {
|
|
|
5200
5192
|
* Can either create a new clinic group or join an existing one with a token
|
|
5201
5193
|
*
|
|
5202
5194
|
* @param data - Clinic admin signup data
|
|
5203
|
-
* @returns
|
|
5195
|
+
* @returns Object containing the created user, clinic group, and clinic admin
|
|
5204
5196
|
*/
|
|
5205
5197
|
async signUpClinicAdmin(data) {
|
|
5206
5198
|
try {
|
|
@@ -5281,6 +5273,8 @@ var AuthService = class extends BaseService {
|
|
|
5281
5273
|
console.log(
|
|
5282
5274
|
"[AUTH] Services initialized and circular dependencies resolved"
|
|
5283
5275
|
);
|
|
5276
|
+
let clinicGroup = null;
|
|
5277
|
+
let adminProfile = null;
|
|
5284
5278
|
if (data.isCreatingNewGroup) {
|
|
5285
5279
|
console.log("[AUTH] Creating new clinic group flow");
|
|
5286
5280
|
if (!data.clinicGroupData) {
|
|
@@ -5299,7 +5293,6 @@ var AuthService = class extends BaseService {
|
|
|
5299
5293
|
isActive: true
|
|
5300
5294
|
// No clinicGroupId yet
|
|
5301
5295
|
};
|
|
5302
|
-
let adminProfile;
|
|
5303
5296
|
try {
|
|
5304
5297
|
adminProfile = await clinicAdminService.createClinicAdmin(
|
|
5305
5298
|
createClinicAdminData
|
|
@@ -5314,6 +5307,21 @@ var AuthService = class extends BaseService {
|
|
|
5314
5307
|
);
|
|
5315
5308
|
throw adminCreationError;
|
|
5316
5309
|
}
|
|
5310
|
+
try {
|
|
5311
|
+
console.log("[AUTH] Updating user with admin profile reference");
|
|
5312
|
+
user = await this.userService.updateUser(firebaseUser.uid, {
|
|
5313
|
+
adminProfile: adminProfile.id
|
|
5314
|
+
});
|
|
5315
|
+
console.log(
|
|
5316
|
+
"[AUTH] User updated with admin profile reference successfully"
|
|
5317
|
+
);
|
|
5318
|
+
} catch (userUpdateError) {
|
|
5319
|
+
console.error(
|
|
5320
|
+
"[AUTH] Failed to update user with admin profile:",
|
|
5321
|
+
userUpdateError
|
|
5322
|
+
);
|
|
5323
|
+
throw userUpdateError;
|
|
5324
|
+
}
|
|
5317
5325
|
const createClinicGroupData = {
|
|
5318
5326
|
name: data.clinicGroupData.name,
|
|
5319
5327
|
hqLocation: data.clinicGroupData.hqLocation,
|
|
@@ -5328,7 +5336,6 @@ var AuthService = class extends BaseService {
|
|
|
5328
5336
|
console.log("[AUTH] Clinic group data prepared", {
|
|
5329
5337
|
groupName: createClinicGroupData.name
|
|
5330
5338
|
});
|
|
5331
|
-
let clinicGroup;
|
|
5332
5339
|
try {
|
|
5333
5340
|
clinicGroup = await clinicGroupService.createClinicGroup(
|
|
5334
5341
|
createClinicGroupData,
|
|
@@ -5346,6 +5353,9 @@ var AuthService = class extends BaseService {
|
|
|
5346
5353
|
clinicGroupId: clinicGroup.id
|
|
5347
5354
|
});
|
|
5348
5355
|
console.log("[AUTH] Admin updated with clinic group ID successfully");
|
|
5356
|
+
adminProfile = await clinicAdminService.getClinicAdmin(
|
|
5357
|
+
adminProfile.id
|
|
5358
|
+
);
|
|
5349
5359
|
} catch (groupCreationError) {
|
|
5350
5360
|
console.error(
|
|
5351
5361
|
"[AUTH] Clinic group creation failed:",
|
|
@@ -5408,6 +5418,7 @@ var AuthService = class extends BaseService {
|
|
|
5408
5418
|
console.error("[AUTH] No valid token found in any clinic group");
|
|
5409
5419
|
throw new Error("Invalid or expired invite token");
|
|
5410
5420
|
}
|
|
5421
|
+
clinicGroup = foundGroup;
|
|
5411
5422
|
console.log("[AUTH] Creating clinic admin");
|
|
5412
5423
|
const createClinicAdminData = {
|
|
5413
5424
|
userRef: firebaseUser.uid,
|
|
@@ -5418,7 +5429,6 @@ var AuthService = class extends BaseService {
|
|
|
5418
5429
|
roleTitle: data.title,
|
|
5419
5430
|
isActive: true
|
|
5420
5431
|
};
|
|
5421
|
-
let adminProfile;
|
|
5422
5432
|
try {
|
|
5423
5433
|
adminProfile = await clinicAdminService.createClinicAdmin(
|
|
5424
5434
|
createClinicAdminData
|
|
@@ -5446,9 +5456,20 @@ var AuthService = class extends BaseService {
|
|
|
5446
5456
|
}
|
|
5447
5457
|
}
|
|
5448
5458
|
console.log("[AUTH] Clinic admin signup completed successfully", {
|
|
5449
|
-
userId: user.uid
|
|
5459
|
+
userId: user.uid,
|
|
5460
|
+
clinicGroupId: clinicGroup.id,
|
|
5461
|
+
clinicAdminId: (adminProfile == null ? void 0 : adminProfile.id) || "unknown"
|
|
5450
5462
|
});
|
|
5451
|
-
|
|
5463
|
+
if (!clinicGroup || !adminProfile) {
|
|
5464
|
+
throw new Error(
|
|
5465
|
+
"Failed to create or retrieve clinic group or admin profile"
|
|
5466
|
+
);
|
|
5467
|
+
}
|
|
5468
|
+
return {
|
|
5469
|
+
user,
|
|
5470
|
+
clinicGroup,
|
|
5471
|
+
clinicAdmin: adminProfile
|
|
5472
|
+
};
|
|
5452
5473
|
} catch (error) {
|
|
5453
5474
|
if (error instanceof import_zod15.z.ZodError) {
|
|
5454
5475
|
console.error(
|
package/dist/index.mjs
CHANGED
|
@@ -3924,15 +3924,6 @@ async function updateClinicGroup(db, groupId, data, app) {
|
|
|
3924
3924
|
console.error("[CLINIC_GROUP] Error processing logo for update:", error);
|
|
3925
3925
|
}
|
|
3926
3926
|
}
|
|
3927
|
-
if (updatedData.contactInfo) {
|
|
3928
|
-
updatedData.contactInfo = {
|
|
3929
|
-
...updatedData.contactInfo,
|
|
3930
|
-
email: updatedData.contactInfo.email || "",
|
|
3931
|
-
phoneNumber: updatedData.contactInfo.phoneNumber || "",
|
|
3932
|
-
alternativePhoneNumber: updatedData.contactInfo.alternativePhoneNumber || "",
|
|
3933
|
-
website: updatedData.contactInfo.website || ""
|
|
3934
|
-
};
|
|
3935
|
-
}
|
|
3936
3927
|
updatedData = {
|
|
3937
3928
|
...updatedData,
|
|
3938
3929
|
updatedAt: Timestamp10.now()
|
|
@@ -4224,7 +4215,8 @@ var ClinicGroupService = class extends BaseService {
|
|
|
4224
4215
|
description: setupData.description,
|
|
4225
4216
|
logo: logoUrl,
|
|
4226
4217
|
calendarSyncEnabled: setupData.calendarSyncEnabled,
|
|
4227
|
-
autoConfirmAppointments: setupData.autoConfirmAppointments
|
|
4218
|
+
autoConfirmAppointments: setupData.autoConfirmAppointments,
|
|
4219
|
+
businessIdentificationNumber: setupData.businessIdentificationNumber
|
|
4228
4220
|
};
|
|
4229
4221
|
console.log("[CLINIC_GROUP] Updating clinic group with setup data");
|
|
4230
4222
|
return this.updateClinicGroup(groupId, updateData);
|
|
@@ -5177,7 +5169,7 @@ var AuthService = class extends BaseService {
|
|
|
5177
5169
|
* Can either create a new clinic group or join an existing one with a token
|
|
5178
5170
|
*
|
|
5179
5171
|
* @param data - Clinic admin signup data
|
|
5180
|
-
* @returns
|
|
5172
|
+
* @returns Object containing the created user, clinic group, and clinic admin
|
|
5181
5173
|
*/
|
|
5182
5174
|
async signUpClinicAdmin(data) {
|
|
5183
5175
|
try {
|
|
@@ -5258,6 +5250,8 @@ var AuthService = class extends BaseService {
|
|
|
5258
5250
|
console.log(
|
|
5259
5251
|
"[AUTH] Services initialized and circular dependencies resolved"
|
|
5260
5252
|
);
|
|
5253
|
+
let clinicGroup = null;
|
|
5254
|
+
let adminProfile = null;
|
|
5261
5255
|
if (data.isCreatingNewGroup) {
|
|
5262
5256
|
console.log("[AUTH] Creating new clinic group flow");
|
|
5263
5257
|
if (!data.clinicGroupData) {
|
|
@@ -5276,7 +5270,6 @@ var AuthService = class extends BaseService {
|
|
|
5276
5270
|
isActive: true
|
|
5277
5271
|
// No clinicGroupId yet
|
|
5278
5272
|
};
|
|
5279
|
-
let adminProfile;
|
|
5280
5273
|
try {
|
|
5281
5274
|
adminProfile = await clinicAdminService.createClinicAdmin(
|
|
5282
5275
|
createClinicAdminData
|
|
@@ -5291,6 +5284,21 @@ var AuthService = class extends BaseService {
|
|
|
5291
5284
|
);
|
|
5292
5285
|
throw adminCreationError;
|
|
5293
5286
|
}
|
|
5287
|
+
try {
|
|
5288
|
+
console.log("[AUTH] Updating user with admin profile reference");
|
|
5289
|
+
user = await this.userService.updateUser(firebaseUser.uid, {
|
|
5290
|
+
adminProfile: adminProfile.id
|
|
5291
|
+
});
|
|
5292
|
+
console.log(
|
|
5293
|
+
"[AUTH] User updated with admin profile reference successfully"
|
|
5294
|
+
);
|
|
5295
|
+
} catch (userUpdateError) {
|
|
5296
|
+
console.error(
|
|
5297
|
+
"[AUTH] Failed to update user with admin profile:",
|
|
5298
|
+
userUpdateError
|
|
5299
|
+
);
|
|
5300
|
+
throw userUpdateError;
|
|
5301
|
+
}
|
|
5294
5302
|
const createClinicGroupData = {
|
|
5295
5303
|
name: data.clinicGroupData.name,
|
|
5296
5304
|
hqLocation: data.clinicGroupData.hqLocation,
|
|
@@ -5305,7 +5313,6 @@ var AuthService = class extends BaseService {
|
|
|
5305
5313
|
console.log("[AUTH] Clinic group data prepared", {
|
|
5306
5314
|
groupName: createClinicGroupData.name
|
|
5307
5315
|
});
|
|
5308
|
-
let clinicGroup;
|
|
5309
5316
|
try {
|
|
5310
5317
|
clinicGroup = await clinicGroupService.createClinicGroup(
|
|
5311
5318
|
createClinicGroupData,
|
|
@@ -5323,6 +5330,9 @@ var AuthService = class extends BaseService {
|
|
|
5323
5330
|
clinicGroupId: clinicGroup.id
|
|
5324
5331
|
});
|
|
5325
5332
|
console.log("[AUTH] Admin updated with clinic group ID successfully");
|
|
5333
|
+
adminProfile = await clinicAdminService.getClinicAdmin(
|
|
5334
|
+
adminProfile.id
|
|
5335
|
+
);
|
|
5326
5336
|
} catch (groupCreationError) {
|
|
5327
5337
|
console.error(
|
|
5328
5338
|
"[AUTH] Clinic group creation failed:",
|
|
@@ -5385,6 +5395,7 @@ var AuthService = class extends BaseService {
|
|
|
5385
5395
|
console.error("[AUTH] No valid token found in any clinic group");
|
|
5386
5396
|
throw new Error("Invalid or expired invite token");
|
|
5387
5397
|
}
|
|
5398
|
+
clinicGroup = foundGroup;
|
|
5388
5399
|
console.log("[AUTH] Creating clinic admin");
|
|
5389
5400
|
const createClinicAdminData = {
|
|
5390
5401
|
userRef: firebaseUser.uid,
|
|
@@ -5395,7 +5406,6 @@ var AuthService = class extends BaseService {
|
|
|
5395
5406
|
roleTitle: data.title,
|
|
5396
5407
|
isActive: true
|
|
5397
5408
|
};
|
|
5398
|
-
let adminProfile;
|
|
5399
5409
|
try {
|
|
5400
5410
|
adminProfile = await clinicAdminService.createClinicAdmin(
|
|
5401
5411
|
createClinicAdminData
|
|
@@ -5423,9 +5433,20 @@ var AuthService = class extends BaseService {
|
|
|
5423
5433
|
}
|
|
5424
5434
|
}
|
|
5425
5435
|
console.log("[AUTH] Clinic admin signup completed successfully", {
|
|
5426
|
-
userId: user.uid
|
|
5436
|
+
userId: user.uid,
|
|
5437
|
+
clinicGroupId: clinicGroup.id,
|
|
5438
|
+
clinicAdminId: (adminProfile == null ? void 0 : adminProfile.id) || "unknown"
|
|
5427
5439
|
});
|
|
5428
|
-
|
|
5440
|
+
if (!clinicGroup || !adminProfile) {
|
|
5441
|
+
throw new Error(
|
|
5442
|
+
"Failed to create or retrieve clinic group or admin profile"
|
|
5443
|
+
);
|
|
5444
|
+
}
|
|
5445
|
+
return {
|
|
5446
|
+
user,
|
|
5447
|
+
clinicGroup,
|
|
5448
|
+
clinicAdmin: adminProfile
|
|
5449
|
+
};
|
|
5429
5450
|
} catch (error) {
|
|
5430
5451
|
if (error instanceof z15.ZodError) {
|
|
5431
5452
|
console.error(
|
package/package.json
CHANGED
|
@@ -55,6 +55,7 @@ import {
|
|
|
55
55
|
ClinicAdminSignupData,
|
|
56
56
|
SubscriptionModel,
|
|
57
57
|
CLINIC_GROUPS_COLLECTION,
|
|
58
|
+
ClinicAdmin,
|
|
58
59
|
} from "../types/clinic";
|
|
59
60
|
import { clinicAdminSignupSchema } from "../validations/clinic.schema";
|
|
60
61
|
import { ClinicGroupService } from "./clinic/clinic-group.service";
|
|
@@ -104,9 +105,13 @@ export class AuthService extends BaseService {
|
|
|
104
105
|
* Can either create a new clinic group or join an existing one with a token
|
|
105
106
|
*
|
|
106
107
|
* @param data - Clinic admin signup data
|
|
107
|
-
* @returns
|
|
108
|
+
* @returns Object containing the created user, clinic group, and clinic admin
|
|
108
109
|
*/
|
|
109
|
-
async signUpClinicAdmin(data: ClinicAdminSignupData): Promise<
|
|
110
|
+
async signUpClinicAdmin(data: ClinicAdminSignupData): Promise<{
|
|
111
|
+
user: User;
|
|
112
|
+
clinicGroup: ClinicGroup;
|
|
113
|
+
clinicAdmin: ClinicAdmin;
|
|
114
|
+
}> {
|
|
110
115
|
try {
|
|
111
116
|
console.log("[AUTH] Starting clinic admin signup process", {
|
|
112
117
|
email: data.email,
|
|
@@ -198,6 +203,9 @@ export class AuthService extends BaseService {
|
|
|
198
203
|
"[AUTH] Services initialized and circular dependencies resolved"
|
|
199
204
|
);
|
|
200
205
|
|
|
206
|
+
let clinicGroup: ClinicGroup | null = null;
|
|
207
|
+
let adminProfile: ClinicAdmin | null = null;
|
|
208
|
+
|
|
201
209
|
if (data.isCreatingNewGroup) {
|
|
202
210
|
console.log("[AUTH] Creating new clinic group flow");
|
|
203
211
|
// Create new clinic group
|
|
@@ -220,7 +228,6 @@ export class AuthService extends BaseService {
|
|
|
220
228
|
// No clinicGroupId yet
|
|
221
229
|
};
|
|
222
230
|
|
|
223
|
-
let adminProfile;
|
|
224
231
|
try {
|
|
225
232
|
adminProfile = await clinicAdminService.createClinicAdmin(
|
|
226
233
|
createClinicAdminData
|
|
@@ -236,6 +243,23 @@ export class AuthService extends BaseService {
|
|
|
236
243
|
throw adminCreationError;
|
|
237
244
|
}
|
|
238
245
|
|
|
246
|
+
// Update user document with admin profile reference
|
|
247
|
+
try {
|
|
248
|
+
console.log("[AUTH] Updating user with admin profile reference");
|
|
249
|
+
user = await this.userService.updateUser(firebaseUser.uid, {
|
|
250
|
+
adminProfile: adminProfile.id,
|
|
251
|
+
});
|
|
252
|
+
console.log(
|
|
253
|
+
"[AUTH] User updated with admin profile reference successfully"
|
|
254
|
+
);
|
|
255
|
+
} catch (userUpdateError) {
|
|
256
|
+
console.error(
|
|
257
|
+
"[AUTH] Failed to update user with admin profile:",
|
|
258
|
+
userUpdateError
|
|
259
|
+
);
|
|
260
|
+
throw userUpdateError;
|
|
261
|
+
}
|
|
262
|
+
|
|
239
263
|
// Then create clinic group
|
|
240
264
|
const createClinicGroupData: CreateClinicGroupData = {
|
|
241
265
|
name: data.clinicGroupData.name,
|
|
@@ -254,7 +278,6 @@ export class AuthService extends BaseService {
|
|
|
254
278
|
});
|
|
255
279
|
|
|
256
280
|
// Create clinic group
|
|
257
|
-
let clinicGroup;
|
|
258
281
|
try {
|
|
259
282
|
clinicGroup = await clinicGroupService.createClinicGroup(
|
|
260
283
|
createClinicGroupData,
|
|
@@ -272,6 +295,11 @@ export class AuthService extends BaseService {
|
|
|
272
295
|
clinicGroupId: clinicGroup.id,
|
|
273
296
|
});
|
|
274
297
|
console.log("[AUTH] Admin updated with clinic group ID successfully");
|
|
298
|
+
|
|
299
|
+
// Get the updated admin profile
|
|
300
|
+
adminProfile = await clinicAdminService.getClinicAdmin(
|
|
301
|
+
adminProfile.id
|
|
302
|
+
);
|
|
275
303
|
} catch (groupCreationError) {
|
|
276
304
|
console.error(
|
|
277
305
|
"[AUTH] Clinic group creation failed:",
|
|
@@ -349,6 +377,8 @@ export class AuthService extends BaseService {
|
|
|
349
377
|
throw new Error("Invalid or expired invite token");
|
|
350
378
|
}
|
|
351
379
|
|
|
380
|
+
clinicGroup = foundGroup;
|
|
381
|
+
|
|
352
382
|
// Create clinic admin
|
|
353
383
|
console.log("[AUTH] Creating clinic admin");
|
|
354
384
|
const createClinicAdminData: CreateClinicAdminData = {
|
|
@@ -361,7 +391,6 @@ export class AuthService extends BaseService {
|
|
|
361
391
|
isActive: true,
|
|
362
392
|
};
|
|
363
393
|
|
|
364
|
-
let adminProfile;
|
|
365
394
|
try {
|
|
366
395
|
adminProfile = await clinicAdminService.createClinicAdmin(
|
|
367
396
|
createClinicAdminData
|
|
@@ -393,8 +422,22 @@ export class AuthService extends BaseService {
|
|
|
393
422
|
|
|
394
423
|
console.log("[AUTH] Clinic admin signup completed successfully", {
|
|
395
424
|
userId: user.uid,
|
|
425
|
+
clinicGroupId: clinicGroup.id,
|
|
426
|
+
clinicAdminId: adminProfile?.id || "unknown",
|
|
396
427
|
});
|
|
397
|
-
|
|
428
|
+
|
|
429
|
+
// Ensure we have all required data before returning
|
|
430
|
+
if (!clinicGroup || !adminProfile) {
|
|
431
|
+
throw new Error(
|
|
432
|
+
"Failed to create or retrieve clinic group or admin profile"
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
return {
|
|
437
|
+
user,
|
|
438
|
+
clinicGroup,
|
|
439
|
+
clinicAdmin: adminProfile,
|
|
440
|
+
};
|
|
398
441
|
} catch (error) {
|
|
399
442
|
if (error instanceof z.ZodError) {
|
|
400
443
|
console.error(
|
|
@@ -179,6 +179,7 @@ export class ClinicGroupService extends BaseService {
|
|
|
179
179
|
logo: logoUrl,
|
|
180
180
|
calendarSyncEnabled: setupData.calendarSyncEnabled,
|
|
181
181
|
autoConfirmAppointments: setupData.autoConfirmAppointments,
|
|
182
|
+
businessIdentificationNumber: setupData.businessIdentificationNumber,
|
|
182
183
|
};
|
|
183
184
|
|
|
184
185
|
console.log("[CLINIC_GROUP] Updating clinic group with setup data");
|
|
@@ -322,18 +322,6 @@ export async function updateClinicGroup(
|
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
// Ensure contactInfo fields are never undefined
|
|
326
|
-
if (updatedData.contactInfo) {
|
|
327
|
-
updatedData.contactInfo = {
|
|
328
|
-
...updatedData.contactInfo,
|
|
329
|
-
email: updatedData.contactInfo.email || "",
|
|
330
|
-
phoneNumber: updatedData.contactInfo.phoneNumber || "",
|
|
331
|
-
alternativePhoneNumber:
|
|
332
|
-
updatedData.contactInfo.alternativePhoneNumber || "",
|
|
333
|
-
website: updatedData.contactInfo.website || "",
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
|
|
337
325
|
// Add timestamp
|
|
338
326
|
updatedData = {
|
|
339
327
|
...updatedData,
|