From 2d80d1a8e69d34985ce9e4107aea7de6437ddaa5 Mon Sep 17 00:00:00 2001 From: ajithsimons Date: Tue, 2 Jan 2024 11:31:12 +0530 Subject: [PATCH] Contract end date removed --- src/components/ContractsTable.tsx | 42 +++---------------------------- 1 file changed, 4 insertions(+), 38 deletions(-) diff --git a/src/components/ContractsTable.tsx b/src/components/ContractsTable.tsx index 81c87780..1d12ab49 100644 --- a/src/components/ContractsTable.tsx +++ b/src/components/ContractsTable.tsx @@ -22,8 +22,7 @@ import CancelIcon from '@mui/icons-material/Cancel'; import { Box, Grid, LinearProgress } from '@mui/material'; import { DataGrid, GridColDef, GridRenderCellParams, GridToolbar, GridValidRowModel } from '@mui/x-data-grid'; import { IconButton, LoadingButton, Tooltips, Typography } from 'cx-portal-shared-components'; -import { capitalize, find } from 'lodash'; -import moment from 'moment'; +import { capitalize } from 'lodash'; import { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; @@ -31,9 +30,8 @@ import { setPageLoading } from '../features/app/slice'; import { useDeleteContractMutation, useGetContractsQuery } from '../features/provider/contracts/apiSlice'; import { useAppDispatch } from '../features/store'; import { handleBlankCellValues, MAX_CONTRACTS_AGREEMENTS } from '../helpers/ConsumerOfferHelper'; -import { IDefaultObject } from '../models/Common'; -import { CONTRACT_STATES, DURATION_UNIT_MAPPING, STATUS_COLOR_MAPPING, USER_TYPE_SWITCH } from '../utils/constants'; -import { convertEpochToDate, epochToDate } from '../utils/utils'; +import { CONTRACT_STATES, STATUS_COLOR_MAPPING, USER_TYPE_SWITCH } from '../utils/constants'; +import { convertEpochToDate } from '../utils/utils'; import NoDataPlaceholder from './NoDataPlaceholder'; interface IContractsTable { @@ -63,16 +61,6 @@ function ContractsTable({ type, title, subtitle }: IContractsTable) { const [deleteContract, { isLoading: isDeleting }] = useDeleteContractMutation({}); - function calculateEndDate(policies: IDefaultObject[], signingDate: number) { - if (policies?.length) { - const { durationUnit, value } = find(policies, e => e.type === 'DURATION'); - const startDate = epochToDate(signingDate); - if (durationUnit) { - return moment(startDate).add(value, Object(DURATION_UNIT_MAPPING)[durationUnit]).format('DD/MM/YYYY HH:mm:ss'); - } else return '-'; - } else return '-'; - } - useEffect(() => { dispatch(setPageLoading(isLoading)); }, [dispatch, isLoading, isDeleting]); @@ -125,31 +113,9 @@ function ContractsTable({ type, title, subtitle }: IContractsTable) { '-' ), }, - { - field: 'contractEndDate', - flex: 1, - headerName: t('content.contractHistory.columns.contractEndDate'), - sortingOrder: ['asc', 'desc'], - sortComparator: (v1, v2, param1: GridValidRowModel, param2: GridValidRowModel) => param2.id - param1.id, - valueGetter: ({ row }) => row.contractAgreementInfo, - valueFormatter: ({ value }) => calculateEndDate(value?.policies, value?.contractSigningDate), - renderCell: ({ row }) => ( - - - {calculateEndDate(row.contractAgreementInfo?.policies, row.contractAgreementInfo?.contractSigningDate)} - - - ), - }, { field: 'state', - flex: 1, + maxWidth: 200, headerName: t('content.contractHistory.columns.state'), renderCell: renderContractAgreementStatus, },