%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/emergentqj/actioncivile/pre-auth/.4cc3a2e1590a4463a5f392ddcc26929e/static/js/common/actions/
Upload File :
Create Path :
Current File : /home/emergentqj/actioncivile/pre-auth/.4cc3a2e1590a4463a5f392ddcc26929e/static/js/common/actions/index.js

import axios from "axios";
// import * as Sentry from "@sentry/browser";

const transactionId = Math.random()
  .toString(36)
  .substr(2, 9);

// Sentry.configureScope((scope) => {
//   scope.setTag("transaction_id", transactionId);
// });

function dataAction(
  method,
  url,
  params = null,
  auth = false,
  headers = {},
  responseType = null,
  options = null,
) {
  return () => {
    const requestHeaders = headers;

    const config = {
      url,
      method,
      timeout: 20000,
      params: method === "get" || method === "delete" ? params : null,
      data:
        method === "put"
        || method === "post"
        || method === "path"
        || method === "delete"
          ? params
          : null,
      headers: {
        ...requestHeaders,
      },
      validateStatus: (status) => status < 300,
      ...options,
    };

    if (!config.url.includes("faq")) {
      config.headers = { "X-Transaction-ID": transactionId, ...config.headers };
    }

    if (responseType) {
      config.responseType = responseType;
    }

    if (auth) {
      config.withCredentials = true;
    }

    return axios
      .request(config)
      .then((response) => response)
      .catch((error) => {
        throw error;
      });
  };
}

export function getDataAction(
  url,
  params = null,
  auth = false,
  headers = {},
  responseType = null,
) {
  return dataAction("get", url, params, auth, headers, responseType);
}

export function postDataAction(url, params = null, auth = false, headers = {}) {
  return dataAction("post", url, params, auth, headers);
}

// All occurences of postDataAction should be replaced by this one
export function postDataAction2({
  url,
  params,
  auth,
  headers,
  options,
}) {
  return dataAction("post", url, params, auth, headers, null, options);
}

export function putDataAction(url, params = null, auth = false, headers = {}) {
  return dataAction("put", url, params, auth, headers);
}

export function deleteDataAction(
  url,
  params = null,
  auth = false,
  headers = {},
) {
  return dataAction("delete", url, params, auth, headers);
}

Zerion Mini Shell 1.0