chore: remove orphaned backoffice/builder dead code
Sprint 2 high-priority cleanup: backoffice-dashboard.component.ts and builder-sandbox.component.ts were not routed anywhere, superseded by features/backoffice and features/project-editor. Their sole facades (BackofficeFacade, BuilderConfigFacade) had no other consumers. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
import { Injectable, signal } from '@angular/core';
|
||||
import { ProductCardConfig, CategoryCardConfig } from '../../shared/models/ui';
|
||||
import { BackofficeDataService } from '../../core/backoffice/backoffice-data.service';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class BackofficeFacade {
|
||||
readonly products = signal<ProductCardConfig[]>([]);
|
||||
readonly categories = signal<CategoryCardConfig[]>([]);
|
||||
readonly loading = signal(false);
|
||||
|
||||
constructor(private readonly backofficeDataService: BackofficeDataService) {}
|
||||
|
||||
load(): void {
|
||||
this.loading.set(true);
|
||||
|
||||
this.backofficeDataService.loadProducts().subscribe({
|
||||
next: (products) => {
|
||||
this.products.set(products ?? []);
|
||||
this.loadCategories();
|
||||
},
|
||||
error: () => {
|
||||
this.products.set([]);
|
||||
this.loadCategories();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private loadCategories(): void {
|
||||
this.backofficeDataService.loadCategories().subscribe({
|
||||
next: (categories) => {
|
||||
this.categories.set(categories ?? []);
|
||||
this.loading.set(false);
|
||||
},
|
||||
error: () => {
|
||||
this.categories.set([]);
|
||||
this.loading.set(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
import { Injectable, computed, signal } from '@angular/core';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { BootstrapConfig } from '../../shared/models/config';
|
||||
import { ConfigService } from '../../core/config/config.service';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class BuilderConfigFacade {
|
||||
private readonly bootstrapState = signal<BootstrapConfig | null>(null);
|
||||
|
||||
readonly bootstrap = this.bootstrapState.asReadonly();
|
||||
readonly branding = computed(() => this.bootstrapState()?.branding ?? null);
|
||||
readonly featureFlags = computed(() => this.bootstrapState()?.featureFlags ?? null);
|
||||
|
||||
constructor(private readonly configService: ConfigService) {}
|
||||
|
||||
load(): void {
|
||||
this.configService.loadBootstrap().pipe(take(1)).subscribe({
|
||||
next: (config) => this.bootstrapState.set(JSON.parse(JSON.stringify(config)) as BootstrapConfig),
|
||||
error: () => this.bootstrapState.set(null)
|
||||
});
|
||||
}
|
||||
|
||||
updateBrandName(nextBrandName: string): void {
|
||||
const current = this.bootstrapState();
|
||||
if (!current) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.bootstrapState.set({
|
||||
...current,
|
||||
branding: {
|
||||
...current.branding,
|
||||
brandName: nextBrandName
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setFeatureFlag(flag: string, enabled: boolean): void {
|
||||
const current = this.bootstrapState();
|
||||
if (!current) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.bootstrapState.set({
|
||||
...current,
|
||||
featureFlags: {
|
||||
...current.featureFlags,
|
||||
[flag]: enabled
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
|
||||
import { BackofficeFacade } from '../../facades/backoffice/backoffice.facade';
|
||||
import { TranslatePipe } from '../../i18n/translate.pipe';
|
||||
|
||||
@Component({
|
||||
selector: 'app-backoffice-dashboard',
|
||||
standalone: true,
|
||||
imports: [CommonModule, TranslatePipe],
|
||||
template: `
|
||||
<main class="backoffice-dashboard">
|
||||
<h1>{{ 'backoffice.title' | translate }}</h1>
|
||||
<p>{{ 'backoffice.subtitle' | translate }}</p>
|
||||
|
||||
@if (loading()) {
|
||||
<section class="card">{{ 'backoffice.loading' | translate }}</section>
|
||||
} @else {
|
||||
<section class="card">
|
||||
<h2>{{ 'backoffice.products' | translate }}</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ 'backoffice.sku' | translate }}</th>
|
||||
<th>{{ 'backoffice.titleColumn' | translate }}</th>
|
||||
<th>{{ 'backoffice.price' | translate }}</th>
|
||||
<th>{{ 'backoffice.status' | translate }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (product of products(); track product.id) {
|
||||
<tr>
|
||||
<td>{{ product.sku }}</td>
|
||||
<td>{{ product.title }}</td>
|
||||
<td>{{ product.price.amount }} {{ product.price.currency }}</td>
|
||||
<td>{{ product.stockStatus ?? ('backoffice.notAvailable' | translate) }}</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2>{{ 'backoffice.categories' | translate }}</h2>
|
||||
<ul>
|
||||
@for (category of categories(); track category.id) {
|
||||
<li>{{ category.title }} ({{ category.itemsCount ?? 0 }} {{ 'backoffice.itemsCount' | translate }})</li>
|
||||
}
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="card placeholders">
|
||||
<h2>{{ 'backoffice.otherDomains' | translate }}</h2>
|
||||
<div class="chips">
|
||||
<span>{{ 'backoffice.orders' | translate }}</span>
|
||||
<span>{{ 'backoffice.customers' | translate }}</span>
|
||||
<span>{{ 'backoffice.inventory' | translate }}</span>
|
||||
<span>{{ 'backoffice.media' | translate }}</span>
|
||||
<span>{{ 'backoffice.settings' | translate }}</span>
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
</main>
|
||||
`,
|
||||
styles: [
|
||||
`
|
||||
.backoffice-dashboard { padding: 1.5rem; display: grid; gap: 1rem; }
|
||||
.card { border: 1px solid var(--border-color, #d3dad9); border-radius: 12px; padding: 1rem; background: #fff; }
|
||||
table { width: 100%; border-collapse: collapse; }
|
||||
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid #ececec; }
|
||||
ul { margin: 0; padding-left: 1rem; }
|
||||
.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; }
|
||||
.chips span { padding: 0.25rem 0.5rem; border-radius: 999px; background: var(--bg-secondary, #f5f5f5); }
|
||||
`
|
||||
],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class BackofficeDashboardComponent {
|
||||
private readonly facade = inject(BackofficeFacade);
|
||||
|
||||
readonly products = this.facade.products;
|
||||
readonly categories = this.facade.categories;
|
||||
readonly loading = this.facade.loading;
|
||||
|
||||
constructor() {
|
||||
this.facade.load();
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { BuilderConfigFacade } from '../../facades/builder/builder-config.facade';
|
||||
import { TranslatePipe } from '../../i18n/translate.pipe';
|
||||
|
||||
@Component({
|
||||
selector: 'app-builder-sandbox',
|
||||
standalone: true,
|
||||
imports: [CommonModule, FormsModule, TranslatePipe],
|
||||
template: `
|
||||
<main class="builder-sandbox">
|
||||
<h1>{{ 'builder.title' | translate }}</h1>
|
||||
<p>{{ 'builder.subtitle' | translate }}</p>
|
||||
|
||||
@if (branding(); as brand) {
|
||||
<section class="builder-card">
|
||||
<h2>{{ 'builder.branding' | translate }}</h2>
|
||||
<label>
|
||||
{{ 'builder.brandName' | translate }}
|
||||
<input type="text" [ngModel]="brand.brandName" (ngModelChange)="onBrandNameChange($event)" />
|
||||
</label>
|
||||
</section>
|
||||
}
|
||||
|
||||
@if (featureFlags(); as flags) {
|
||||
<section class="builder-card">
|
||||
<h2>{{ 'builder.featureFlags' | translate }}</h2>
|
||||
@for (flag of featureFlagKeys(); track flag) {
|
||||
<label class="flag-row">
|
||||
<input type="checkbox" [checked]="flags[flag]" (change)="onFlagToggle(flag, $event)" />
|
||||
<span>{{ flag }}</span>
|
||||
</label>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
</main>
|
||||
`,
|
||||
styles: [
|
||||
`
|
||||
.builder-sandbox { padding: 1.5rem; display: grid; gap: 1rem; }
|
||||
.builder-card { border: 1px solid var(--border-color, #d3dad9); border-radius: 12px; padding: 1rem; display: grid; gap: 0.75rem; }
|
||||
input[type='text'] { width: 100%; max-width: 420px; padding: 0.5rem; border-radius: 8px; border: 1px solid var(--border-color, #d3dad9); }
|
||||
.flag-row { display: flex; align-items: center; gap: 0.5rem; }
|
||||
`
|
||||
],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class BuilderSandboxComponent {
|
||||
private readonly facade = inject(BuilderConfigFacade);
|
||||
|
||||
readonly branding = this.facade.branding;
|
||||
readonly featureFlags = this.facade.featureFlags;
|
||||
readonly featureFlagKeys = computed(() => Object.keys(this.featureFlags() ?? {}).sort());
|
||||
|
||||
constructor() {
|
||||
this.facade.load();
|
||||
}
|
||||
|
||||
onBrandNameChange(value: string): void {
|
||||
this.facade.updateBrandName(value);
|
||||
}
|
||||
|
||||
onFlagToggle(flag: string, event: Event): void {
|
||||
const input = event.target as HTMLInputElement;
|
||||
this.facade.setFeatureFlag(flag, input.checked);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user