import type { Token } from "@/types/index";
import { createSlice } from "@reduxjs/toolkit";
import type { Chain } from "./globalSlice";

const initialState: MultiTokenParams = {
	isVisible: false,
	data: null,
};

const multiTokenModalSlice = createSlice({
	name: "multiTokenModal",
	initialState,
	reducers: {
		setMultiTokenData: (state, action) => {
			state.isVisible = action.payload.isVisible;
			state.data = action.payload.data;
		},
	},
});

export interface MultiTokenParams {
	isVisible: boolean;
	data: {
		id: number;
		isSource: boolean;
		defaultToken: Token;
		otherTokens: Token[];
		activeChain?: Chain | "all";
	} | null;
}

export const { setMultiTokenData } = multiTokenModalSlice.actions;
export default multiTokenModalSlice.reducer;
