Skip to content

Commit 7adbbe3

Browse files
authored
feat(App/Service Subscription): Ability to Decline the Subscription requests (#1629)
* feat: PM2-1858 Ability for App or Service Provider to Decline the Subscription request (#588) # Conflicts: # src/assets/locales/cfx/de/main.json # src/assets/locales/cfx/de/servicerelease.json # src/assets/locales/cfx/en/main.json # src/assets/locales/cfx/en/servicerelease.json # src/components/shared/templates/Subscription/index.tsx # src/components/shared/templates/Subscription/style.scss * fix(App/Service Subscription): trigger activate/decline APIs, the records are not updated (#594) # Conflicts: # src/assets/locales/cfx/de/main.json # src/assets/locales/cfx/de/servicerelease.json # src/assets/locales/cfx/en/main.json # src/assets/locales/cfx/en/servicerelease.json # src/components/pages/AppSubscription/index.tsx * fix: translations updated * fix: color updates * chore: translations * fix(App/Service Subscription): PM2-3070 service decline message is incorrect (#603) Cofinity-X/portal-frontend#603 # Conflicts: # src/assets/locales/cfx/de/main.json # src/assets/locales/cfx/en/main.json * fix(App/Service Subscription): PM2-3070 service decline message is incorrect (#609) Cofinity-X/portal-frontend#609 # Conflicts: # src/assets/locales/cfx/de/main.json # src/assets/locales/cfx/en/main.json * chore: translation fix * chore: translations fix * chore: type fix
1 parent e61d3eb commit 7adbbe3

File tree

16 files changed

+525
-40
lines changed

16 files changed

+525
-40
lines changed

src/assets/locales/de/main.json

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,10 @@
14931493
"clientSercret": "Client Secret"
14941494
}
14951495
},
1496+
"appServiceSubscription": {
1497+
"appsOffered": "Angebotene Apps",
1498+
"subscriptions": "Abos"
1499+
},
14961500
"appSubscription": {
14971501
"headline": "App Subscription",
14981502
"subHeading": "Manage customer subscriptons",
@@ -1506,25 +1510,31 @@
15061510
"newServices": "New Services",
15071511
"recommendations": "Recommendations",
15081512
"allServices": "All Services",
1509-
"viewDetails": "Display more details",
1513+
"viewDetails": "Details anzeigen",
15101514
"activateBtn": "Aktivieren",
15111515
"configureBtn": "Konfigurieren",
15121516
"pleaseEnterValidURL": "Please enter a valid URL",
15131517
"error": "Error",
15141518
"success": "Aktivierung erfolgreich",
15151519
"configuration": "Konfiguration erfolgreich",
1516-
"pending": "Das Abonnement steht noch aus",
1517-
"active": "Das Abonnement ist aktiv",
1518-
"inactive": "Das Abonnement ist inaktiv",
1519-
"process": "Das Abonnement ist in Bearbeitung",
1520+
"pending": "Abo ausstehend",
1521+
"active": "Abo aktiv",
1522+
"inactive": "Abo abbestellt",
1523+
"unsubscribed": "Abo abbestellt",
1524+
"process": "Abo in Bearbeitung",
1525+
"offersHeading": "Angebotene Apps",
1526+
"appSubscriptionHeading": "Abos",
1527+
"loadMore": "Mehr laden",
15201528
"tabs": {
15211529
"request": "Request",
15221530
"active": "Active",
1531+
"inactive": "Abbestellt",
15231532
"showAll": "Show All"
15241533
},
15251534
"sortOptions": {
1526-
"customer": "By Customer A-Z",
1527-
"offer": "By Offer"
1535+
"customer": "Kunde A–Z",
1536+
"offer": "Angebot A-Z",
1537+
"apps": "Apps A–Z"
15281538
},
15291539
"document": {
15301540
"heading": "Relevant Documents",
@@ -1588,6 +1598,14 @@
15881598
"technicalSecret": "Technical User Secret",
15891599
"technicalPermission": "Technical User Permission"
15901600
},
1601+
"decline": {
1602+
"heading": "{{subscriptionType}} Abonnement ablehnen?",
1603+
"intro": "Für {{appName}}",
1604+
"description": "{{companyName}} erhält eine E-Mail-Benachrichtigung mit der Option, die App erneut zu abonnieren.",
1605+
"success": "{{subscriptionType}} Abonnement abgelehnt",
1606+
"cancelBtn": "Abbrechen",
1607+
"declineBtn": "Ablehnen"
1608+
},
15911609
"detailOverlay": {
15921610
"title": "Provider View",
15931611
"description": "App Subscription Details & Status",
@@ -2014,6 +2032,7 @@
20142032
"description": "Verwalten und organisieren Sie Ihre Unternehmenszertifikate einfach und effizient. Diese Seite bietet eine benutzerfreundliche Oberfläche zum Anzeigen, Hinzufügen, Bearbeiten und Löschen von Unternehmenszertifikaten. Behalten Sie den Überblick über Ihren Zertifikatsverwaltungsprozess und stellen Sie mühelos die Einhaltung sicher.",
20152033
"tabs": {
20162034
"inactive": "Inactive",
2035+
"unsubscribed": "Abo abbestellt",
20172036
"active": " Active",
20182037
"all": "All certificates"
20192038
},

src/assets/locales/de/servicerelease.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,15 @@
166166
"activateBtn": "Activate",
167167
"pleaseEnterValidURL": "Please enter a valid URL",
168168
"tabs": {
169-
"request": "Request",
170-
"active": "Active",
171-
"showAll": "Show All"
169+
"request": "Anfragen",
170+
"active": "Aktiv",
171+
"inactive": "Abbestellt",
172+
"showAll": "Alle"
172173
},
173174
"sortOptions": {
174-
"customer": "By Customer A-Z",
175-
"offer": "By Offer"
175+
"customer": "Kunde A–Z",
176+
"offer": "Angebot A-Z",
177+
"apps": "Apps A–Z"
176178
},
177179
"document": {
178180
"heading": "Relevant Documents",
@@ -206,7 +208,9 @@
206208
"technicaluserType": "Assigned Permissions:",
207209
"close": "Close"
208210
},
209-
"offersHeading": "Services Offered",
211+
"offersHeading": "Angebotene Services",
212+
"serviceSubscriptionHeading": "Abos",
213+
"loadMore": "Mehr laden",
210214
"success": "Aktivierung erfolgreich",
211215
"configuration": "Konfiguration erfolgreich",
212216
"failure": "Fehler bei der Konfiguration des Service Abonnements"

src/assets/locales/en/main.json

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,10 @@
14931493
"clientSercret": "Client Secret"
14941494
}
14951495
},
1496+
"appServiceSubscription": {
1497+
"appsOffered": "Apps Offered",
1498+
"subscriptions": "Subscriptions"
1499+
},
14961500
"appSubscription": {
14971501
"headline": "App Subscription",
14981502
"subHeading": "Manage customer subscriptons",
@@ -1509,14 +1513,19 @@
15091513
"viewDetails": "Display more details",
15101514
"activateBtn": "Activate",
15111515
"configureBtn": "Configure",
1516+
"declineBtn": "Decline",
15121517
"pleaseEnterValidURL": "Please enter a valid URL",
15131518
"error": "Error",
15141519
"success": "Activation successful",
15151520
"configuration": "Configuration successful",
1516-
"pending": "Subscription is Pending",
1517-
"active": "Subscription is Active",
1518-
"inactive": "Subscription is Inactive",
1519-
"process": "Subscription is in Progress",
1521+
"pending": "Subscription pending",
1522+
"active": "Subscription active",
1523+
"inactive": "Inactive",
1524+
"unsubscribed": "Unsubscribed",
1525+
"process": "Subscription in progress",
1526+
"offersHeading": "Apps Offered",
1527+
"appSubscriptionHeading": "Subscriptions",
1528+
"loadMore": "Load more",
15201529
"tabs": {
15211530
"request": "Request",
15221531
"active": "Active",
@@ -1588,6 +1597,14 @@
15881597
"technicalSecret": "Technical User Secret",
15891598
"technicalPermission": "Technical User Permission"
15901599
},
1600+
"decline": {
1601+
"heading": "Decline {{subscriptionType}} subscription?",
1602+
"intro": "For {{appName}}",
1603+
"description": "{{companyName}} receives an e-mail notification with the option to re-subscribe again.",
1604+
"success": "{{subscriptionType}} subscription declined",
1605+
"cancelBtn": "Cancel",
1606+
"declineBtn": "Decline"
1607+
},
15911608
"detailOverlay": {
15921609
"title": "Provider View",
15931610
"description": "App Subscription Details & Status",
@@ -2015,6 +2032,7 @@
20152032
"tabs": {
20162033
"inactive": "Inactive",
20172034
"active": " Active",
2035+
"unsubscribed": "Unsubscribed",
20182036
"all": "All certificates"
20192037
},
20202038
"sort": {

src/assets/locales/en/servicerelease.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,13 @@
168168
"tabs": {
169169
"request": "Request",
170170
"active": "Active",
171+
"inactive": "Unsubscribed",
171172
"showAll": "Show All"
172173
},
173174
"sortOptions": {
174-
"customer": "By Customer A-Z",
175-
"offer": "By Offer"
175+
"customer": "Customer A–Z",
176+
"offer": "Offer",
177+
"apps": "Apps A–Z"
176178
},
177179
"document": {
178180
"heading": "Relevant Documents",
@@ -207,6 +209,8 @@
207209
"close": "Close"
208210
},
209211
"offersHeading": "Services Offered",
212+
"serviceSubscriptionHeading": "Subscriptions",
213+
"loadMore": "Load More",
210214
"success": "Activation successful",
211215
"configuration": "Configuration successful",
212216
"failure": "Error while configuring service subscription"
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
/********************************************************************************
2+
* Copyright (c) 2023 BMW Group AG
3+
* Copyright (c) 2023 Contributors to the Eclipse Foundation
4+
*
5+
* See the NOTICE file(s) distributed with this work for additional
6+
* information regarding copyright ownership.
7+
*
8+
* This program and the accompanying materials are made available under the
9+
* terms of the Apache License, Version 2.0 which is available at
10+
* https://www.apache.org/licenses/LICENSE-2.0.
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15+
* License for the specific language governing permissions and limitations
16+
* under the License.
17+
*
18+
* SPDX-License-Identifier: Apache-2.0
19+
********************************************************************************/
20+
21+
import {
22+
Button,
23+
Dialog,
24+
DialogActions,
25+
DialogContent,
26+
DialogHeader,
27+
LoadingButton,
28+
Typography,
29+
} from '@catena-x/portal-shared-components'
30+
import { useTranslation, Trans } from 'react-i18next'
31+
import { useDeclineAppSubscriptionMutation } from 'features/appSubscription/appSubscriptionApiSlice'
32+
import { useDeclineServiceSubscriptionMutation } from 'features/serviceSubscription/serviceSubscriptionApiSlice'
33+
import { useState } from 'react'
34+
import './style.scss'
35+
import { success, error } from 'services/NotifyService'
36+
import { SubscriptionTypes } from 'components/shared/templates/Subscription'
37+
import { capitalize } from 'components/shared/cfx/generic'
38+
39+
interface DeclineSubscriptionProps {
40+
openDialog: boolean
41+
appId: string
42+
subscriptionId: string
43+
title: string
44+
appName: string
45+
subscriptionType: string
46+
handleOverlayClose: () => void
47+
refetch?: () => void
48+
declineSubscriptionAction: (subscriptionId: string) => void
49+
}
50+
51+
const DeclineSubscriptionOverlay = ({
52+
openDialog = false,
53+
subscriptionId,
54+
title,
55+
appName,
56+
subscriptionType,
57+
handleOverlayClose,
58+
declineSubscriptionAction,
59+
}: DeclineSubscriptionProps) => {
60+
const { t } = useTranslation()
61+
const [loading, setLoading] = useState(false)
62+
63+
const [declineAppSubscription] = useDeclineAppSubscriptionMutation()
64+
const [declineServiceSubscription] = useDeclineServiceSubscriptionMutation()
65+
66+
const handleDecline = async (subscriptionId: string) => {
67+
setLoading(true)
68+
try {
69+
if (subscriptionType === SubscriptionTypes.APP_SUBSCRIPTION) {
70+
await declineAppSubscription(subscriptionId).unwrap()
71+
} else {
72+
await declineServiceSubscription(subscriptionId).unwrap()
73+
}
74+
declineSubscriptionAction(subscriptionId)
75+
success(
76+
t('content.appSubscription.decline.success').replace(
77+
'{{subscriptionType}}',
78+
capitalize(subscriptionType)
79+
)
80+
)
81+
} catch (err) {
82+
error(t('content.appSubscription.error'), '', err as object)
83+
} finally {
84+
setLoading(false)
85+
handleOverlayClose()
86+
}
87+
}
88+
return (
89+
<Dialog
90+
open={openDialog}
91+
sx={{
92+
'.MuiDialog-paper': {
93+
maxWidth: '45%',
94+
width: '400px',
95+
},
96+
}}
97+
>
98+
<DialogHeader
99+
title={t('content.appSubscription.decline.heading').replace(
100+
'{{subscriptionType}}',
101+
capitalize(subscriptionType)
102+
)}
103+
intro={t('content.appSubscription.decline.intro').replace(
104+
'{{appName}}',
105+
appName
106+
)}
107+
closeWithIcon={false}
108+
/>
109+
<DialogContent>
110+
<div className="appSubscriptionMain">
111+
<Trans
112+
values={{
113+
companyName: title,
114+
}}
115+
>
116+
<Typography variant="body2">
117+
{t('content.appSubscription.decline.description')}
118+
</Typography>
119+
</Trans>
120+
</div>
121+
</DialogContent>
122+
<DialogActions>
123+
<Button
124+
variant="outlined"
125+
onClick={() => {
126+
handleOverlayClose()
127+
}}
128+
>
129+
{t('content.appSubscription.decline.cancelBtn')}
130+
</Button>
131+
{loading ? (
132+
<LoadingButton
133+
color="primary"
134+
helperText=""
135+
helperTextColor="success"
136+
label=""
137+
loadIndicator="Loading ..."
138+
loading
139+
size="medium"
140+
onButtonClick={() => {
141+
// do nothing
142+
}}
143+
sx={{ marginLeft: '10px' }}
144+
/>
145+
) : (
146+
<Button
147+
className="cx-decline-btn"
148+
variant="contained"
149+
onClick={() => handleDecline(subscriptionId)}
150+
>
151+
{t('content.appSubscription.decline.declineBtn')}
152+
</Button>
153+
)}
154+
</DialogActions>
155+
</Dialog>
156+
)
157+
}
158+
159+
export default DeclineSubscriptionOverlay

0 commit comments

Comments
 (0)