dropdown enabled
Browse files
src/app/app.component.ts
CHANGED
|
@@ -288,84 +288,66 @@ export class AppComponent implements OnInit, OnDestroy {
|
|
| 288 |
|
| 289 |
console.log('?? Checking database progress for user:', userId);
|
| 290 |
|
| 291 |
-
// Check Marriage profile completion
|
| 292 |
this.signupService.checkMarriageProfile(userId).subscribe({
|
| 293 |
next: (profileRes: any) => {
|
| 294 |
const profileExists = profileRes.exists || false;
|
| 295 |
-
console.log('? Marriage profile check:', profileExists);
|
| 296 |
|
| 297 |
-
// Only
|
|
|
|
| 298 |
if (profileExists) {
|
| 299 |
this.profileCompleted = true;
|
| 300 |
this.saveProgress();
|
| 301 |
this.changeDetectorRef.detectChanges();
|
| 302 |
-
} else {
|
| 303 |
-
this.profileCompleted = false;
|
| 304 |
-
this.saveProgress();
|
| 305 |
-
this.changeDetectorRef.detectChanges();
|
| 306 |
}
|
| 307 |
},
|
| 308 |
error: (err: any) => {
|
| 309 |
-
|
| 310 |
-
//
|
| 311 |
-
|
| 312 |
-
this.saveProgress();
|
| 313 |
-
this.changeDetectorRef.detectChanges();
|
| 314 |
}
|
| 315 |
});
|
| 316 |
|
| 317 |
-
// Check Expectations completion
|
| 318 |
this.signupService.checkExpectations(userId).subscribe({
|
| 319 |
next: (expectationsRes: any) => {
|
| 320 |
const expectationsExists = expectationsRes.exists || false;
|
| 321 |
-
console.log('? Expectations check:', expectationsExists);
|
| 322 |
|
| 323 |
if (expectationsExists) {
|
| 324 |
this.expectationsCompleted = true;
|
| 325 |
this.saveProgress();
|
| 326 |
this.changeDetectorRef.detectChanges();
|
| 327 |
-
} else {
|
| 328 |
-
this.expectationsCompleted = false;
|
| 329 |
-
this.saveProgress();
|
| 330 |
-
this.changeDetectorRef.detectChanges();
|
| 331 |
}
|
| 332 |
},
|
| 333 |
error: (err: any) => {
|
| 334 |
-
console.
|
| 335 |
-
this.expectationsCompleted = false;
|
| 336 |
-
this.saveProgress();
|
| 337 |
-
this.changeDetectorRef.detectChanges();
|
| 338 |
}
|
| 339 |
});
|
| 340 |
|
| 341 |
-
// Check Assessment completion
|
| 342 |
this.signupService.checkAssessment(userId).subscribe({
|
| 343 |
next: (assessmentRes: any) => {
|
| 344 |
const assessmentExists = assessmentRes.exists || false;
|
| 345 |
-
console.log('? Assessment check:', assessmentExists);
|
| 346 |
|
| 347 |
if (assessmentExists) {
|
| 348 |
this.assessmentCompleted = true;
|
| 349 |
-
this.matchingCompleted = true;
|
| 350 |
-
this.saveProgress();
|
| 351 |
-
this.changeDetectorRef.detectChanges();
|
| 352 |
-
} else {
|
| 353 |
-
this.assessmentCompleted = false;
|
| 354 |
-
this.matchingCompleted = false;
|
| 355 |
this.saveProgress();
|
| 356 |
this.changeDetectorRef.detectChanges();
|
| 357 |
}
|
| 358 |
},
|
| 359 |
error: (err: any) => {
|
| 360 |
-
console.
|
| 361 |
-
this.assessmentCompleted = false;
|
| 362 |
-
this.matchingCompleted = false;
|
| 363 |
-
this.saveProgress();
|
| 364 |
-
this.changeDetectorRef.detectChanges();
|
| 365 |
}
|
| 366 |
});
|
| 367 |
}
|
| 368 |
|
|
|
|
|
|
|
|
|
|
| 369 |
private saveProgress(): void {
|
| 370 |
const userId = this.authService.userId;
|
| 371 |
|
|
|
|
| 288 |
|
| 289 |
console.log('?? Checking database progress for user:', userId);
|
| 290 |
|
| 291 |
+
// 1. Check Marriage profile completion
|
| 292 |
this.signupService.checkMarriageProfile(userId).subscribe({
|
| 293 |
next: (profileRes: any) => {
|
| 294 |
const profileExists = profileRes.exists || false;
|
| 295 |
+
console.log('? Marriage profile check response:', profileExists);
|
| 296 |
|
| 297 |
+
// Only change state if the database explicitly confirms completion
|
| 298 |
+
// We do NOT set it to false here to prevent UI locking during network lag
|
| 299 |
if (profileExists) {
|
| 300 |
this.profileCompleted = true;
|
| 301 |
this.saveProgress();
|
| 302 |
this.changeDetectorRef.detectChanges();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
}
|
| 304 |
},
|
| 305 |
error: (err: any) => {
|
| 306 |
+
// In production (Hugging Face), requests may timeout or fail due to CORS/Latency
|
| 307 |
+
// We keep the local state (from localStorage) instead of forcing it to false
|
| 308 |
+
console.error('? Marriage profile check API error:', err);
|
|
|
|
|
|
|
| 309 |
}
|
| 310 |
});
|
| 311 |
|
| 312 |
+
// 2. Check Expectations completion
|
| 313 |
this.signupService.checkExpectations(userId).subscribe({
|
| 314 |
next: (expectationsRes: any) => {
|
| 315 |
const expectationsExists = expectationsRes.exists || false;
|
| 316 |
+
console.log('? Expectations check response:', expectationsExists);
|
| 317 |
|
| 318 |
if (expectationsExists) {
|
| 319 |
this.expectationsCompleted = true;
|
| 320 |
this.saveProgress();
|
| 321 |
this.changeDetectorRef.detectChanges();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
}
|
| 323 |
},
|
| 324 |
error: (err: any) => {
|
| 325 |
+
console.error('? Expectations check API error:', err);
|
|
|
|
|
|
|
|
|
|
| 326 |
}
|
| 327 |
});
|
| 328 |
|
| 329 |
+
// 3. Check Assessment completion
|
| 330 |
this.signupService.checkAssessment(userId).subscribe({
|
| 331 |
next: (assessmentRes: any) => {
|
| 332 |
const assessmentExists = assessmentRes.exists || false;
|
| 333 |
+
console.log('? Assessment check response:', assessmentExists);
|
| 334 |
|
| 335 |
if (assessmentExists) {
|
| 336 |
this.assessmentCompleted = true;
|
| 337 |
+
this.matchingCompleted = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
this.saveProgress();
|
| 339 |
this.changeDetectorRef.detectChanges();
|
| 340 |
}
|
| 341 |
},
|
| 342 |
error: (err: any) => {
|
| 343 |
+
console.error('? Assessment check API error:', err);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
}
|
| 345 |
});
|
| 346 |
}
|
| 347 |
|
| 348 |
+
|
| 349 |
+
|
| 350 |
+
|
| 351 |
private saveProgress(): void {
|
| 352 |
const userId = this.authService.userId;
|
| 353 |
|
src/app/matching-list/matching-list.component.ts
CHANGED
|
@@ -107,6 +107,7 @@ export class MatchingListComponent implements OnInit {
|
|
| 107 |
activeTab: 'details' | 'compatibility' = 'details';
|
| 108 |
subTab: 'expectation' | 'character' = 'expectation';
|
| 109 |
showUserProfileModal: boolean = false;
|
|
|
|
| 110 |
|
| 111 |
// User data
|
| 112 |
userId: number | null = null;
|
|
@@ -190,7 +191,7 @@ export class MatchingListComponent implements OnInit {
|
|
| 190 |
// If in character mode and no character data loaded yet, fetch it
|
| 191 |
if (this.mode === 'character' && this.strengths.length === 0 && this.risks.length === 0 && this.sacrifices.length === 0) {
|
| 192 |
console.log('🎯 Loading character data on tab switch...');
|
| 193 |
-
|
| 194 |
}
|
| 195 |
|
| 196 |
// Log current state for debugging
|
|
@@ -752,6 +753,13 @@ export class MatchingListComponent implements OnInit {
|
|
| 752 |
fetchCompatibilityExplanation(profile: Profile): void {
|
| 753 |
if (!this.userId) return;
|
| 754 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 755 |
this.matchingService.getCompatibilityExplanation(
|
| 756 |
this.userId,
|
| 757 |
profile.user_id,
|
|
@@ -778,6 +786,7 @@ export class MatchingListComponent implements OnInit {
|
|
| 778 |
|
| 779 |
processCharacterExplanation(explanations: string[]) {
|
| 780 |
console.log('🔍 Frontend: RAW explanations from backend:', explanations);
|
|
|
|
| 781 |
|
| 782 |
this.strengths = [];
|
| 783 |
this.risks = [];
|
|
@@ -1004,6 +1013,9 @@ export class MatchingListComponent implements OnInit {
|
|
| 1004 |
this.compatibilityAnalysis = null;
|
| 1005 |
this.activeTab = 'details';
|
| 1006 |
|
|
|
|
|
|
|
|
|
|
| 1007 |
// Reset subTab based on mode
|
| 1008 |
if (this.mode === 'expectation') {
|
| 1009 |
this.subTab = 'expectation'; // Default to expectation tab for combined mode
|
|
|
|
| 107 |
activeTab: 'details' | 'compatibility' = 'details';
|
| 108 |
subTab: 'expectation' | 'character' = 'expectation';
|
| 109 |
showUserProfileModal: boolean = false;
|
| 110 |
+
private characterExplanationLoaded = false;
|
| 111 |
|
| 112 |
// User data
|
| 113 |
userId: number | null = null;
|
|
|
|
| 191 |
// If in character mode and no character data loaded yet, fetch it
|
| 192 |
if (this.mode === 'character' && this.strengths.length === 0 && this.risks.length === 0 && this.sacrifices.length === 0) {
|
| 193 |
console.log('🎯 Loading character data on tab switch...');
|
| 194 |
+
/* this.fetchCompatibilityExplanation(this.selectedProfile);*/
|
| 195 |
}
|
| 196 |
|
| 197 |
// Log current state for debugging
|
|
|
|
| 753 |
fetchCompatibilityExplanation(profile: Profile): void {
|
| 754 |
if (!this.userId) return;
|
| 755 |
|
| 756 |
+
// ✅ PREVENT DUPLICATE CALLS
|
| 757 |
+
if (this.characterExplanationLoaded) {
|
| 758 |
+
console.log(⏭️ Character explanation already loaded, skipping API call');
|
| 759 |
+
return;
|
| 760 |
+
}
|
| 761 |
+
this.characterExplanationLoaded = true;
|
| 762 |
+
|
| 763 |
this.matchingService.getCompatibilityExplanation(
|
| 764 |
this.userId,
|
| 765 |
profile.user_id,
|
|
|
|
| 786 |
|
| 787 |
processCharacterExplanation(explanations: string[]) {
|
| 788 |
console.log('🔍 Frontend: RAW explanations from backend:', explanations);
|
| 789 |
+
this.characterExplanationLoaded = false; // allow retry on failure
|
| 790 |
|
| 791 |
this.strengths = [];
|
| 792 |
this.risks = [];
|
|
|
|
| 1013 |
this.compatibilityAnalysis = null;
|
| 1014 |
this.activeTab = 'details';
|
| 1015 |
|
| 1016 |
+
this.characterExplanationLoaded = false;
|
| 1017 |
+
|
| 1018 |
+
|
| 1019 |
// Reset subTab based on mode
|
| 1020 |
if (this.mode === 'expectation') {
|
| 1021 |
this.subTab = 'expectation'; // Default to expectation tab for combined mode
|