Преглед на файлове

change to ffb production

Dr-Swopt преди 2 месеца
родител
ревизия
6cab55c17d

+ 0 - 0
src/app/components/ffb-calculation/ffb-harvest-calculate-dialog.component.css → src/app/components/ffb-calculation/ffb-production-calculate-dialog.component.css


+ 1 - 1
src/app/components/ffb-calculation/ffb-harvest-calculate-dialog.component.html → src/app/components/ffb-calculation/ffb-production-calculate-dialog.component.html

@@ -1,4 +1,4 @@
-<h2 mat-dialog-title>FFB Harvest Summary</h2>
+<h2 mat-dialog-title>FFB Production Summary</h2>
 
 <mat-dialog-content>
   <section>

+ 6 - 5
src/app/components/ffb-calculation/ffb-harvest-calculate-dialog.component.ts → src/app/components/ffb-calculation/ffb-production-calculate-dialog.component.ts

@@ -3,6 +3,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
 import { CommonModule } from '@angular/common';
 import { MatDialogModule } from '@angular/material/dialog';
 import { MatButtonModule } from '@angular/material/button';
+import { FFBProduction } from '../../ffb/ffb-production.interface';
 
 export interface FFBHarvest {
   _id?: string;
@@ -19,11 +20,11 @@ export interface FFBHarvest {
 }
 
 @Component({
-  selector: 'app-ffb-harvest-calculate-dialog',
+  selector: 'app-ffb-production-calculate-dialog',
   standalone: true,
   imports: [CommonModule, MatDialogModule, MatButtonModule],
-  templateUrl: './ffb-harvest-calculate-dialog.component.html',
-  styleUrls: ['./ffb-harvest-calculate-dialog.component.css'],
+  templateUrl: './ffb-production-calculate-dialog.component.html',
+  styleUrls: ['./ffb-production-calculate-dialog.component.css'],
 })
 export class FfbHarvestCalculateDialogComponent implements OnInit {
   totalWeight: Record<string, number> = {};
@@ -35,7 +36,7 @@ export class FfbHarvestCalculateDialogComponent implements OnInit {
 
   constructor(
     private dialogRef: MatDialogRef<FfbHarvestCalculateDialogComponent>,
-    @Inject(MAT_DIALOG_DATA) public data: { harvests: FFBHarvest[] }
+    @Inject(MAT_DIALOG_DATA) public data: { productions: FFBProduction[] }
   ) {}
 
   ngOnInit(): void {
@@ -48,7 +49,7 @@ export class FfbHarvestCalculateDialogComponent implements OnInit {
     const weightCounts: Record<string, number> = {};
     const quantityCounts: Record<string, number> = {};
 
-    this.data.harvests.forEach(h => {
+    this.data.productions.forEach(h => {
       // Weight
       if (!weightTotals[h.weightUom]) {
         weightTotals[h.weightUom] = 0;

+ 0 - 0
src/app/components/ffb-harvest-dialog/create-ffb-harvest-dialog.component.css → src/app/components/ffb-production-dialog/create-ffb-production-dialog.component.css


+ 9 - 21
src/app/components/ffb-harvest-dialog/create-ffb-harvest-dialog.component.html → src/app/components/ffb-production-dialog/create-ffb-production-dialog.component.html

@@ -1,20 +1,20 @@
 <h2 mat-dialog-title>
-  {{ data?.harvest ? 'View/Edit FFB Harvest' : 'Create FFB Harvest' }}
+  {{ data?.production ? 'View/Edit FFB Production' : 'Create FFB Production' }}
 </h2>
 
 <form [formGroup]="form" (ngSubmit)="onSubmit()" class="dialog-form">
   <div class="form-section">
 
     <mat-form-field appearance="outline" class="flex-1">
-      <mat-label>Harvest Date</mat-label>
-      <input matInput [matDatepicker]="picker" formControlName="harvestDate" [readonly]="!!data?.harvest" />
+      <mat-label>Production Date</mat-label>
+      <input matInput [matDatepicker]="picker" formControlName="productionDate" [readonly]="!!data?.production" />
       <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
       <mat-datepicker #picker></mat-datepicker>
     </mat-form-field>
 
     <mat-form-field appearance="outline">
       <mat-label>Site</mat-label>
-      <input matInput [formControl]="siteControl" [matAutocomplete]="siteAuto" [readonly]="!!data?.harvest" />
+      <input matInput [formControl]="siteControl" [matAutocomplete]="siteAuto" [readonly]="!!data?.production" />
       <mat-autocomplete #siteAuto="matAutocomplete">
         <mat-option *ngFor="let option of filteredSites | async" [value]="option">{{ option }}</mat-option>
       </mat-autocomplete>
@@ -22,7 +22,7 @@
 
     <mat-form-field appearance="outline">
       <mat-label>Phase</mat-label>
-      <input matInput [formControl]="phaseControl" [matAutocomplete]="phaseAuto" [readonly]="!!data?.harvest" />
+      <input matInput [formControl]="phaseControl" [matAutocomplete]="phaseAuto" [readonly]="!!data?.production" />
       <mat-autocomplete #phaseAuto="matAutocomplete">
         <mat-option *ngFor="let option of filteredPhases | async" [value]="option">{{ option }}</mat-option>
       </mat-autocomplete>
@@ -30,20 +30,12 @@
 
     <mat-form-field appearance="outline">
       <mat-label>Block</mat-label>
-      <input matInput [formControl]="blockControl" [matAutocomplete]="blockAuto" [readonly]="!!data?.harvest" />
+      <input matInput [formControl]="blockControl" [matAutocomplete]="blockAuto" [readonly]="!!data?.production" />
       <mat-autocomplete #blockAuto="matAutocomplete">
         <mat-option *ngFor="let option of filteredBlocks | async" [value]="option">{{ option }}</mat-option>
       </mat-autocomplete>
     </mat-form-field>
 
-    <mat-form-field appearance="outline">
-      <mat-label>Harvester</mat-label>
-      <input matInput [formControl]="harvesterControl" [matAutocomplete]="harvesterAuto" [readonly]="!!data?.harvest" />
-      <mat-autocomplete #harvesterAuto="matAutocomplete">
-        <mat-option *ngFor="let option of filteredHarvesters | async" [value]="option">{{ option }}</mat-option>
-      </mat-autocomplete>
-    </mat-form-field>
-
     <mat-form-field appearance="outline" class="flex-1">
       <mat-label>Quantity</mat-label>
       <input matInput type="number" formControlName="quantity" [readonly]="!!data?.harvest" />
@@ -65,21 +57,17 @@
 
     <mat-form-field appearance="outline" class="flex-1">
       <mat-label>Weight UOM</mat-label>
-      <input type="text" matInput formControlName="weightUom" [matAutocomplete]="weightUomAuto" [readonly]="!!data?.harvest" />
+      <input type="text" matInput formControlName="weightUom" [matAutocomplete]="weightUomAuto"
+        [readonly]="!!data?.harvest" />
       <mat-autocomplete #weightUomAuto="matAutocomplete">
         <mat-option *ngFor="let u of weightUomOptions" [value]="u">{{ u }}</mat-option>
       </mat-autocomplete>
     </mat-form-field>
 
-    <mat-form-field appearance="outline" class="flex-1">
-      <mat-label>Days of Work</mat-label>
-      <input matInput type="number" formControlName="daysOfWork" [readonly]="!!data?.harvest" />
-    </mat-form-field>
-
   </div>
 
   <div class="dialog-footer">
     <button mat-stroked-button type="button" (click)="cancel()">Close</button>
     <button *ngIf="!data?.harvest" mat-flat-button color="primary" type="submit">Save</button>
   </div>
-</form>
+</form>

+ 14 - 23
src/app/components/ffb-harvest-dialog/create-ffb-harvest-dialog.component.ts → src/app/components/ffb-production-dialog/create-ffb-production-dialog.component.ts

@@ -15,7 +15,7 @@ import { Observable, startWith, map } from 'rxjs';
 import { webConfig } from '../../config';
 
 @Component({
-  selector: 'app-create-ffb-harvest-dialog',
+  selector: 'app-create-ffb-production-dialog',
   standalone: true,
   imports: [
     CommonModule,
@@ -31,32 +31,32 @@ import { webConfig } from '../../config';
     MatIconModule,
     MatSnackBarModule,
   ],
-  templateUrl: './create-ffb-harvest-dialog.component.html',
-  styleUrls: ['./create-ffb-harvest-dialog.component.css'],
+  templateUrl: './create-ffb-production-dialog.component.html',
+  styleUrls: ['./create-ffb-production-dialog.component.css'],
 })
-export class CreateFfbHarvestDialogComponent implements OnInit {
+export class CreateFfbProductionDialogComponent implements OnInit {
   form: FormGroup;
   saving = false;
 
   weightUomOptions = ['Kg', 'Ton'];
-  quantityUomOptions = ['Bunch', 'Bundle', 'Bag'];
+  quantityUomOptions = ['Bunch', 'Bag'];
 
   allSites: string[] = [];
   allPhases: string[] = [];
   allBlocks: string[] = [];
-  allHarvesters: string[] = [];
+  allWorkers: string[] = [];
 
   filteredSites!: Observable<string[]>;
   filteredPhases!: Observable<string[]>;
   filteredBlocks!: Observable<string[]>;
-  filteredHarvesters!: Observable<string[]>;
+  filteredWorkers!: Observable<string[]>;
 
   private conversionMap: Record<string, number> = { Bunch: 10, Bundle: 25, Bag: 100 };
 
   constructor(
     private fb: FormBuilder,
     private http: HttpClient,
-    private dialogRef: MatDialogRef<CreateFfbHarvestDialogComponent>,
+    private dialogRef: MatDialogRef<CreateFfbProductionDialogComponent>,
     private snackBar: MatSnackBar,
     @Inject(MAT_DIALOG_DATA) public data: any
   ) {
@@ -64,20 +64,17 @@ export class CreateFfbHarvestDialogComponent implements OnInit {
     this.allSites = data?.allSites || [];
     this.allPhases = data?.allPhases || [];
     this.allBlocks = data?.allBlocks || [];
-    this.allHarvesters = data?.allHarvesters || [];
     console.log(data)
 
     this.form = this.fb.group({
-      harvestDate: [new Date(), Validators.required],
+      productionDate: [new Date(), Validators.required],
       site: ['', Validators.required],
       phase: ['', Validators.required],
       block: ['', Validators.required],
       quantity: [0, Validators.required],
       quantityUom: ['Bunch', Validators.required],
       weight: [0, Validators.required],
-      weightUom: ['Kg', Validators.required],
-      harvester: ['', Validators.required],
-      daysOfWork: [0, Validators.required],
+      weightUom: ['Kg', Validators.required]
     });
 
     // Auto-update weight
@@ -106,11 +103,6 @@ export class CreateFfbHarvestDialogComponent implements OnInit {
       startWith(this.blockControl.value || ''),
       map(val => this.filterOptions(val, this.allBlocks))
     );
-
-    this.filteredHarvesters = this.harvesterControl.valueChanges.pipe(
-      startWith(this.harvesterControl.value || ''),
-      map(val => this.filterOptions(val, this.allHarvesters))
-    );
   }
 
   private filterOptions(value: string, options: string[]): string[] {
@@ -130,18 +122,18 @@ export class CreateFfbHarvestDialogComponent implements OnInit {
 
     const payload = {
       ...this.form.value,
-      harvestDate: new Date(this.form.value.harvestDate).toISOString(),
+      productionDate: new Date(this.form.value.productionDate).toISOString(),
     };
 
     this.saving = true;
-    this.http.post(`${webConfig.exposedUrl}/api/ffb-harvest`, payload).subscribe({
+    this.http.post(`${webConfig.exposedUrl}/api/ffb-production`, payload).subscribe({
       next: () => {
-        this.snackBar.open('FFB Harvest saved!', 'Close', { duration: 3000 });
+        this.snackBar.open('FFB Production saved!', 'Close', { duration: 3000 });
         this.dialogRef.close('refresh');
       },
       error: (err) => {
         console.error(err);
-        this.snackBar.open('Failed to save FFB Harvest.', 'Close', { duration: 5000 });
+        this.snackBar.open('Failed to save FFB Production.', 'Close', { duration: 5000 });
         this.saving = false;
       },
     });
@@ -155,5 +147,4 @@ export class CreateFfbHarvestDialogComponent implements OnInit {
   get siteControl(): FormControl { return this.form.get('site') as FormControl; }
   get phaseControl(): FormControl { return this.form.get('phase') as FormControl; }
   get blockControl(): FormControl { return this.form.get('block') as FormControl; }
-  get harvesterControl(): FormControl { return this.form.get('harvester') as FormControl; }
 }

+ 2 - 2
src/app/dashboard/dashboard.component.html

@@ -12,8 +12,8 @@
     <app-activity></app-activity>
   </mat-tab>
   
-  <mat-tab label="FFB Harvest">
-    <app-ffb-harvest></app-ffb-harvest>
+  <mat-tab label="FFB Production">
+    <app-ffb-production></app-ffb-production>
   </mat-tab>
     
   <mat-tab label="Plantation">

+ 2 - 2
src/app/dashboard/dashboard.component.ts

@@ -7,7 +7,7 @@ import { MatButtonModule } from '@angular/material/button';
 import { DashboardHomeComponent } from './dashboard.home.component';
 import { PlantationTreeComponent } from "../plantation/plantation-tree.component";
 import { ActivityComponent } from '../activity/activity.component';
-import { FfbHarvestComponent } from "../ffb/ffb-harvest.component";
+import { FfbProductionComponent } from "../ffb/ffb-production.component";
 
 @Component({
   selector: 'app-dashboard',
@@ -20,7 +20,7 @@ import { FfbHarvestComponent } from "../ffb/ffb-harvest.component";
     DashboardHomeComponent,
     PlantationTreeComponent,
     ActivityComponent,
-    FfbHarvestComponent
+    FfbProductionComponent
 ],
   templateUrl: './dashboard.component.html',
   styleUrls: ['./dashboard.component.css']

+ 0 - 13
src/app/ffb/ffb-harvest.interface.ts

@@ -1,13 +0,0 @@
-export interface FFBHarvest {
-  _id?: string;
-  harvestDate: Date | string; // backend returns ISO string; convert to Date where needed
-  site: string;
-  phase: string;
-  block: string;
-  harvester: string;
-  daysOfWork: number;
-  weight: number;
-  weightUom: string;
-  quantity: number;
-  quantityUom: string;
-}

+ 1 - 1
src/app/ffb/ffb-harvest.component.css → src/app/ffb/ffb-production.component.css

@@ -1,5 +1,5 @@
 /* --- Container padding --- */
-.ffb-harvest-container {
+.ffb-production-container {
   padding: 1.5rem;
 }
 

+ 8 - 13
src/app/ffb/ffb-harvest.component.html → src/app/ffb/ffb-production.component.html

@@ -1,6 +1,6 @@
 <div class="toolbar">
   <div class="left-section">
-    <h2 style="margin-bottom: 15px;">FFB Harvests</h2>
+    <h2 style="margin-bottom: 15px;">FFB Productions</h2>
 
     <mat-form-field appearance="outline" class="search-field">
       <mat-label>Search</mat-label>
@@ -60,8 +60,8 @@
       <mat-icon>refresh</mat-icon>
     </button>
 
-    <button mat-flat-button color="primary" (click)="createHarvest()">
-      + Add FFB Harvest
+    <button mat-flat-button color="primary" (click)="createProduction()">
+      + Add FFB Production
     </button>
 
     <button mat-stroked-button color="warn" (click)="resetFilters()">
@@ -77,15 +77,10 @@
 
 <mat-progress-spinner *ngIf="loading" mode="indeterminate" diameter="48"></mat-progress-spinner>
 
-<table mat-table [dataSource]="filteredHarvests" class="mat-elevation-z8" *ngIf="!loading">
-  <ng-container matColumnDef="harvestDate">
+<table mat-table [dataSource]="filteredProductions" class="mat-elevation-z8" *ngIf="!loading">
+  <ng-container matColumnDef="productionDate">
     <th mat-header-cell *matHeaderCellDef>Date</th>
-    <td mat-cell *matCellDef="let h">{{ formatDate(h.harvestDate) }}</td>
-  </ng-container>
-
-  <ng-container matColumnDef="harvester">
-    <th mat-header-cell *matHeaderCellDef>Harvester</th>
-    <td mat-cell *matCellDef="let h">{{ h.harvester }}</td>
+    <td mat-cell *matCellDef="let h">{{ formatDate(h.productionDate) }}</td>
   </ng-container>
 
   <ng-container matColumnDef="site">
@@ -116,13 +111,13 @@
   <ng-container matColumnDef="actions">
     <th mat-header-cell *matHeaderCellDef></th>
     <td mat-cell *matCellDef="let h">
-      <button mat-icon-button color="warn" (click)="deleteHarvest(h._id); $event.stopPropagation()">
+      <button mat-icon-button color="warn" (click)="deleteProduction(h._id); $event.stopPropagation()">
         <mat-icon>delete</mat-icon>
       </button>
     </td>
   </ng-container>
 
   <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
-  <tr mat-row *matRowDef="let row; columns: displayedColumns" class="clickable-row" (click)="editHarvest(row)">
+  <tr mat-row *matRowDef="let row; columns: displayedColumns" class="clickable-row" (click)="editProduction(row)">
   </tr>
 </table>

+ 32 - 43
src/app/ffb/ffb-harvest.component.ts → src/app/ffb/ffb-production.component.ts

@@ -14,15 +14,15 @@ import { ReactiveFormsModule, FormControl } from '@angular/forms';
 import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
 import { MatDialog, MatDialogModule } from '@angular/material/dialog';
 import { combineLatest, startWith } from 'rxjs';
-import { FFBHarvest } from './ffb-harvest.interface';
+import { FFBProduction } from './ffb-production.interface';
 import { webConfig } from '../config';
-import { CreateFfbHarvestDialogComponent } from '../components/ffb-harvest-dialog/create-ffb-harvest-dialog.component';
-import { FfbHarvestCalculateDialogComponent } from '../components/ffb-calculation/ffb-harvest-calculate-dialog.component';
+import { CreateFfbProductionDialogComponent } from '../components/ffb-production-dialog/create-ffb-production-dialog.component';
+import { FfbHarvestCalculateDialogComponent } from '../components/ffb-calculation/ffb-production-calculate-dialog.component';
 
 @Component({
-  selector: 'app-ffb-harvest',
-  templateUrl: './ffb-harvest.component.html',
-  styleUrls: ['./ffb-harvest.component.css'],
+  selector: 'app-ffb-production',
+  templateUrl: './ffb-production.component.html',
+  styleUrls: ['./ffb-production.component.css'],
   standalone: true,
   imports: [
     CommonModule,
@@ -41,7 +41,7 @@ import { FfbHarvestCalculateDialogComponent } from '../components/ffb-calculatio
     MatDialogModule
   ],
 })
-export class FfbHarvestComponent implements OnInit {
+export class FfbProductionComponent implements OnInit {
   private http = inject(HttpClient);
   private snack = inject(MatSnackBar);
   private dialog = inject(MatDialog);
@@ -58,17 +58,15 @@ export class FfbHarvestComponent implements OnInit {
   startDateControl = new FormControl<Date | null>(null);
   endDateControl = new FormControl<Date | null>(null);
 
-  harvests: FFBHarvest[] = [];
-  filteredHarvests: FFBHarvest[] = [];
+  production: FFBProduction[] = [];
+  filteredProductions: FFBProduction[] = [];
 
   uniqueSites: string[] = [];
   uniquePhases: string[] = [];
   uniqueBlocks: string[] = [];
-  uniqueHarvesters: string[] = [];
 
   displayedColumns: string[] = [
-    'harvestDate',
-    'harvester',
+    'productionDate',
     'site',
     'phase',
     'block',
@@ -80,7 +78,7 @@ export class FfbHarvestComponent implements OnInit {
   loading = false;
 
   ngOnInit() {
-    this.loadHarvests();
+    this.loadFFBproduction();
 
     combineLatest([
       this.searchControl.valueChanges.pipe(startWith(this.searchControl.value)),
@@ -93,19 +91,16 @@ export class FfbHarvestComponent implements OnInit {
     ]).subscribe(() => this.applyFilters());
   }
 
-  loadHarvests() {
+  loadFFBproduction() {
     this.loading = true;
-    this.http.get<FFBHarvest[]>(`${webConfig.exposedUrl}/api/ffb-harvest`).subscribe({
+    this.http.get<FFBProduction[]>(`${webConfig.exposedUrl}/api/ffb-production`).subscribe({
       next: (data) => {
-        this.harvests = data.map(h => ({ ...h, harvestDate: new Date(h.harvestDate) }));
-        this.filteredHarvests = [...this.harvests];
-
+        this.production = data.map(h => ({ ...h, productionDate: new Date(h.productionDate) }));
+        this.filteredProductions = [...this.production];
         // populate unique arrays for filters and autocompletes
-        this.uniqueSites = [...new Set(this.harvests.map(h => h.site))];
-        this.uniquePhases = [...new Set(this.harvests.map(h => h.phase))];
-        this.uniqueBlocks = [...new Set(this.harvests.map(h => h.block))];
-        this.uniqueHarvesters = [...new Set(this.harvests.map(h => h.harvester))];
-
+        this.uniqueSites = [...new Set(this.production.map(h => h.site))];
+        this.uniquePhases = [...new Set(this.production.map(h => h.phase))];
+        this.uniqueBlocks = [...new Set(this.production.map(h => h.block))];
         this.loading = false;
       },
       error: (err) => {
@@ -125,13 +120,12 @@ export class FfbHarvestComponent implements OnInit {
     const weightUom = this.weightUomControl.value;
     const quantityUom = this.quantityUomControl.value;
 
-    this.filteredHarvests = this.harvests.filter(h => {
+    this.filteredProductions = this.production.filter(h => {
       const matchesKeyword =
         !keyword ||
         h.site.toLowerCase().includes(keyword) ||
         h.phase.toLowerCase().includes(keyword) ||
         h.block.toLowerCase().includes(keyword) ||
-        h.harvester.toLowerCase().includes(keyword) ||
         h.weight.toString().includes(keyword) ||
         h.quantity.toString().includes(keyword);
 
@@ -140,7 +134,7 @@ export class FfbHarvestComponent implements OnInit {
       const matchesWeightUom = !weightUom || h.weightUom === weightUom;
       const matchesQuantityUom = !quantityUom || h.quantityUom === quantityUom;
 
-      const hDate = new Date(h.harvestDate);
+      const hDate = new Date(h.productionDate);
       const matchesDate =
         (!startDate || hDate >= startDate) && (!endDate || hDate <= endDate);
 
@@ -157,20 +151,20 @@ export class FfbHarvestComponent implements OnInit {
     this.endDateControl.setValue(null);
     this.weightUomControl.setValue('');
     this.quantityUomControl.setValue('');
-    this.filteredHarvests = [...this.harvests];
+    this.filteredProductions = [...this.production];
   }
 
   refresh() {
-    this.loadHarvests();
+    this.loadFFBproduction();
   }
 
-  deleteHarvest(id?: string) {
+  deleteProduction(id?: string) {
     if (!id || !confirm('Are you sure you want to delete this record?')) return;
 
-    this.http.delete(`${webConfig.exposedUrl}/api/ffb-harvest/${id}`).subscribe({
+    this.http.delete(`${webConfig.exposedUrl}/api/ffb-production/${id}`).subscribe({
       next: () => {
         this.snack.open('Deleted', 'Close', { duration: 2000 });
-        this.loadHarvests();
+        this.loadFFBproduction();
       },
       error: (err) => {
         console.error(err);
@@ -186,46 +180,41 @@ export class FfbHarvestComponent implements OnInit {
 
   // ================== DIALOG HANDLERS ==================
 
-  createHarvest() {
-    const dialogRef = this.dialog.open(CreateFfbHarvestDialogComponent, {
+  createProduction() {
+    const dialogRef = this.dialog.open(CreateFfbProductionDialogComponent, {
       width: '800px',
       data: {
         allSites: this.uniqueSites,
         allPhases: this.uniquePhases,
         allBlocks: this.uniqueBlocks,
-        allHarvesters: this.uniqueHarvesters
       }
     });
 
     dialogRef.afterClosed().subscribe(result => {
-      if (result === 'refresh') this.loadHarvests();
+      if (result === 'refresh') this.loadFFBproduction();
     });
   }
 
-  editHarvest(harvest: FFBHarvest) {
-    const dialogRef = this.dialog.open(CreateFfbHarvestDialogComponent, {
+  editProduction(harvest: FFBProduction) {
+    const dialogRef = this.dialog.open(CreateFfbProductionDialogComponent, {
       width: '800px',
       data: {
         harvest,
         allSites: this.uniqueSites,
         allPhases: this.uniquePhases,
         allBlocks: this.uniqueBlocks,
-        allHarvesters: this.uniqueHarvesters
       }
     });
 
     dialogRef.afterClosed().subscribe(result => {
-      if (result === 'refresh') this.loadHarvests();
+      if (result === 'refresh') this.loadFFBproduction();
     });
   }
 
   openCalculateDialog() {
     this.dialog.open(FfbHarvestCalculateDialogComponent, {
       data: {
-        allSites: this.uniqueSites,
-        allPhases: this.uniquePhases,
-        allBlocks: this.uniqueBlocks,
-        allHarvesters: this.uniqueHarvesters
+        productions: this.filteredProductions, // ✅ send the filtered list (or this.production)
       },
       width: '400px'
     });

+ 11 - 0
src/app/ffb/ffb-production.interface.ts

@@ -0,0 +1,11 @@
+export interface FFBProduction {
+  _id?: string;
+  productionDate: Date | string; // backend returns ISO string; convert to Date where needed
+  site: string;
+  phase: string;
+  block: string;
+  weight: number;
+  weightUom: string;
+  quantity: number;
+  quantityUom: string;
+}