Skip to content

Commit

Permalink
Contract end date removed
Browse files Browse the repository at this point in the history
  • Loading branch information
ajithsimons committed Jan 2, 2024
1 parent 1aefcf9 commit 2d80d1a
Showing 1 changed file with 4 additions and 38 deletions.
42 changes: 4 additions & 38 deletions src/components/ContractsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ 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';

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 {
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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 }) => (
<Tooltips
tooltipPlacement="top"
tooltipText={calculateEndDate(
row.contractAgreementInfo?.policies,
row.contractAgreementInfo?.contractSigningDate,
)}
>
<span>
{calculateEndDate(row.contractAgreementInfo?.policies, row.contractAgreementInfo?.contractSigningDate)}
</span>
</Tooltips>
),
},
{
field: 'state',
flex: 1,
maxWidth: 200,
headerName: t('content.contractHistory.columns.state'),
renderCell: renderContractAgreementStatus,
},
Expand Down

0 comments on commit 2d80d1a

Please sign in to comment.