diff --git a/frontend/src/app/features/calculator/calculator-page.component.ts b/frontend/src/app/features/calculator/calculator-page.component.ts
index ea22dd7..80f9028 100644
--- a/frontend/src/app/features/calculator/calculator-page.component.ts
+++ b/frontend/src/app/features/calculator/calculator-page.component.ts
@@ -7,6 +7,7 @@ import { AppAlertComponent } from '../../shared/components/app-alert/app-alert.c
import { UploadFormComponent } from './components/upload-form/upload-form.component';
import { QuoteResultComponent } from './components/quote-result/quote-result.component';
import { QuoteEstimatorService, QuoteRequest, QuoteResult } from './services/quote-estimator.service';
+import { Router } from '@angular/router';
@Component({
selector: 'app-calculator-page',
@@ -56,7 +57,7 @@ import { QuoteEstimatorService, QuoteRequest, QuoteResult } from './services/quo
Potrebbe richiedere qualche secondo.
} @else if (result()) {
-
+
} @else {
{{ 'CALC.BENEFITS_TITLE' | translate }}
@@ -146,9 +147,10 @@ export class CalculatorPageComponent {
result = signal(null);
error = signal(false);
- constructor(private estimator: QuoteEstimatorService) {}
+ constructor(private estimator: QuoteEstimatorService, private router: Router) {}
onCalculate(req: QuoteRequest) {
+ this.currentRequest = req; // Store request for consultation
this.loading.set(true);
this.error.set(false);
this.result.set(null);
@@ -164,4 +166,30 @@ export class CalculatorPageComponent {
}
});
}
+
+ private currentRequest: QuoteRequest | null = null;
+
+ onConsult() {
+ if (!this.currentRequest) return;
+
+ const req = this.currentRequest;
+ let details = `Richiesta Preventivo:\n`;
+ details += `- Materiale: ${req.material}\n`;
+ details += `- Qualità : ${req.quality}\n`;
+ details += `- Quantità : ${req.quantity}\n`;
+
+ if (req.mode === 'advanced') {
+ if (req.color) details += `- Colore: ${req.color}\n`;
+ if (req.infillDensity) details += `- Infill: ${req.infillDensity}%\n`;
+ }
+
+ if (req.notes) details += `\nNote: ${req.notes}`;
+
+ this.estimator.setPendingConsultation({
+ files: req.files,
+ message: details
+ });
+
+ this.router.navigate(['/contact']);
+ }
}
diff --git a/frontend/src/app/features/calculator/components/quote-result/quote-result.component.ts b/frontend/src/app/features/calculator/components/quote-result/quote-result.component.ts
index 4b701fd..1a2e9da 100644
--- a/frontend/src/app/features/calculator/components/quote-result/quote-result.component.ts
+++ b/frontend/src/app/features/calculator/components/quote-result/quote-result.component.ts
@@ -34,7 +34,7 @@ import { QuoteResult } from '../../services/quote-estimator.service';
{{ 'CALC.ORDER' | translate }}
-
{{ 'CALC.CONSULT' | translate }}
+
{{ 'CALC.CONSULT' | translate }}
`,
@@ -53,4 +53,5 @@ import { QuoteResult } from '../../services/quote-estimator.service';
})
export class QuoteResultComponent {
result = input.required();
+ consult = output();
}
diff --git a/frontend/src/app/features/calculator/services/quote-estimator.service.ts b/frontend/src/app/features/calculator/services/quote-estimator.service.ts
index dc959ad..d278ee4 100644
--- a/frontend/src/app/features/calculator/services/quote-estimator.service.ts
+++ b/frontend/src/app/features/calculator/services/quote-estimator.service.ts
@@ -1,4 +1,4 @@
-import { Injectable, inject } from '@angular/core';
+import { Injectable, inject, signal } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, forkJoin, of } from 'rxjs';
import { map, catchError } from 'rxjs/operators';
@@ -134,4 +134,17 @@ export class QuoteEstimatorService {
if (q.includes('high')) return 'extra_fine';
return 'standard';
}
+
+ // Consultation Data Transfer
+ private pendingConsultation = signal<{files: File[], message: string} | null>(null);
+
+ setPendingConsultation(data: {files: File[], message: string}) {
+ this.pendingConsultation.set(data);
+ }
+
+ getPendingConsultation() {
+ const data = this.pendingConsultation();
+ this.pendingConsultation.set(null); // Clear after reading
+ return data;
+ }
}
diff --git a/frontend/src/app/features/contact/components/contact-form/contact-form.component.ts b/frontend/src/app/features/contact/components/contact-form/contact-form.component.ts
index 7770e6c..30bf471 100644
--- a/frontend/src/app/features/contact/components/contact-form/contact-form.component.ts
+++ b/frontend/src/app/features/contact/components/contact-form/contact-form.component.ts
@@ -4,6 +4,7 @@ import { ReactiveFormsModule, FormBuilder, FormGroup, Validators } from '@angula
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { AppInputComponent } from '../../../../shared/components/app-input/app-input.component';
import { AppButtonComponent } from '../../../../shared/components/app-button/app-button.component';
+import { QuoteEstimatorService } from '../../../calculator/services/quote-estimator.service';
interface FilePreview {
file: File;
@@ -242,7 +243,11 @@ export class ContactFormComponent {
{ value: 'question', label: 'CONTACT.REQ_TYPE_QUESTION' }
];
- constructor(private fb: FormBuilder, private translate: TranslateService) {
+ constructor(
+ private fb: FormBuilder,
+ private translate: TranslateService,
+ private estimator: QuoteEstimatorService
+ ) {
this.form = this.fb.group({
requestType: ['custom', Validators.required],
name: ['', Validators.required],
@@ -279,6 +284,27 @@ export class ContactFormComponent {
companyNameControl?.updateValueAndValidity();
refPersonControl?.updateValueAndValidity();
});
+
+ // Check for pending consultation data
+ effect(() => {
+ // Use timeout or run in constructor to ensure dependency availability?
+ // Actually best in constructor or ngOnInit. Let's stick to constructor logic but executed immediately.
+ });
+
+ const pending = this.estimator.getPendingConsultation();
+ if (pending) {
+ this.form.patchValue({
+ requestType: 'consult',
+ message: pending.message
+ });
+
+ // Process files
+ const filePreviews: FilePreview[] = [];
+ pending.files.forEach(f => {
+ filePreviews.push({ file: f, type: this.getFileType(f) });
+ });
+ this.files.set(filePreviews);
+ }
}
setCompanyMode(isCompany: boolean) {