/**config api */
import { ref } from "vue";

const env = ref<string>(process.env.NODE_ENV || "development");
export const apiUrlConfig = import.meta.env.VITE_API_URI_CONFIG;
export const apiUrlConfigReport = import.meta.env.VITE_API_REPORT_URL;
// if (process.env.VUE_APP_TEST) {
//   env = "test";
// }

const config = ref<any>({
  development: {
    API_URI: apiUrlConfig,
    API_URI_ORG_SERVICE: apiUrlConfig, //ใช้ชั่วคราว
    API_URI_ORG_EMPLOYEE_SERVICE: apiUrlConfig, //ใช้ชั่วคราว
    API_URI_PROFILE_SERVICE: apiUrlConfig,
    API_REPORT_URI: apiUrlConfig,
    MEET_URI: "meet.frappet.com",
    API_REPORT_TEMPLATE_URI:
      "https://report-server.frappet.synology.me/api/v1/report-template",
    API_LOG: apiUrlConfig,
  },
  test: {
    API_URI: "http://localhost:5010/api/v1",
    API_CANDIDATE_URI: "https://localhost:7007/api/v1",
    API_REPORT_URI: "https://localhost:7007/api/v1",
    MEET_URI: "meet.frappet.com",
  },
  production: {
    // API_URI: "https://localhost:5010",
    API_URI: apiUrlConfig,
    API_URI_ORG_SERVICE: apiUrlConfig, //ใช้ชั่วคราว
    API_URI_ORG_EMPLOYEE_SERVICE: apiUrlConfig, //ใช้ชั่วคราว
    API_URI_PROFILE_SERVICE: apiUrlConfig,
    API_REPORT_URI: apiUrlConfig,
    MEET_URI: "meet.frappet.com",
    API_REPORT_TEMPLATE_URI: apiUrlConfigReport,
    API_LOG: apiUrlConfig,
  },
});

const API_URI = ref<string>(config.value[env.value].API_URI);
const API_REPORT_URI = ref<string>(config.value[env.value].API_REPORT_URI);
const API_URI_ORG_SERVICE = ref<string>(
  config.value[env.value].API_URI_ORG_SERVICE
);
const API_URI_ORG_EMPLOYEE_SERVICE = ref<string>(
  config.value[env.value].API_URI_ORG_EMPLOYEE_SERVICE
);
const MEET_URI = ref<string>(config.value[env.value].MEET_URI);
const API_URI_PROFILE_SERVICE = ref<string>(
  config.value[env.value].API_URI_PROFILE_SERVICE
);
const API_REPORT_TEMPLATE_URI = ref<string>(
  config.value[env.value].API_REPORT_TEMPLATE_URI
);
const API_LOG = ref<string>(config.value[env.value].API_LOG);

export default {
  env: env.value,
  config: config.value,
  API_URI: API_URI.value,
  API_REPORT_URI: API_REPORT_URI.value,
  API_URI_ORG_SERVICE: API_URI_ORG_SERVICE.value,
  API_URI_ORG_EMPLOYEE_SERVICE: API_URI_ORG_EMPLOYEE_SERVICE.value,
  API_URI_PROFILE_SERVICE: API_URI_PROFILE_SERVICE.value,
  MEET_URI: MEET_URI.value,
  API_REPORT_TEMPLATE_URI: API_REPORT_TEMPLATE_URI.value,
  API_LOG: API_LOG.value,
};
