Skip to content

Commit 79d4783

Browse files
oleksandrkitsclaude
andcommitted
style: Apply prettier formatting to Intercom files
- Format HTML, TypeScript, and SCSS files - Ensure consistent code style across the codebase 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 34aeaa2 commit 79d4783

5 files changed

Lines changed: 120 additions & 97 deletions

File tree

src/app/adf-config/df-intercom/df-intercom-config.component.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<div class="intercom-config-container">
22
<p>
3-
Control whether the Intercom chat widget is displayed to users.
4-
When disabled, no Intercom resources will be loaded and the widget will not appear.
3+
Control whether the Intercom chat widget is displayed to users. When
4+
disabled, no Intercom resources will be loaded and the widget will not
5+
appear.
56
</p>
67

78
<div class="config-section">
@@ -17,12 +18,14 @@
1718
[disabled]="saving"
1819
color="primary"
1920
class="toggle-control">
20-
{{ intercomEnabled ? 'Intercom Widget Enabled' : 'Intercom Widget Disabled' }}
21+
{{
22+
intercomEnabled ? 'Intercom Widget Enabled' : 'Intercom Widget Disabled'
23+
}}
2124
</mat-slide-toggle>
2225

2326
<div class="saving-indicator" *ngIf="saving">
2427
<mat-spinner diameter="20"></mat-spinner>
2528
<span>Saving...</span>
2629
</div>
2730
</div>
28-
</div>
31+
</div>

src/app/adf-config/df-intercom/df-intercom-config.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626
// }
2727
// }
2828
// }
29-
// }
29+
// }

