how to make dynamic table react typescript

I am working with typescript I want to make section name dynamic when new post then title change to “ARTIKEL BARU” or “BERITA BARU” and when choose old post title become only “ARTIKEL” or “BERITA”.I not make this code from start I only handed this code. I try delete word “TERBARU” on if else but nothing change how to make change to section title.

heres the code

table code

import { useNavigate } from 'react-router';

import { Space, Card, Table, Button, Typography } from 'antd';

import { HomepageProps } from '@customTypes/dashboard';

import { ADD_CAROUSEL, EDIT_CAROUSEL } from '@constants/urls';

const { Title } = Typography;

const CarouselCard = ({ data }: { data: HomepageProps[] }) => {
  const navigate = useNavigate();

  const columns = [
    {
      title: 'Section',
      key: 'otherData',
      dataIndex: 'otherData',
      render: (text: { section: string }) => text?.section,
    },
    {
      title: 'Judul Konten',
      key: 'title',
      dataIndex: 'title',
    },
    {
      title: 'Deskripsi Konten',
      key: 'content',
      dataIndex: 'content',
    },
    {
      title: 'Aksi',
      key: 'action',
      render: (_: string, record: any) => (
        <Space align="end">
          <Button
            type="link"
            className="button-link-grey"
            onClick={() => navigate(EDIT_CAROUSEL + '/' + record.id)}
          >
            Ubah
          </Button>
        </Space>
      ),
    },
  ];
  return (
    <Space direction="vertical" size="middle" style={{ display: 'flex' }}>
      <Card
        title={
          <Space align="end">
            <Title level={4} style={{ marginBottom: 0 }}>
              Carousel
            </Title>
            {data.length < 3 && (
              <Button onClick={() => navigate(ADD_CAROUSEL)}>
                Tambah Baru
              </Button>
            )}
          </Space>
        }
      >
        <Table columns={columns} dataSource={data} pagination={false} />
      </Card>
    </Space>
  );
};

export default CarouselCard;

edit code

import { useState, useEffect } from 'react';
import { useLocation, useNavigate } from 'react-router';

import {
  Card,
  Row,
  Col,
  Space,
  Button,
  message,
  Input,
  Typography,
  Select,
} from 'antd';

import CustomTitle from '@components/Title';

import { DASHBOARD } from '@constants/urls';

import fetchRequest from '@utils/fetcher';

const { TextArea } = Input;
const { Title } = Typography;
const { Option } = Select;

type TitleProps = {
  id: string;
  title: string;
  type: 'news' | 'article' | 'publication';
};

const EditCarousel = () => {
  const [id, setId] = useState('');
  const [title, setTitle] = useState('');
  const [content, setContent] = useState('');
  const [articleList, setArticleList] = useState<TitleProps[]>([]);
  const [newsList, setNewsList] = useState<TitleProps[]>([]);
  const [publicationList, setPublicationList] = useState<TitleProps[]>([]);
  const [section, setSection] = useState('');
  


  const navigate = useNavigate();
  const location = useLocation();

  const handleSubmit = async () => {
    const titleId = [...articleList, ...newsList, ...publicationList].filter(
      (al) => al.id === title
    )[0];

    let sec = section;

    if (section === '') {
      if (titleId.type === 'news') {
        sec = 'BERITA TERBARU';
      } else if (titleId.type === 'article') {
        sec = 'ARTIKEL TERBARU';
      } else if (titleId.type === 'publication') {
        sec = 'PUBLIKASI TERBARU';
      }
    }

    const param = {
      title: titleId.title,
      content,
      section: sec,
      originId: title,
    };

    try {
      await fetchRequest({
        method: 'POST',
        path: 'resource/homepage/carousel',
        data: id !== '' ? { ...param, id } : param,
      }).then((response) => {
        if (!response.error) {
          navigate(DASHBOARD);
        } else {
          message.error(response.error.message);
        }
      });
    } catch (error) {
      message.error(error.message);
    }
  };

  const getContent = async (id: string) => {
    try {
      await fetchRequest({
        method: 'GET',
        path: 'resource?id=' + id,
      }).then((response) => {
        if (!response.error) {
          setTitle(response.title || '');
          setContent(response.content || '');
          setSection(response?.otherData?.section || '');
        } else {
          message.error(response.error.message);
        }
      });
    } catch (error) {
      message.error(error.message);
    }
  };

  const getTitleList = async (type: string) => {
    try {
      await fetchRequest({
        method: 'GET',
        path: 'info/no-content?types=' + type,
      }).then((response) => {
        if (!response.error) {
          if (type === 'news') {
            setNewsList(response || []);
          } else if (type === 'article') {
            setArticleList(response || []);
          } else if (type === 'publication') {
            setPublicationList(response || []);
          }
        } else {
          message.error(response.error.message);
        }
      });
    } catch (error) {
      message.error(error.message);
    }
  };

  const getDataList = async () => {
    let type = '';

    if (section === 'ARTIKEL TERBARU') {
      type = 'article';
    } else if (section === 'PUBLIKASI TERBARU') {
      type = 'publication';
    } else if (section === 'BERITA TERBARU') {
      type = 'news';
    }

    if (type === '') {
      getTitleList('news');
      getTitleList('publication');
      getTitleList('article');
    } else {
      getTitleList(type);
    }
  };

  useEffect(() => {
    const isEdit =
      location.pathname.split('/').filter((pn) => pn === 'edit').length > 0;

    if (isEdit) {
      const path = location.pathname.split('/');
      const testimonyId = path[path.indexOf('edit') + 1];

      setId(testimonyId);

      getContent(testimonyId);
    }

    getDataList();
  }, []);
  return (
    <Row>
      <Col span={12} offset={6}>
        <Card>
          <Space direction="vertical" style={{ width: '100%' }}>
            <CustomTitle name={section || 'Carousel'} url={DASHBOARD} />
            <Title level={5}>Pilih judul yang akan ditampilkan</Title>
            <Select
              value={title}
              placeholder="Judul"
              onChange={(value: any) => setTitle(value)}
              style={{ width: '100%' }}
            >
              {[...articleList, ...newsList, ...publicationList].map((al) => (
                <Option key={al.id} value={al.id}>
                  {al.title}
                </Option>

              ))}
            </Select>
            <Title level={5}>Deskripsi Singkat</Title>
            <TextArea
              value={content}
              onChange={(e: any) => setContent(e.target.value)}
              rows={4}
            />
            <Row justify="end">
              <Col>
                <Button type="primary" danger onClick={() => handleSubmit()}>
                  Simpan Perubahan
                </Button>
              </Col>
            </Row>
          </Space>
        </Card>
      </Col>
    </Row>
  );
};

export default EditCarousel;

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật