import { defineStore } from "pinia";
import { ReviewTaskListItem } from "@/ap/types/review";

interface ReviewState {
  tabKey: "review" | "history";
  curTask: ReviewTaskListItem | null;
  waitTask: ReviewTaskListItem | null;
}

export const useReviewStore = defineStore("review", {
  state: (): ReviewState => ({
    tabKey: "review",
    curTask: null,
    waitTask: null,
  }),

  getters: {
    reviewInfo(state: ReviewState): ReviewState {
      return { ...state };
    },
  },

  actions: {
    setInfo(partial: Partial<ReviewState>) {
      this.$patch(partial);
    },
    resetInfo() {
      this.$reset();
    },
  },
  persist: {
    storage: sessionStorage,
  },
});
