import { defineStore } from "pinia";

export const detailsStore = defineStore("details", {
  state: () => ({
    type: "",
  }),
  actions: {
    setType(type) {
      this.type = type;
    },
  },
});

export const articleStore = defineStore("article", {
  state: () => ({
    detail: {
      a_id: "",
      title: "",
      content: "",
      created: "",
      updated: "",
    },
  }),
  actions: {
    setArticle(data) {
      this.detail.a_id = data.a_id;
      this.detail.title = data.title;
      this.detail.content = data.content;
      this.detail.created = data.created;
      this.detail.updated = data.updated;
    },
  },
});

export const newsStore = defineStore("news", {
  state: () => ({
    detail: {
      a_id: "",
      title: "",
      content: "",
      published: "",
    },
  }),
  actions: {
    setNews(data) {
      this.detail.a_id = data.a_id;
      this.detail.title = data.n_title;
      this.detail.content = data.synopsis;
      this.detail.published = data.published;
    },
  },
});

export const projectStore = defineStore("project", {
  state: () => ({
    detail: {
      p_id: "",
      p_name: "",
      techstack: "",
      content: "",
      p_status: "",
    },
  }),
  actions: {
    setProject(data) {
      this.detail.p_id = data.p_id;
      this.detail.p_name = data.p_name;
      this.detail.techstack = data.techstack;
      this.detail.content = data.details;
      this.detail.p_status = data.p_status;
    },
  },
});

export const viewDetailsStore = defineStore("viewDetails", {
  state: () => ({
    detail: {
      id: "",
      title: "",
      content: "",
      cover: "",
      published: "",
      related: "",
    },
  }),
  actions: {
    setViewDetails(data) {
      this.detail.id = data.id;
      this.detail.title = data.title;
      this.detail.content = data.content;
      this.detail.cover = data.cover;
      this.detail.published = data.published;
      this.detail.related = data.related;
    },
  },
});
