From 5ed6207f99c10d42a78ad272d10a12a253736ac4 Mon Sep 17 00:00:00 2001 From: nidhi garg Date: Tue, 11 Jul 2023 18:06:41 +0530 Subject: [PATCH] feat(certificate): remove unused code --- .../CertificateElements.tsx | 144 ------------------ .../pages/CertificateCredentials/index.tsx | 5 +- .../index.tsx | 2 +- .../style.scss | 0 src/types/Config.tsx | 2 +- 5 files changed, 4 insertions(+), 149 deletions(-) delete mode 100644 src/components/pages/CertificateCredentials/CertificateElements.tsx rename src/components/shared/basic/{Certificatecard => CertificateCard}/index.tsx (99%) rename src/components/shared/basic/{Certificatecard => CertificateCard}/style.scss (100%) diff --git a/src/components/pages/CertificateCredentials/CertificateElements.tsx b/src/components/pages/CertificateCredentials/CertificateElements.tsx deleted file mode 100644 index 9f46df375..000000000 --- a/src/components/pages/CertificateCredentials/CertificateElements.tsx +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021, 2023 BMW Group AG - * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -import { CardDecision, PageSnackbar } from '@catena-x/portal-shared-components' -import { useDispatch, useSelector } from 'react-redux' -import { useTheme, CircularProgress } from '@mui/material' -import { show } from 'features/control/overlay' -import './AdminBoard.scss' -import { - AppContent, - useApproveRequestMutation, -} from 'features/adminBoard/adminBoardApiSlice' -import { OVERLAYS, PAGES } from 'types/Constants' -import { - currentErrorType, - currentSuccessType, - setErrorType, - setSuccessType, -} from 'features/adminBoard/slice' -import { SuccessErrorType } from 'features/admin/appuserApiSlice' -import NoItems from 'components/pages/NoItems' -import { - ServiceContent, - useApproveServiceRequestMutation, -} from 'features/adminBoard/serviceAdminBoardApiSlice' -import { useState } from 'react' - -export default function AdminBoardElements({ - apps, - onClick, - type, - successApproveMsg, - errorApproveMsg, - successDeclineMsg, - errorDeclineMsg, -}: { - apps?: AppContent[] | ServiceContent[] - onClick: (appId: string) => void - type?: string - successApproveMsg?: string - errorApproveMsg?: string - successDeclineMsg?: string - errorDeclineMsg?: string -}) { - const dispatch = useDispatch() - const theme = useTheme() - const [approveRequest] = useApproveRequestMutation() - const [approveServiceRequest] = useApproveServiceRequestMutation() - const isDecisionSuccess = useSelector(currentSuccessType) - const isDecisionError = useSelector(currentErrorType) - const [actionApprove, setActionApprove] = useState(false) - - if (apps && apps.length === 0) { - return - } - - const handleApprove = async (appId: string) => { - setActionApprove(true) - if (type === PAGES.SERVICEADMINBOARD_DETAIL) { - await approveServiceRequest(appId) - .unwrap() - .then(() => { - dispatch(setSuccessType(true)) - }) - .catch((error) => dispatch(setErrorType(true))) - } else { - await approveRequest(appId) - .unwrap() - .then(() => { - dispatch(setSuccessType(true)) - }) - .catch((error) => dispatch(setErrorType(true))) - } - } - - const onAlertClose = () => { - dispatch(setSuccessType(false)) - dispatch(setErrorType(false)) - } - - const getDescription = () => { - if (actionApprove) { - return isDecisionSuccess ? successApproveMsg : errorApproveMsg - } else { - return isDecisionSuccess ? successDeclineMsg : errorDeclineMsg - } - } - - return ( -
- - {apps && apps.length ? ( - { - setActionApprove(false) - if (type === PAGES.SERVICEADMINBOARD_DETAIL) { - dispatch(show(OVERLAYS.SERVICE_DECLINE_ADMINBOARD, appId)) - } else { - dispatch(show(OVERLAYS.APP_DECLINE_ADMINBOARD, appId)) - } - }} - onApprove={(appId: string) => handleApprove(appId)} - onClick={onClick} - /> - ) : ( -
- -
- )} -
- ) -} diff --git a/src/components/pages/CertificateCredentials/index.tsx b/src/components/pages/CertificateCredentials/index.tsx index 7db2c0827..bc8ee5847 100644 --- a/src/components/pages/CertificateCredentials/index.tsx +++ b/src/components/pages/CertificateCredentials/index.tsx @@ -36,7 +36,7 @@ import { CertificateResponse, useFetchCertificatesQuery, } from 'features/certification/certificationApiSlice' -import { Card3 } from 'components/shared/basic/Certificatecard' +import { CertificateCard } from 'components/shared/basic/CertificateCard' enum FilterType { UPLOADED = 'Uploaded', @@ -109,7 +109,6 @@ export default function CertificateCredentials() { const { t } = useTranslation() const { data } = useFetchCertificatesQuery() - console.log('data', data) const [{ searchExpr, showModal, selected, sortOption }, setState] = useReducer(reducer, initialState) @@ -245,7 +244,7 @@ export default function CertificateCredentials() { className="certificate-card" key={item.credentialType} > - diff --git a/src/components/shared/basic/Certificatecard/index.tsx b/src/components/shared/basic/CertificateCard/index.tsx similarity index 99% rename from src/components/shared/basic/Certificatecard/index.tsx rename to src/components/shared/basic/CertificateCard/index.tsx index 7068c7f22..a2f1cac30 100644 --- a/src/components/shared/basic/Certificatecard/index.tsx +++ b/src/components/shared/basic/CertificateCard/index.tsx @@ -47,7 +47,7 @@ export interface CertificateData { ssiDetailData: SSIDetailData } -export const Card3 = ({ +export const CertificateCard = ({ credentialType, ssiDetailData, }: CertificateResponse) => { diff --git a/src/components/shared/basic/Certificatecard/style.scss b/src/components/shared/basic/CertificateCard/style.scss similarity index 100% rename from src/components/shared/basic/Certificatecard/style.scss rename to src/components/shared/basic/CertificateCard/style.scss diff --git a/src/types/Config.tsx b/src/types/Config.tsx index 87cb527de..a08af0913 100644 --- a/src/types/Config.tsx +++ b/src/types/Config.tsx @@ -466,7 +466,7 @@ export const ALL_PAGES: IPage[] = [ }, { name: PAGES.CERTIFICATE_CREDENTIAL, - //role: ROLES.MANAGE_COMPANY_CREDENTIALS, + role: ROLES.MANAGE_COMPANY_CREDENTIALS, element: , }, ]