import type { RequestType } from "@hooks/apis/useFetchQuote";
import type { RequestStatus } from "@hooks/apis/useRequestStatus";
import { createSlice } from "@reduxjs/toolkit";

const initialState: InflightParams = {
	requestHash: "",
	requestType: "SINGLE_OUTPUT_REQUEST",
};

const inflightSlice = createSlice({
	name: "inflight",
	initialState,
	reducers: {
		setInflightData: (state, action: { payload: InflightParams }) => {
			state.requestHash = action.payload.requestHash;
			state.data = action.payload.data;
			state.requestType = action.payload.requestType;
		},
	},
});

export interface InflightParams {
	requestHash: string;
	requestType: RequestType;
	data?: Partial<RequestStatus>;
}

export const { setInflightData } = inflightSlice.actions;
export default inflightSlice.reducer;
