import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { Moment } from "moment";
import * as moment from "moment";
import "moment/locale/ru";

interface IState {
  isCalendar: boolean;
  isTimepicker: boolean;
  isForm: boolean;
  isDone: boolean;
}

interface IForm {
  name: string,
  value: string | number
}

export interface planState {
  time: Moment;
  isCalendar: boolean;
  isTimepicker: boolean;
  isForm: boolean;
  isDone: boolean;
  email: string;
  name: string;
  currTime: Moment | null
}

const initialState: planState = {
  time: moment.default(),
  currTime: null,
  isCalendar: true,
  isTimepicker: false,
  isForm: false,
  isDone: false,
  email: "",
  name: "",
};

export const planSlice = createSlice({
  name: "plan",
  initialState,
  reducers: {
    handleNavigation(state, action: PayloadAction<IState>) {
      state.isCalendar = action.payload.isCalendar;
      state.isDone = action.payload.isDone;
      state.isTimepicker = action.payload.isTimepicker;
      state.isForm = action.payload.isForm;
    },

    handleTimeValue(state, action: PayloadAction<Moment>) {
      state.currTime = action.payload;
    },

  },
});

export default planSlice.reducer;
