import { createSlice, PayloadAction } from "@reduxjs/toolkit";

interface DateRangePickerState {
  vonDatum: string | null;
  bisDatum: string | null;
}

const initialState: DateRangePickerState = {
  vonDatum: null,
  bisDatum: null,
};

const dateRangePickerSlice = createSlice({
  name: "dateRangePicker",
  initialState,
  reducers: {
    setVonDatum(state, action: PayloadAction<string>) {
      state.vonDatum = action.payload;
    },
    setBisDatum(state, action: PayloadAction<string>) {
      state.bisDatum = action.payload;
    },
    resetDateRange(state) {
      state.vonDatum = null;
      state.bisDatum = null;
    },
  },
});

export const { setVonDatum, setBisDatum, resetDateRange } =
  dateRangePickerSlice.actions;
export default dateRangePickerSlice.reducer;
