import { create } from "zustand";

import { ReportType } from "@/contracts/client.schemas";

interface State {
	assetIdList: string[];
	reportType: ReportType;
	currentReportId?: string;

	openBuilder: (assetIdList: string[]) => void;
	setReportType: (reportType: ReportType) => void;
	setCurrentReportId: (id?: string) => void;
}

export const useReportStore = create<State>((set) => ({
	assetIdList: [],
	reportType: ReportType.ByState,
	currentReportId: undefined,

	openBuilder: (assetIdList: string[]) =>
		set((state) => ({
			...state,
			assetIdList: assetIdList,
		})),

	setReportType: (reportType: ReportType) =>
		set((state) => ({
			...state,
			reportType,
		})),

	setCurrentReportId: (id?: string) =>
		set((state) => ({
			...state,
			currentReportId: id,
		})),
}));
