diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d22ed574..1f2931fde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## unreleased +- App Subscription + - Autosetup Process Worker implementation (adjust overlay) - Usermanagement - User Invite IdP connection logic diff --git a/src/assets/locales/de/main.json b/src/assets/locales/de/main.json index df7a6ba02..8444ff261 100644 --- a/src/assets/locales/de/main.json +++ b/src/assets/locales/de/main.json @@ -1233,6 +1233,8 @@ "activateBtn": "Activate", "configureBtn": "Configure", "pleaseEnterValidURL": "Please enter a valid URL", + "error": "Error", + "success": "Success", "tabs": { "request": "Request", "active": "Active", diff --git a/src/assets/locales/en/main.json b/src/assets/locales/en/main.json index fa1e5c52b..f97e2e1f4 100644 --- a/src/assets/locales/en/main.json +++ b/src/assets/locales/en/main.json @@ -1197,6 +1197,8 @@ "activateBtn": "Activate", "configureBtn": "Configure", "pleaseEnterValidURL": "Please enter a valid URL", + "error": "Error", + "success": "Success", "tabs": { "request": "Request", "active": "Active", diff --git a/src/components/shared/templates/Subscription/Subscription.scss b/src/components/shared/templates/Subscription/Subscription.scss index 151478b74..bf43ee52f 100644 --- a/src/components/shared/templates/Subscription/Subscription.scss +++ b/src/components/shared/templates/Subscription/Subscription.scss @@ -209,9 +209,6 @@ border-radius: 15px; padding: 5px; } - .configureBtn { - pointer-events: none; - } .statusIcon { height: 30px; float: right; diff --git a/src/components/shared/templates/Subscription/SubscriptionElements.tsx b/src/components/shared/templates/Subscription/SubscriptionElements.tsx index ef3fff440..5ab60e533 100644 --- a/src/components/shared/templates/Subscription/SubscriptionElements.tsx +++ b/src/components/shared/templates/Subscription/SubscriptionElements.tsx @@ -32,6 +32,7 @@ import { type CompanySubscriptionData, ProcessStep, type SubscriptionContent, + useActivateSubscriptionMutation, } from 'features/appSubscription/appSubscriptionApiSlice' import NoItems from 'components/pages/NoItems' import './Subscription.scss' @@ -44,6 +45,7 @@ import { SubscriptionTypes } from '.' import { getAssetBase } from 'services/EnvironmentService' import AddTaskIcon from '@mui/icons-material/AddTask' import HistoryIcon from '@mui/icons-material/History' +import { error, success } from 'services/NotifyService' type ViewDetail = { appId: string @@ -146,6 +148,17 @@ export default function SubscriptionElements({ const [subscriptionDetail, setSubscriptionDetail] = useState(SubscriptionInitialData) + const [activateSubscription] = useActivateSubscriptionMutation() + + const handleActivate = async (subscriptionId: string) => { + try { + await activateSubscription(subscriptionId).unwrap() + success(t('content.appSubscription.success')) + } catch (err) { + error(t('content.appSubscription.error'), '', err as object) + } + } + if (subscriptions && subscriptions.length === 0 && isSuccess) { return } else if (!isSuccess) { @@ -176,21 +189,6 @@ export default function SubscriptionElements({ label={t('content.appSubscription.configureBtn')} type="plain" variant="filled" - className="configureBtn" - /> - - - ) - } else if ( - subscriptionData.processStepTypeId === ProcessStep.ACTIVATE_SUBSCRIPTION - ) { - return ( - <> - { type === SubscriptionTypes.APP_SUBSCRIPTION ? setSubscriptionDetail({ @@ -215,6 +213,21 @@ export default function SubscriptionElements({ ) + } else if ( + subscriptionData.processStepTypeId === ProcessStep.ACTIVATE_SUBSCRIPTION + ) { + return ( + <> + handleActivate(subscription.subscriptionId)} + /> + + + ) } else { return ( ({ + query: (subscriptionId) => ({ + url: `/subscription/${subscriptionId}/activate `, + method: 'PUT', + }), + }), }), }) @@ -196,4 +202,5 @@ export const { useFetchTechnicalProfilesQuery, useAddUserSubscribtionMutation, useUpdateTenantUrlMutation, + useActivateSubscriptionMutation, } = apiSlice