diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ede1703b..638d5699d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,8 @@ - update the status(skipped) in application requests and necessary changes with checkbox in connector management [#1019](https://github.com/eclipse-tractusx/portal-frontend/pull/1019) - **Technical User Management** - Removed 'Inactive' filter in technical user management [#1046](https://github.com/eclipse-tractusx/portal-frontend/pull/1046) +- **Company Subscriptions** + - Update and bind API with filter options [#1062](https://github.com/eclipse-tractusx/portal-frontend/pull/1062) ### Bugfixes diff --git a/src/assets/locales/de/main.json b/src/assets/locales/de/main.json index c73816c60..741b717a5 100644 --- a/src/assets/locales/de/main.json +++ b/src/assets/locales/de/main.json @@ -460,9 +460,10 @@ "action": "Aktion" }, "filter": { - "requested": "angefordert", + "pending": "ausstehend", "active": "aktiv", - "showAll": "zeige alles" + "inactive": "inaktiv", + "showAll": "Alles anzeigen" } }, "appOverview": { diff --git a/src/assets/locales/en/main.json b/src/assets/locales/en/main.json index ad81512d0..180c8fc24 100644 --- a/src/assets/locales/en/main.json +++ b/src/assets/locales/en/main.json @@ -456,8 +456,9 @@ "action": "Action" }, "filter": { - "requested": "requested", + "pending": "pending", "active": "active", + "inactive": "inactive", "showAll": "show all" } }, diff --git a/src/components/pages/CompanySubscriptions/index.tsx b/src/components/pages/CompanySubscriptions/index.tsx index 097d5dd03..9c609877f 100644 --- a/src/components/pages/CompanySubscriptions/index.tsx +++ b/src/components/pages/CompanySubscriptions/index.tsx @@ -40,7 +40,7 @@ import { import { CompanySubscriptionsTableColumns } from './CompanySubscriptionsTableColumns' interface FetchHookArgsType { - statusFilter: string + statusId: string expr: string } @@ -50,7 +50,9 @@ export default function CompanySubscriptions() { const [refresh, setRefresh] = useState(0) const [searchExpr, setSearchExpr] = useState('') const [fetchHookArgs, setFetchHookArgs] = useState() - const [filterStatus, setFilterStatus] = useState('') + const [filterStatus, setFilterStatus] = useState( + CompanySubscriptionFilterType.SHOW_ALL + ) const searchInputData = useSelector(updateApplicationRequestSelector) const [group, setGroup] = useState( t('content.companySubscriptions.filter.showAll') @@ -72,8 +74,8 @@ export default function CompanySubscriptions() { const filterView = [ { - buttonText: t('content.companySubscriptions.filter.requested'), - buttonValue: CompanySubscriptionFilterType.REQUESTED, + buttonText: t('content.companySubscriptions.filter.pending'), + buttonValue: CompanySubscriptionFilterType.PENDING, onButtonClick: setView, }, { @@ -81,6 +83,11 @@ export default function CompanySubscriptions() { buttonValue: CompanySubscriptionFilterType.ACTIVE, onButtonClick: setView, }, + { + buttonText: t('content.companySubscriptions.filter.inactive'), + buttonValue: CompanySubscriptionFilterType.INACTIVE, + onButtonClick: setView, + }, { buttonText: t('content.companySubscriptions.filter.showAll'), buttonValue: CompanySubscriptionFilterType.SHOW_ALL, @@ -89,12 +96,10 @@ export default function CompanySubscriptions() { ] useEffect(() => { - if (onValidate(searchExpr)) { - setFetchHookArgs({ - statusFilter: filterStatus, - expr: searchExpr, - }) - } + setFetchHookArgs({ + statusId: filterStatus, + expr: searchExpr, + }) }, [filterStatus, searchExpr]) const onValidate = (expr: string) => { diff --git a/src/features/apps/apiSlice.ts b/src/features/apps/apiSlice.ts index 6a686c987..99393e63d 100644 --- a/src/features/apps/apiSlice.ts +++ b/src/features/apps/apiSlice.ts @@ -42,6 +42,7 @@ import { type FetchSubscriptionAppQueryType, type SubscribedActiveApps, StatusIdEnum, + CompanySubscriptionFilterType, } from './types' export const apiSlice = createApi({ @@ -164,9 +165,16 @@ export const apiSlice = createApi({ PaginResult, PaginFetchArgs >({ - query: (fetchArgs) => ({ - url: `/api/Apps/subscribed/subscription-status?size=${PAGE_SIZE}&page=${fetchArgs.page}`, - }), + query: (fetchArgs) => { + if ( + fetchArgs.args.statusId && + fetchArgs.args.statusId !== CompanySubscriptionFilterType.SHOW_ALL + ) { + return `/api/Apps/subscribed/subscription-status?size=${PAGE_SIZE}&page=${fetchArgs.page}&statusId=${fetchArgs.args.statusId}` + } else { + return `/api/Apps/subscribed/subscription-status?size=${PAGE_SIZE}&page=${fetchArgs.page}` + } + }, }), }), }) diff --git a/src/features/apps/types.ts b/src/features/apps/types.ts index 057de1a74..899e1a203 100644 --- a/src/features/apps/types.ts +++ b/src/features/apps/types.ts @@ -251,8 +251,9 @@ export const initialState: AppsControlState = { } export enum CompanySubscriptionFilterType { - REQUESTED = 'requested', + PENDING = 'pending', ACTIVE = 'active', + INACTIVE = 'inactive', SHOW_ALL = 'show all', }