UNPKG

@finos/legend-application-marketplace

Version:
62 lines 4.27 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; /** * Copyright (c) 2020-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://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. */ import { observer } from 'mobx-react-lite'; import { withLakehouseEntitlementsStore, useLakehouseEntitlementsStore, } from '../../../application/providers/LakehouseEntitlementsStoreProvider.js'; import { useAuth } from 'react-oidc-context'; import { useEffect, useState } from 'react'; import { LegendMarketplacePage } from '../../LegendMarketplacePage.js'; import { flowResult } from 'mobx'; import { Container, Tab, Tabs, Typography } from '@mui/material'; import { EntitlementsClosedContractsDashboard } from './EntitlementsClosedContractsDashboard.js'; import { EntitlementsPendingContractsDashboard } from './EntitlementsPendingContractsDashboard.js'; import { EntitlementsPendingTasksDashboard } from './EntitlementsPendingTasksDashboard.js'; import { useSearchParams } from '@finos/legend-application/browser'; import { LEGEND_MARKETPLACE_ENTITLEMENTS_QUERY_PARAM_TOKEN } from '../../../__lib__/LegendMarketplaceNavigation.js'; var EntitlementsTabs; (function (EntitlementsTabs) { EntitlementsTabs["PENDING_TASKS"] = "pendingTasks"; EntitlementsTabs["PENDING_CONTRACTS"] = "pendingContracts"; EntitlementsTabs["CLOSED_CONTRACTS"] = "closedContracts"; })(EntitlementsTabs || (EntitlementsTabs = {})); export const LakehouseEntitlements = withLakehouseEntitlementsStore(observer(() => { // State and props const entitlementsStore = useLakehouseEntitlementsStore(); const auth = useAuth(); const [searchParams, setSearchParams] = useSearchParams(); const [selectedTab, setSelectedTab] = useState(searchParams.get(LEGEND_MARKETPLACE_ENTITLEMENTS_QUERY_PARAM_TOKEN.SELECTED_TAB) ?? EntitlementsTabs.PENDING_TASKS); // Effects useEffect(() => { if (entitlementsStore.dashboardViewer.initializationState.isInInitialState) { // eslint-disable-next-line no-void void flowResult(entitlementsStore.dashboardViewer.init(auth.user?.access_token)); } }, [ entitlementsStore.dashboardViewer.initializationState, auth.user?.access_token, entitlementsStore, ]); // Callbacks const handleTabChange = (_, newValue) => { setSelectedTab(newValue); setSearchParams((params) => { params.set(LEGEND_MARKETPLACE_ENTITLEMENTS_QUERY_PARAM_TOKEN.SELECTED_TAB, newValue); return params; }); }; return (_jsx(LegendMarketplacePage, { className: "marketplace-lakehouse-entitlements", children: _jsxs(Container, { className: "marketplace-lakehouse-entitlements-dashboard", maxWidth: "xxl", children: [_jsxs(Tabs, { value: selectedTab, onChange: handleTabChange, children: [_jsx(Tab, { label: _jsx(Typography, { variant: "h4", gutterBottom: true, children: "MY APPROVALS" }), value: EntitlementsTabs.PENDING_TASKS }), _jsx(Tab, { label: _jsx(Typography, { variant: "h4", gutterBottom: true, children: "MY PENDING REQUESTS" }), value: EntitlementsTabs.PENDING_CONTRACTS }), _jsx(Tab, { label: _jsx(Typography, { variant: "h4", gutterBottom: true, children: "MY CLOSED REQUESTS" }), value: EntitlementsTabs.CLOSED_CONTRACTS })] }), selectedTab === EntitlementsTabs.PENDING_TASKS && (_jsx(EntitlementsPendingTasksDashboard, { dashboardState: entitlementsStore.dashboardViewer })), selectedTab === EntitlementsTabs.PENDING_CONTRACTS && (_jsx(EntitlementsPendingContractsDashboard, { dashboardState: entitlementsStore.dashboardViewer })), selectedTab === EntitlementsTabs.CLOSED_CONTRACTS && (_jsx(EntitlementsClosedContractsDashboard, { dashboardState: entitlementsStore.dashboardViewer }))] }) })); })); //# sourceMappingURL=LakehouseEntitlements.js.map