From 1aefcf93c88e99a4792883a5effcd8724d0dddc4 Mon Sep 17 00:00:00 2001 From: ajithsimons Date: Tue, 2 Jan 2024 11:26:56 +0530 Subject: [PATCH 1/2] duration usage policy removed --- src/components/policies/PoliciesDialog.tsx | 14 ++------------ src/components/policies/UsagePolicy.tsx | 15 ++------------- src/components/policies/UsagePolicyItem.tsx | 21 +++------------------ 3 files changed, 7 insertions(+), 43 deletions(-) diff --git a/src/components/policies/PoliciesDialog.tsx b/src/components/policies/PoliciesDialog.tsx index 126c7119..721c36c7 100644 --- a/src/components/policies/PoliciesDialog.tsx +++ b/src/components/policies/PoliciesDialog.tsx @@ -60,9 +60,6 @@ export default function PoliciesDialog() { uploadUrl, uploadData, uploadType, - duration, - durationValue, - durationUnit, purpose, purposeValue, role, @@ -78,13 +75,12 @@ export default function PoliciesDialog() { const dispatch = useAppDispatch(); useEffect(() => { - const durationCheck = duration === 'RESTRICTED' && durationValue === ''; const purposeCheck = purpose === 'RESTRICTED' && isEmpty(purposeValue); const roleCheck = role === 'RESTRICTED' && roleValue === ''; const customCheck = custom === 'RESTRICTED' && customValue === ''; - setshowError(() => durationCheck || purposeCheck || roleCheck || customCheck); + setshowError(() => purposeCheck || roleCheck || customCheck); return () => {}; - }, [duration, durationValue, purpose, purposeValue, role, roleValue, custom, customValue]); + }, [purpose, purposeValue, role, roleValue, custom, customValue]); const clearUpload = () => { dispatch(setPageLoading(false)); @@ -167,12 +163,6 @@ export default function PoliciesDialog() { type_of_access: accessType, row_data: uploadData, usage_policies: [ - { - type: 'DURATION', - typeOfAccess: duration, - value: durationValue, - durationUnit: durationUnit.value, - }, { type: 'ROLE', typeOfAccess: role, diff --git a/src/components/policies/UsagePolicy.tsx b/src/components/policies/UsagePolicy.tsx index 8acbd576..c7f3d102 100644 --- a/src/components/policies/UsagePolicy.tsx +++ b/src/components/policies/UsagePolicy.tsx @@ -22,29 +22,18 @@ import { Box } from '@mui/material'; import { Typography } from 'cx-portal-shared-components'; import { useTranslation } from 'react-i18next'; -import { setDuration, setDurationValue, setPurpose } from '../../features/provider/policies/slice'; +import { setPurpose } from '../../features/provider/policies/slice'; import { useAppDispatch, useAppSelector } from '../../features/store'; import UsagePolicyItem from './UsagePolicyItem'; export default function UsagePolicy() { - const { duration, durationValue, purpose } = useAppSelector(state => state.accessUsagePolicySlice); + const { purpose } = useAppSelector(state => state.accessUsagePolicySlice); const dispatch = useAppDispatch(); const { t } = useTranslation(); return ( <> {t('content.policies.usagePolicy')} - - dispatch(setDuration(e))} - constraintType={t('content.policies.duration')} - displayText={t('content.policies.durationNote')} - labelText={t('content.common.enterValue')} - inputFreeText={durationValue} - setInputFreeText={e => dispatch(setDurationValue(e))} - /> - state.accessUsagePolicySlice); + const { purposeValue } = useAppSelector(state => state.accessUsagePolicySlice); const dispatch = useAppDispatch(); const { t } = useTranslation(); @@ -93,21 +93,6 @@ export default function UsagePolicyItem({ sx={{ minWidth: 250 }} /> )} - {constraintType === t('content.policies.duration') && ( - - { - dispatch(setDurationUnit(e)); - }} - /> - - )} {constraintType === t('content.policies.purpose') && ( Date: Tue, 2 Jan 2024 11:31:12 +0530 Subject: [PATCH 2/2] 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, },