import { StateCreator } from 'zustand';
import type { PrepareImportFileResponse } from '../typings/types';
import type { ImporterSlice, CombinedStore } from './types';

export const createImporterSlice: StateCreator<
	CombinedStore,
	[],
	[],
	ImporterSlice
> = (set, getState) => ({
	filePath: null,
	disambiguation: null,
	fileContents: null,
	setFilePath: (filePath: string) => {
		set({ filePath });
	},
	setDisambiguation: (
		disambiguation: PrepareImportFileResponse['data']['disambiguation']
	) => {
		set({ disambiguation });
	},
	setFileContents: (fileContents: Array<Array<string>>) => {
		set({ fileContents });
	},
	clearStore: () => {
		// TODO
		set({
			filePath: null,
		});
	},
});