src/app/adf-config/df-intercom/df-intercom-config.component.ts

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import { IntercomService } from '../../shared/services/intercom.service';
1717
CommonModule,
1818
MatSlideToggleModule,
1919
MatProgressSpinnerModule,
20-
FormsModule
21-
]
20+
FormsModule,
21+
],
2222
})
2323
export class DfIntercomConfigComponent implements OnInit {
2424
intercomEnabled = true;
@@ -38,42 +38,53 @@ export class DfIntercomConfigComponent implements OnInit {
3838
loadConfig(): void {
3939
this.loading = true;
4040
this.intercomConfigService.getConfig().subscribe({
41-
next: (config) => {
41+
next: config => {
4242
this.intercomEnabled = config.intercomWidget ?? true;
4343
this.loading = false;
4444
},
45-
error: (error) => {
45+
error: error => {
4646
console.error('Failed to load Intercom configuration:', error);
47-
this.snackbarService.openSnackBar('Failed to load configuration', 'error');
47+
this.snackbarService.openSnackBar(
48+
'Failed to load configuration',
49+
'error'
50+
);
4851
this.loading = false;
49-
}
52+
},
5053
});
5154
}
5255

5356
saveConfig(): void {
5457
this.saving = true;
55-
this.intercomConfigService.updateConfig({ intercomWidget: this.intercomEnabled }).subscribe({
56-
next: () => {
57-
this.snackbarService.openSnackBar('Intercom configuration saved successfully', 'success');
58-
this.saving = false;
58+
this.intercomConfigService
59+
.updateConfig({ intercomWidget: this.intercomEnabled })
60+
.subscribe({
61+
next: () => {
62+
this.snackbarService.openSnackBar(
63+
'Intercom configuration saved successfully',
64+
'success'
65+
);
66+
this.saving = false;
5967

60-
// Update the Intercom widget state immediately
61-
if (this.intercomEnabled) {
62-
this.intercomService.showIntercom();
63-
} else {
64-
this.intercomService.hideIntercom();
65-
}
66-
},
67-
error: (error) => {
68-
console.error('Failed to save Intercom configuration:', error);
69-
this.snackbarService.openSnackBar('Failed to save configuration', 'error');
70-
this.saving = false;
71-
}
72-
});
68+
// Update the Intercom widget state immediately
69+
if (this.intercomEnabled) {
70+
this.intercomService.showIntercom();
71+
} else {
72+
this.intercomService.hideIntercom();
73+
}
74+
},
75+
error: error => {
76+
console.error('Failed to save Intercom configuration:', error);
77+
this.snackbarService.openSnackBar(
78+
'Failed to save configuration',
79+
'error'
80+
);
81+
this.saving = false;
82+
},
83+
});
7384
}
7485

7586
onToggleChange(): void {
7687
// Auto-save when toggle changes
7788
this.saveConfig();
7889
}
79-
}
90+
}

src/app/adf-config/df-intercom/df-intercom-config.service.ts

Lines changed: 74 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ export interface IntercomConfig {
1010
}
1111

1212
@Injectable({
13-
providedIn: 'root'
13+
providedIn: 'root',
1414
})
1515
export class DfIntercomConfigService {
16-
private configSubject = new BehaviorSubject<IntercomConfig>({ intercomWidget: true });
16+
private configSubject = new BehaviorSubject<IntercomConfig>({
17+
intercomWidget: true,
18+
});
1719
public config$ = this.configSubject.asObservable();
1820
private readonly INTERCOM_KEY = 'intercom_widget_enabled';
1921

@@ -32,70 +34,81 @@ export class DfIntercomConfigService {
3234

3335
getConfig(): Observable<IntercomConfig> {
3436
// Get the lookup key for Intercom configuration
35-
return this.lookupService.getAll<any>({ filter: `name="${this.INTERCOM_KEY}"` }).pipe(
36-
map(response => {
37-
const lookupKey = response?.resource?.[0];
38-
const config: IntercomConfig = {
39-
intercomWidget: lookupKey ? lookupKey.value === 'true' : true,
40-
intercomAppId: 'ymvqkyiw'
41-
};
42-
this.configSubject.next(config);
43-
return config;
44-
}),
45-
catchError(() => {
46-
// If config doesn't exist or error occurs, return default
47-
const defaultConfig: IntercomConfig = {
48-
intercomWidget: true,
49-
intercomAppId: 'ymvqkyiw'
50-
};
51-
this.configSubject.next(defaultConfig);
52-
return of(defaultConfig);
53-
})
54-
);
37+
return this.lookupService
38+
.getAll<any>({ filter: `name="${this.INTERCOM_KEY}"` })
39+
.pipe(
40+
map(response => {
41+
const lookupKey = response?.resource?.[0];
42+
const config: IntercomConfig = {
43+
intercomWidget: lookupKey ? lookupKey.value === 'true' : true,
44+
intercomAppId: 'ymvqkyiw',
45+
};
46+
this.configSubject.next(config);
47+
return config;
48+
}),
49+
catchError(() => {
50+
// If config doesn't exist or error occurs, return default
51+
const defaultConfig: IntercomConfig = {
52+
intercomWidget: true,
53+
intercomAppId: 'ymvqkyiw',
54+
};
55+
this.configSubject.next(defaultConfig);
56+
return of(defaultConfig);
57+
})
58+
);
5559
}
5660

5761
updateConfig(config: IntercomConfig): Observable<any> {
5862
const value = config.intercomWidget ? 'true' : 'false';
5963

6064
// First check if the key exists
61-
return this.lookupService.getAll<any>({ filter: `name="${this.INTERCOM_KEY}"` }).pipe(
62-
map(response => response?.resource?.[0]),
63-
catchError(() => of(null)),
64-
switchMap(existingKey => {
65-
console.log('Existing lookup key:', existingKey);
66-
if (existingKey) {
67-
// Update existing key
68-
console.log('Updating existing key with id:', existingKey.id, 'value:', value);
69-
return this.lookupService.patch(existingKey.id, { value }).pipe(
70-
tap(() => {
71-
console.log('Successfully updated lookup key');
72-
this.configSubject.next(config);
73-
})
74-
);
75-
} else {
76-
// Create new key - DreamFactory expects data wrapped in resource array
77-
const payload = {
78-
resource: [{
79-
name: this.INTERCOM_KEY,
80-
value,
81-
private: false
82-
}]
83-
};
84-
console.log('Creating new lookup key with payload:', payload);
85-
return this.lookupService.create(payload).pipe(
86-
tap(() => {
87-
console.log('Successfully created lookup key');
88-
this.configSubject.next(config);
89-
})
90-
);
91-
}
92-
}),
93-
catchError(error => {
94-
console.error('Failed to update Intercom config:', error);
95-
console.error('Error details:', error.error || error);
96-
throw error;
97-
})
98-
);
65+
return this.lookupService
66+
.getAll<any>({ filter: `name="${this.INTERCOM_KEY}"` })
67+
.pipe(
68+
map(response => response?.resource?.[0]),
69+
catchError(() => of(null)),
70+
switchMap(existingKey => {
71+
console.log('Existing lookup key:', existingKey);
72+
if (existingKey) {
73+
// Update existing key
74+
console.log(
75+
'Updating existing key with id:',
76+
existingKey.id,
77+
'value:',
78+
value
79+
);
80+
return this.lookupService.patch(existingKey.id, { value }).pipe(
81+
tap(() => {
82+
console.log('Successfully updated lookup key');
83+
this.configSubject.next(config);
84+
})
85+
);
86+
} else {
87+
// Create new key - DreamFactory expects data wrapped in resource array
88+
const payload = {
89+
resource: [
90+
{
91+
name: this.INTERCOM_KEY,
92+
value,
93+
private: false,
94+
},
95+
],
96+
};
97+
console.log('Creating new lookup key with payload:', payload);
98+
return this.lookupService.create(payload).pipe(
99+
tap(() => {
100+
console.log('Successfully created lookup key');
101+
this.configSubject.next(config);
102+
})
103+
);
104+
}
105+
}),
106+
catchError(error => {
107+
console.error('Failed to update Intercom config:', error);
108+
console.error('Error details:', error.error || error);
109+
throw error;
110+
})
111+
);
99112
}
100113

101114
get currentConfig(): IntercomConfig {
@@ -105,4 +118,4 @@ export class DfIntercomConfigService {
105118
get isIntercomEnabled(): boolean {
106119
return this.configSubject.value.intercomWidget ?? true;
107120
}
108-
}
121+
}

src/app/shared/services/intercom.service.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class IntercomService {
5959
instance_url: window.location.origin,
6060
license_key: systemEnvironment.platform?.licenseKey || 'N/A',
6161
DreamFactoryTier: systemEnvironment.platform?.license || 'N/A',
62-
"DreamFactory version": systemEnvironment.platform?.version || 'N/A',
62+
'DreamFactory version': systemEnvironment.platform?.version || 'N/A',
6363
plan: systemEnvironment.platform?.license || 'N/A',
6464
is_hosted: systemEnvironment.platform?.isHosted || false,
6565
is_trial: systemEnvironment.platform?.isTrial || false,
@@ -104,11 +104,7 @@ export class IntercomService {
104104
const apiConfig = this.dfIntercomConfigService.currentConfig;
105105
const intercomEnabled = apiConfig.intercomWidget ?? true; // Default to true if no config exists
106106

107-
if (
108-
!intercomEnabled ||
109-
!(window as any).Intercom ||
110-
!this.intercomLoaded
111-
) {
107+
if (!intercomEnabled || !(window as any).Intercom || !this.intercomLoaded) {
112108
return;
113109
}
114110

@@ -130,7 +126,7 @@ export class IntercomService {
130126
instance_url: window.location.origin,
131127
license_key: systemEnvironment.platform?.licenseKey || 'N/A',
132128
DreamFactoryTier: systemEnvironment.platform?.license || 'N/A',
133-
"DreamFactory version": systemEnvironment.platform?.version || 'N/A',
129+
'DreamFactory version': systemEnvironment.platform?.version || 'N/A',
134130
plan: systemEnvironment.platform?.license || 'N/A',
135131
is_hosted: systemEnvironment.platform?.isHosted || false,
136132
is_trial: systemEnvironment.platform?.isTrial || false,

0 commit comments

Comments
 (0)