import Vue from 'vue';
import Vuex from 'vuex';
import _ from 'lodash';
import axios from 'axios';
Vue.use(Vuex);
const api = {
  upload: (dir) => `/files/jlstcompany/${dir}/upload`,
};
const state = () => ({});
const mutations = {};

const actions = {
  async upload({ commit }, { file, dir }) {
    var formdata = new FormData();
    formdata.append('file', file, file.name);
    const res = await axios.post(api.upload(dir), formdata, { headers: { 'Content-Type': 'multipart/form-data' } });
    return res.data;
  },
};
export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
