import { defineStore } from 'pinia';
import { ref } from 'vue';
interface formType {
  personalPhoto: string;
  name: string;
  phone: string;
  wechatNumber: string;
  specializedSubject: string;
  gradSchool: string;
  personalInformation: string;
  index: number;
  qualification: any[];
}
export const userPersonalStore = defineStore({
  id: 'inspector',
  state: () => ({
    index: -1,
    form: <formType>{
      index: 0,
      personalPhoto: '',
      name: '',
      phone: '',
      wechatNumber: '',
      specializedSubject: '',
      gradSchool: '',
      personalInformation: '',
      qualification: [],
    },
  }),
  actions: {
    /** 头像 */
    SET_AVATAR(url: string) {
      this.form.personalPhoto = url;
    },
    SET_PHONE(phone: string) {
      this.form.phone = phone;
    },
    SET_NAME(name: string) {
      this.form.name = name;
    },
    SET_SUBJECT(specializedSubject: string) {
      this.form.specializedSubject = specializedSubject;
    },
    SET_GRADSCHOOL(gradSchool: string) {
      this.form.gradSchool = gradSchool;
    },
    SET_PERSONALINFORMATION(personalInformation: string) {
      this.form.personalInformation = personalInformation;
    },
    SET_FORM(form: any) {
      this.form = { ...form };
    },
    SET_QUALIFICATION(list: any[]) {
      this.form.qualification = list;
    },
    SET_INDEX(index: number) {
      this.index = index;
    },
  },
});

export function usepersonalStoreHook() {
  return userPersonalStore();
}
