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

const env = ref<string>(process.env.NODE_ENV || "development");
// if (process.env.VUE_APP_TEST) {
//   env = "test";
// }

const config = ref<any>({
  development: {
    // API_URI: "https://localhost:7260/api",
    API_URI: "https://bma-ehr.frappet.synology.me/api/v1",
    // API_URI_ORG_SERVICE: "https://localhost:7056/api/v1", //ใช้ชั่วคราว
    API_URI_ORG_SERVICE: "https://bma-ehr.frappet.synology.me/api/v1", //ใช้ชั่วคราว
    // API_URI_ORG_EMPLOYEE_SERVICE: "https://localhost:7208/api/v1", //ใช้ชั่วคราว
    API_URI_ORG_EMPLOYEE_SERVICE: "https://bma-ehr.frappet.synology.me/api/v1", //ใช้ชั่วคราว
    // API_URI_PROFILE_SERVICE: "https://localhost:7159/api/v1",
    API_URI_PROFILE_SERVICE: "https://bma-ehr.frappet.synology.me/api/v1", //ใช้ชั่วคราว
    // API_CANDIDATE_URI: "https://localhost:7007/api/v1",
    API_CANDIDATE_URI: "https://bma-ehr.frappet.synology.me/api/v1",
    // API_REPORT_URI: "https://localhost:7187/api/v1",
    API_REPORT_URI: "https://bma-ehr.frappet.synology.me/api/v1",
    // API_PLACEMENT_URI: "https://localhost:7260/api",
    API_PLACEMENT_URI: "https://bma-ehr.frappet.synology.me/api/v1",
    API_URI_ORG_TREE:
      "https://s3cluster.frappet.com/bma-ehr-fpt/organization/strueture/tree_20230712_172702.json",
    MEET_URI: "meet.frappet.com",
    API_RETIREMENT_URI: "https://bma-ehr.frappet.synology.me/api/v1",
    // API_PROBATION_URI: "https://ehr.joolsoft.com/v1",
    API_PROBATION_URI: "https://bma-ehr.frappet.synology.me/api/v1/probation",
    // API_PROBATION_URI: "http://192.168.1.151:7776/v1",
    API_REPORT2_URI: "https://bma-ehr.frappet.synology.me/api/v2",
  },
  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: `${window.location.protocol}//${window.location.host}/api/v1`,
    API_URI_ORG_SERVICE: `${window.location.protocol}//${window.location.host}/api/v1`, //ใช้ชั่วคราว
    API_URI_ORG_EMPLOYEE_SERVICE: `${window.location.protocol}//${window.location.host}/api/v1`, //ใช้ชั่วคราว
    API_URI_PROFILE_SERVICE: `${window.location.protocol}//${window.location.host}/api/v1`,
    API_CANDIDATE_URI: `${window.location.protocol}//${window.location.host}/api/v1`,
    API_REPORT_URI: `${window.location.protocol}//${window.location.host}/api/v1`,
    API_PLACEMENT_URI: `${window.location.protocol}//${window.location.host}/api/v1`,
    API_URI_ORG_TREE:
      "https://s3cluster.frappet.com/bma-ehr-fpt/organization/strueture/tree_20230707_115124.json",
    MEET_URI: "meet.frappet.com",
    API_RETIREMENT_URI: `${window.location.protocol}//${window.location.host}/api/v1`,
    API_PROBATION_URI: `${window.location.protocol}//${window.location.host}/api/v1/probation`,
    API_REPORT2_URI: `${window.location.protocol}//${window.location.host}/api/v2`,
  },
});

const API_URI = ref<string>(config.value[env.value].API_URI);
const API_CANDIDATE_URI = ref<string>(
  config.value[env.value].API_CANDIDATE_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_PLACEMENT_URI = ref<string>(
  config.value[env.value].API_PLACEMENT_URI
);
const API_RETIREMENT_URI = ref<string>(
  config.value[env.value].API_RETIREMENT_URI
);
const API_URI_ORG_TREE = ref<string>(config.value[env.value].API_URI_ORG_TREE);
const API_PROBATION_URI = ref<string>(
  config.value[env.value].API_PROBATION_URI
);
const API_REPORT2_URI = ref<string>(config.value[env.value].API_REPORT2_URI);

export default {
  env: env.value,
  config: config.value,
  API_URI: API_URI.value,
  API_CANDIDATE_URI: API_CANDIDATE_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,
  API_PLACEMENT_URI: API_PLACEMENT_URI.value,
  API_URI_ORG_TREE: API_URI_ORG_TREE.value,
  MEET_URI: MEET_URI.value,
  API_RETIREMENT_URI: API_RETIREMENT_URI.value,
  API_PROBATION_URI: API_PROBATION_URI.value,
  API_REPORT2_URI: API_REPORT2_URI.value,
};
