File "tableColumns.tsx"

Full Path: /var/www/html/front_back/workspace/Gitep-front/src/shared/config/tableColumns.tsx
File size: 3.11 KB
MIME-type: text/x-java
Charset: utf-8

import React from "react";
import {
  ApplicantColumn,
  ArticleProjectColumn,
  CommonColumnsData,
  GroupRowData,
  MainRowData,
  TagsKeys,
} from "@shared/modals";
import {
  Applicant,
  ArticleProject,
  MessageTooltip,
  Name
} from "@shared/ui/ColumnsTable";
import { CustomStatus } from "@shared/ui/Tags/tags";
import { TableColumnsType, Flex, Typography } from "antd";
import styles from "@shared/ui/ColumnsTable/columns-table.module.scss";
import dayjs from "dayjs";

export const mainColumns: TableColumnsType<CommonColumnsData> = [
  {
    title: null,
    dataIndex: "expand",
    key: "expand",
    width: 0,
    render: () => null,
    className: 'expand-col'
  },
  {
    title: "Назначение / Контрагент",
    dataIndex: "name",
    render: (name: GroupRowData["name"] | MainRowData["name"], record: CommonColumnsData) => {
      const { counterparty } = record
      if (typeof name === "string") {
        return (
          <Flex vertical>
            <Typography.Text>{name}</Typography.Text>
            {"counterparty" in record && (
              <Typography.Text className={styles.subname}>
                {counterparty?.name}
              </Typography.Text>
            )}
          </Flex>
        );
      } else if (name && typeof name === "object") {
        return <Name data={name} counterparty={counterparty} />;
      }
      return null;
    },
    width: 320,
    fixed: "left",
  },
  {
    title: "Сумма, ₽",
    dataIndex: "amount",
    fixed: "left",
    width: 112,
    render: (text: string | undefined, record) => {
      if (text) {
        return (
          <Typography.Text
            style={{
              textAlign: "end",
              display: "block",
              fontSize: record.isGroup ? "16px" : "inherit",
            }}
          >
            {text}
          </Typography.Text>
        );
      }
      return null;
    },
  },
  {
    title: false,
    dataIndex: "message",
    render: (text: string | undefined) =>
      text ? <MessageTooltip text={text} /> : null,
    width: 56,
  },
  {
    title: "Статус",
    dataIndex: "status",
    render: (status: TagsKeys | undefined) =>
      status ? <CustomStatus prefixIcon status={status} /> : null,
    width: 156,
  },
  {
    title: "Статья / Проект",
    dataIndex: "articleProject",
    render: (text: ArticleProjectColumn | undefined) =>
      text ? <ArticleProject data={text} /> : null,
    width: 396,
  },
  /* {
    title: "Заявитель",
    dataIndex: "applicant",
    render: (text: ApplicantColumn | undefined) =>
      text ? <Applicant data={text} /> : null,
    width: 160,
  }, */
  {
    title: "Дата платежа",
    dataIndex: "date",
    width: 128,
    render: (text: string | undefined) =>
      text ? <Typography.Text>{dayjs(text).format("DD.MM.YY")}</Typography.Text> : null,
  },
  /* {
    title: "Назначение 1С",
    dataIndex: "purpose1C",
    width: 320,
  },
  {
    title: "Примечание 1С",
    dataIndex: "note1C",
    width: 320,
  },
  {
    title: "Счет списания 1С",
    dataIndex: "writeOffAccount1C",
    width: 320,
  }, */
];