import type { FormattedQuoteResponse } from "@hooks/apis/common/quote/types";
import { createSlice } from "@reduxjs/toolkit";

const initialState: RoutesParams = {
	activeRoute: undefined,
	isLoading: false,
	isRefetching: false,
};

const routesStates = createSlice({
	name: "routes",
	initialState,
	reducers: {
		setActiveRoute: (state, action) => {
			state.activeRoute = action.payload;
		},
		setLoading: (state, action) => {
			state.isLoading = action.payload;
		},
		setRefetching: (state, action) => {
			state.isRefetching = action.payload;
		},
	},
});

export const { setActiveRoute, setLoading, setRefetching } =
	routesStates.actions;
export default routesStates.reducer;

export interface RoutesParams {
	activeRoute?: FormattedQuoteResponse;
	isLoading: boolean;
	isRefetching: boolean;
}
