diff --git a/src/assets/locales/de/main.json b/src/assets/locales/de/main.json index f27b85ef7..df17ef8da 100644 --- a/src/assets/locales/de/main.json +++ b/src/assets/locales/de/main.json @@ -1675,6 +1675,20 @@ "status": "Status: " }, "noData": "Derzeit bestehen keine Zertifikate für das Unternehmen. Sie können mit dem Hochladen eines Zertifikats beginnen, indem Sie oben auf die Schaltfläche „Zertifikat hochladen“ klicken." + }, + "deleteCompany": { + "title": "Delete Company Account", + "description": "You have initiated the deletion of the company account {{companyName}} incl. your personal user account {name}. Please note that the deletion can not get reversed.", + "heading1": "Company Account {name} is getting deleted", + "heading2": "All linked user accounts are getting deleted:", + "deleteBtn": "Delete my company", + "successTitle": "Company Account Deletion was successful.", + "successDescription": "The deletion was successful. You can now close this page. An email confirmation was send.", + "errorTitle": "Company Account Deletion was unsuccessful.", + "errorDescription": "The deletion was unsuccessful. Try it again or contact the platform administrator.", + "retryBtn": "Retry Deletion", + "notSupportedTitle": "Company account deletion is not supported. You registration is already submitted/closed. To unsubscribe you need to use the platform off-boarding process.", + "notSupportedDescription": "You can close the screen now or redirect to the portal >> get to the platform" } }, "navigation": { diff --git a/src/assets/locales/en/main.json b/src/assets/locales/en/main.json index d7943d925..f0d9d62b2 100644 --- a/src/assets/locales/en/main.json +++ b/src/assets/locales/en/main.json @@ -1639,6 +1639,20 @@ "approvedMessage": "Credential Request Accepted successfully.", "declinedMessage": "Credential Request Declined successfully.", "errorMessage": "Something went wrong!" + }, + "deleteCompany": { + "title": "Delete Company Account", + "description": "You have initiated the deletion of the company account {{companyName}} incl. your personal user account {{name}}. Please note that the deletion can not get reversed.", + "heading1": "Company Account {{name}} is getting deleted", + "heading2": "All linked user accounts are getting deleted:", + "deleteBtn": "Delete my company", + "successTitle": "Company Account Deletion was successful.", + "successDescription": "The deletion was successful. You can now close this page. An email confirmation was send.", + "errorTitle": "Company Account Deletion was unsuccessful.", + "errorDescription": "The deletion was unsuccessful. Try it again or contact the platform administrator.", + "retryBtn": "Retry Deletion", + "notSupportedTitle": "Company account deletion is not supported. You registration is already submitted/closed. To unsubscribe you need to use the platform off-boarding process.", + "notSupportedDescription": "You can close the screen now or redirect to the portal >> get to the platform" } }, "navigation": { diff --git a/src/components/AuthorizingRouter.tsx b/src/components/AuthorizingRouter.tsx index efd0b978c..896fc2dce 100644 --- a/src/components/AuthorizingRouter.tsx +++ b/src/components/AuthorizingRouter.tsx @@ -24,6 +24,7 @@ import NotFound from 'components/pages/NotFound' import AccessService from 'services/AccessService' import ScrollToTop from '../utils/ScrollToTop' import ErrorBoundary from 'components/pages/ErrorBoundary' +import DeleteCompany from './pages/DeleteCompany' const AuthorizingRouter = () => { return ( @@ -35,6 +36,7 @@ const AuthorizingRouter = () => { {AccessService.permittedRoutes()} } /> + } /> ) diff --git a/src/components/pages/DeleteCompany/DeleteCompany.scss b/src/components/pages/DeleteCompany/DeleteCompany.scss new file mode 100644 index 000000000..6860eec1c --- /dev/null +++ b/src/components/pages/DeleteCompany/DeleteCompany.scss @@ -0,0 +1,87 @@ +/******************************************************************************** + * Copyright (c) 2021, 2024 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 + ********************************************************************************/ + +.loading { + display: flex; + align-items: center; + justify-content: center; + min-height: 100vh; +} +.deleteMain { + min-height: 100vh; + background-repeat: no-repeat; + background-size: cover; + padding: 70px 0 50px 0; + + .d-flex { + display: flex; + } + + .align-item-center { + align-items: center; + } + + .text-center { + text-align: center; + } + + .mr-10 { + margin-right: 10px !important; + } + + .mb-15 { + margin-bottom: 15px !important; + } + + .mb-20 { + margin-bottom: 20px !important; + } + + .mb-25 { + margin-bottom: 25px !important; + } + + .logo { + margin-bottom: 70px; + + img { + height: 50px; + } + } + + .content { + max-width: 650px; + margin: 0 auto; + + .contentListing { + max-width: 80%; + margin: 0 auto; + + .icon { + color: #0f71cb; + font-size: 20px; + padding-top: 2px; + } + } + } + + .deleteBtn { + text-transform: capitalize; + } +} diff --git a/src/components/pages/DeleteCompany/index.tsx b/src/components/pages/DeleteCompany/index.tsx new file mode 100644 index 000000000..bb15dc876 --- /dev/null +++ b/src/components/pages/DeleteCompany/index.tsx @@ -0,0 +1,211 @@ +/******************************************************************************** + * Copyright (c) 2021, 2024 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 { useEffect, useState } from 'react' +import { Trans, useTranslation } from 'react-i18next' +import { CircularProgress, Typography } from '@mui/material' +import { uniqueId } from 'lodash' +import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline' +import { getAssetBase } from 'services/EnvironmentService' +import { Button, LoadingButton } from '@catena-x/portal-shared-components' +import { + ApplicationStatus, + useDeclineRegistrationMutation, + useFetchDeclineDataQuery, +} from 'features/deleteCompany/deleteCompanyApiSlice' +import './DeleteCompany.scss' + +export default function DeleteCompany() { + const { t } = useTranslation() + + const [initialPage, setInitialPage] = useState(false) + const [isSuccess, setIsSuccess] = useState(false) + const [isError, setIsError] = useState(false) + const [notSupported, setNotSupported] = useState(false) + const [isLoadingBtn, setIsLoadingBtn] = useState(false) + + const { data, isLoading } = useFetchDeclineDataQuery() + const companyData = data?.[0] + const [declineRegistration] = useDeclineRegistrationMutation() + + useEffect(() => { + if ( + companyData && + Object.values(ApplicationStatus).includes(companyData?.applicationStatus) + ) { + setInitialPage(true) + setNotSupported(false) + } else { + setNotSupported(true) + } + }, [companyData]) + + const handleDeleteCompany = async () => { + if (companyData) { + setIsLoadingBtn(true) + try { + await declineRegistration(companyData.applicationId).unwrap() + setInitialPage(false) + setIsSuccess(true) + setIsLoadingBtn(false) + } catch (err) { + setInitialPage(false) + setIsError(true) + setIsLoadingBtn(false) + } + } + } + + const handleRetryDelete = () => { + setIsError(false) + setInitialPage(true) + } + + return ( + <> + {isLoading ? ( +
+ +
+ ) : ( +
+
+
+ logo +
+ {initialPage && ( +
+ + {t('content.deleteCompany.title')} + + + + {t('content.deleteCompany.description')} + + +
+
+ + + + {t('content.deleteCompany.heading1')} + + +
+
+ + + {t('content.deleteCompany.heading2')} + +
+ +
    + {companyData?.users.map((user) => ( +
  • {user}
  • + ))} +
+ {isLoadingBtn ? ( + { + // do nothing + }} + /> + ) : ( + + )} +
+
+ )} + {isSuccess && ( +
+ + {t('content.deleteCompany.successTitle')} + + + {t('content.deleteCompany.successDescription')} + +
+ )} + {isError && ( +
+ + {t('content.deleteCompany.errorTitle')} + + + {t('content.deleteCompany.errorDescription')} + + +
+ )} + {notSupported && ( +
+ + {t('content.deleteCompany.notSupportedTitle')} + + + {t('content.deleteCompany.notSupportedDescription')} + +
+ )} +
+
+ )} + + ) +} diff --git a/src/features/apps/marketplaceDeprecated/slice.ts b/src/features/apps/marketplaceDeprecated/slice.ts index a531d2942..b70c6f673 100644 --- a/src/features/apps/marketplaceDeprecated/slice.ts +++ b/src/features/apps/marketplaceDeprecated/slice.ts @@ -112,7 +112,7 @@ export const latestSelector = (state: RootState): CardItems[] => export const subscribedStatusSelector = (state: RootState) => state.apps.marketplace.subscribedApps -export const subscribedAppsSelector = (state: RootState) => +export const subscribedAppsSelector = (state: RootState) => { state.apps.marketplace.items .filter((item: AppMarketplaceApp) => { return state.apps.marketplace.subscribedApps.find( @@ -127,6 +127,7 @@ export const subscribedAppsSelector = (state: RootState) => console.log('result', appToCard(result)) return appToCard(result) }) +} const Slice = { slice } diff --git a/src/features/deleteCompany/deleteCompanyApiSlice.ts b/src/features/deleteCompany/deleteCompanyApiSlice.ts new file mode 100644 index 000000000..a6242766e --- /dev/null +++ b/src/features/deleteCompany/deleteCompanyApiSlice.ts @@ -0,0 +1,57 @@ +/******************************************************************************** + * Copyright (c) 2021, 2024 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 { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react' +import { apiBaseQuery } from 'utils/rtkUtil' + +export enum ApplicationStatus { + CREATED = 'CREATED', + ADD_COMPANY_DATA = 'ADD_COMPANY_DATA', + INVITE_USER = 'INVITE_USER', + SELECT_COMPANY_ROLE = 'SELECT_COMPANY_ROLE', + UPLOAD_DOCUMENTS = 'UPLOAD_DOCUMENTS', + VERIFY = 'VERIFY', +} + +export type CompanyDataResponse = { + applicationId: string + applicationStatus: ApplicationStatus + companyName: string + user: string + users: string[] +} + +export const apiSlice = createApi({ + reducerPath: 'rtk/deleteCompany', + baseQuery: fetchBaseQuery(apiBaseQuery()), + endpoints: (builder) => ({ + fetchDeclineData: builder.query({ + query: () => '/api/registration/applications/declinedata', + }), + declineRegistration: builder.mutation({ + query: (applicationId) => ({ + url: `/api/registration/application/${applicationId}/declineRegistration`, + method: 'POST', + }), + }), + }), +}) + +export const { useFetchDeclineDataQuery, useDeclineRegistrationMutation } = + apiSlice diff --git a/src/features/store.ts b/src/features/store.ts index 8507e92f3..d8edc738a 100644 --- a/src/features/store.ts +++ b/src/features/store.ts @@ -64,8 +64,8 @@ import { apiSlice as serviceAdminBoardApiSlice } from './adminBoard/serviceAdmin import { apiSlice as companyRoleApiSlice } from './companyRoles/companyRoleApiSlice' import { apiSlice as certificationApiSlice } from './certification/certificationApiSlice' import { apiSlice as userManagementApiSlice } from './appManagement/userManagementApiSlice' +import { apiSlice as deleteCompanyApiSlice } from './deleteCompany/deleteCompanyApiSlice' import { apiSlice as registrationApiSlice } from './registration/registrationApiSlice' - import languageSlice from './language/slice' import { apiSlice as usecaseApiSlice } from './usecase/usecaseApiSlice' @@ -118,6 +118,7 @@ export const reducers = { [certificationApiSlice.reducerPath]: certificationApiSlice.reducer, [userManagementApiSlice.reducerPath]: userManagementApiSlice.reducer, [usecaseApiSlice.reducerPath]: usecaseApiSlice.reducer, + [deleteCompanyApiSlice.reducerPath]: deleteCompanyApiSlice.reducer, [registrationApiSlice.reducerPath]: registrationApiSlice.reducer, } @@ -150,6 +151,7 @@ export const store = configureStore({ .concat(certificationApiSlice.middleware) .concat(userManagementApiSlice.middleware) .concat(usecaseApiSlice.middleware) + .concat(deleteCompanyApiSlice.middleware) .concat(registrationApiSlice.middleware), }) diff --git a/src/types/Constants.ts b/src/types/Constants.ts index ac87bab39..4e33eb082 100644 --- a/src/types/Constants.ts +++ b/src/types/Constants.ts @@ -101,6 +101,7 @@ export enum PAGES { DATA_SPACE = 'dataspace', ADMIN_CREDENTIAL = 'admin-credential', ONBOARDING_SERVICEPROVIDER = 'onboarding-serviceprovider', + DECLINE = 'decline', } export enum OVERLAYS {