import { Injectable } from '@angular/core';
import { ColumnConfigState, ColumnConfigStorage } from './column-config-storage';

/**
 * In-memory implementation of ColumnConfigStorage.
 * State is lost on page reload. Replace with a DB-backed
 * service when server-side persistence is needed.
 */
@Injectable({ providedIn: 'root' })
export class InMemoryColumnConfigStorage extends ColumnConfigStorage {
  private readonly store = new Map<string, ColumnConfigState>();

  load(gridId: string): ColumnConfigState | null {
    return this.store.get(gridId) ?? null;
  }

  save(gridId: string, state: ColumnConfigState): void {
    this.store.set(gridId, state);
  }
}
