import { defineStore } from "pinia";
import { reactive } from "vue";

export const useReleasePostionStore = defineStore("releasePostion", {
    state: () => ({
        formData: {
            workMode: 1,
            jobName: "",
            jobType: 1,
            jobTypeText: "",
            jobDesc: "",
            negotiableSalary: 1,
            settlementType: 1,
            minSalary: 0,
            maxSalary: 0,
            benefits: "",
            identityRequirement: 1,
            educationRequirement: 1,
            minAgeRequirement: 1,
            maxAgeRequirement: 1,
            recruitmentNumber: 1,
            accommodation: 1,
            provinceCode: "",
            cityCode: "",
            districtCode: "",
            town: "",
            street: "",
            address: "",
            locationLongitude: 0,
            locationLatitude: 0,
            contactPerson: "",
            contactPhone: ""
        }
    }),
    actions: {
        setFormDataKey(key, data) {
            this.formData[key] = data;
        },
        resetForm() {
            this.formData = {
                workMode: 1,
                jobName: "",
                jobType: 1,
                jobTypeText: "",
                jobDesc: "",
                negotiableSalary: 1,
                settlementType: 1,
                minSalary: 0,
                maxSalary: 0,
                benefits: "",
                identityRequirement: 1,
                educationRequirement: 1,
                minAgeRequirement: 1,
                maxAgeRequirement: 1,
                recruitmentNumber: 1,
                accommodation: 1,
                provinceCode: "",
                cityCode: "",
                districtCode: "",
                town: "",
                street: "",
                address: "",
                locationLongitude: 0,
                locationLatitude: 0,
                contactPerson: "",
                contactPhone: ""
            };
        },
        setForm(data) {
            this.formData = reactive(data);
            console.log("this.formData", this.formData);
        }
    }
});
