import {ComponentExporterImporter, PreloadedDynamicValues} from "../ComponentExporterImporter";
import {TestableData} from "../../store";
import {CategoriesOptions} from "../../cards/Categories";
import {ExportImportTarget} from "../Exporters";

export class BrandsExporterImporter implements ComponentExporterImporter<TestableData<CategoriesOptions>, TestableData<CategoriesOptions>> {
    type= 'InBrands'

    /**
     * Remove ids when this is a preset
     */
    exportData(data: TestableData<CategoriesOptions>, target: ExportImportTarget): TestableData<CategoriesOptions> {
        if (target === 'preset') {
            data.options.expectedValues = []
            data.options.excludedSubsetValues && (data.options.excludedSubsetValues = [])
        }

        return data
    }

    tagDynamicValues({
                         options: {
                             expectedValues,
                             excludedSubsetValues
                         }
                     }: TestableData<CategoriesOptions>, target: ExportImportTarget): PreloadedDynamicValues {
        return {
            category: 'brands',
            values: [...expectedValues, ...(excludedSubsetValues || [])]
        };
    }
}