Skip to content

Commit

Permalink
feat(decline-registration): decline registration confirmation logic (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nidhigarg-bmw authored Jan 25, 2024
1 parent 7e45302 commit b9c8f79
Show file tree
Hide file tree
Showing 9 changed files with 391 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/assets/locales/de/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
14 changes: 14 additions & 0 deletions src/assets/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 2 additions & 0 deletions src/components/AuthorizingRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -35,6 +36,7 @@ const AuthorizingRouter = () => {
{AccessService.permittedRoutes()}
</Route>
<Route path="*" element={<NotFound />} />
<Route path="/decline" element={<DeleteCompany />} />
</Routes>
</BrowserRouter>
)
Expand Down
87 changes: 87 additions & 0 deletions src/components/pages/DeleteCompany/DeleteCompany.scss
Original file line number Diff line number Diff line change
@@ -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;
}
}
211 changes: 211 additions & 0 deletions src/components/pages/DeleteCompany/index.tsx
Original file line number Diff line number Diff line change
@@ -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 ? (
<div className="loading">
<CircularProgress size={100} />
</div>
) : (
<div
className="deleteMain"
style={{
backgroundImage: `url(${getAssetBase()}/images/frame/home-stage-desktop.png)`,
}}
>
<div className="container">
<div className="logo text-center">
<img
src={`${getAssetBase()}/images/logos/cx-text.svg`}
alt="logo"
/>
</div>
{initialPage && (
<div className="content">
<Typography variant="h4" className="text-center mb-20">
{t('content.deleteCompany.title')}
</Typography>
<Trans
values={{
companyName: companyData?.companyName,
name: companyData?.user,
}}
>
<Typography variant="body1" className="text-center mb-25">
{t('content.deleteCompany.description')}
</Typography>
</Trans>
<div className="contentListing">
<div className="d-flex mb-15">
<CheckCircleOutlineIcon className="icon mr-10" />
<Trans
values={{
name: companyData?.user,
}}
>
<Typography variant="body3">
{t('content.deleteCompany.heading1')}
</Typography>
</Trans>
</div>
<div className="d-flex align-item-center mb-15">
<CheckCircleOutlineIcon className="icon mr-10" />
<Typography variant="body3">
{t('content.deleteCompany.heading2')}
</Typography>
</div>

<ul className="mb-25">
{companyData?.users.map((user) => (
<li key={uniqueId(user)}>{user}</li>
))}
</ul>
{isLoadingBtn ? (
<LoadingButton
color="primary"
helperText=""
helperTextColor="success"
label=""
loadIndicator="Loading ..."
loading
size="small"
onButtonClick={() => {
// do nothing
}}
/>
) : (
<Button
onClick={() => {
handleDeleteCompany()
}}
className="deleteBtn"
size="small"
>
{t('content.deleteCompany.deleteBtn')}
</Button>
)}
</div>
</div>
)}
{isSuccess && (
<div className="content text-center ">
<Typography variant="h4" className="mb-20">
{t('content.deleteCompany.successTitle')}
</Typography>
<Typography variant="body1">
{t('content.deleteCompany.successDescription')}
</Typography>
</div>
)}
{isError && (
<div className="content text-center">
<Typography variant="h4" className="mb-20">
{t('content.deleteCompany.errorTitle')}
</Typography>
<Typography variant="body1" className="mb-25">
{t('content.deleteCompany.errorDescription')}
</Typography>
<Button
onClick={() => {
handleRetryDelete()
}}
className="deleteBtn"
size="small"
>
{t('content.deleteCompany.retryBtn')}
</Button>
</div>
)}
{notSupported && (
<div className="content text-center">
<Typography variant="h4" className="mb-20">
{t('content.deleteCompany.notSupportedTitle')}
</Typography>
<Typography variant="body1">
{t('content.deleteCompany.notSupportedDescription')}
</Typography>
</div>
)}
</div>
</div>
)}
</>
)
}
3 changes: 2 additions & 1 deletion src/features/apps/marketplaceDeprecated/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -127,6 +127,7 @@ export const subscribedAppsSelector = (state: RootState) =>
console.log('result', appToCard(result))
return appToCard(result)
})
}

const Slice = { slice }

Expand Down
Loading

0 comments on commit b9c8f79

Please sign in to comment.