@syzy/apphost 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.js +83 -0
- package/dist/AppHostProvider.js +4 -0
- package/dist/AppHostRoutes.js +7 -0
- package/dist/api/image-api.js +45 -0
- package/dist/api/mapping-api.js +427 -0
- package/dist/bookingModule/components/AmenityForm.js +19 -0
- package/dist/bookingModule/components/BillingManagement.js +17 -0
- package/dist/bookingModule/components/CreateRoomForm.js +19 -0
- package/dist/bookingModule/components/ExtraRequirementForm.js +19 -0
- package/dist/bookingModule/components/ReservationForm.js +18 -0
- package/dist/bookingModule/components/RoomCategoryForm.js +19 -0
- package/dist/bookingModule/components/RoomCategoryPriceForm.js +20 -0
- package/dist/bookingModule/components/RoomExtraRequirementCapture.js +18 -0
- package/dist/bookingModule/components/RoomFacilityForm.js +19 -0
- package/dist/bookingModule/components/RoomReservationAction.js +18 -0
- package/dist/components/Home/Home.js +14 -0
- package/dist/components/Loader/Loader.js +5 -0
- package/dist/components/Login/Login.js +149 -0
- package/dist/components/Login/loginSchema.js +41 -0
- package/dist/components/Mappings/BranchMapping/Branch.js +135 -0
- package/dist/components/Mappings/BranchMapping/BranchTableColumns.js +21 -0
- package/dist/components/Mappings/BranchMapping/MappingFormBranchUser.js +150 -0
- package/dist/components/Mappings/BranchMapping/MappingTableColumns.js +29 -0
- package/dist/components/Mappings/BranchMapping/branchSchema.js +34 -0
- package/dist/components/Mappings/ComponentMapping/ComponentRoleMapping.js +98 -0
- package/dist/components/Mappings/ComponentMapping/componentRoleColumns.js +29 -0
- package/dist/components/Mappings/MappingForm/MappingForm.js +142 -0
- package/dist/components/Mappings/MappingForm/mappingSchema.js +32 -0
- package/dist/components/Mappings/RoleMapping/MappingFormUserRole.js +194 -0
- package/dist/components/Mappings/RoleMapping/UserRoleTableColumns.js +33 -0
- package/dist/components/NavBar/Sidebar.js +56 -0
- package/dist/components/ProfileForm/ProfileForm.js +190 -0
- package/dist/components/ProfileForm/ProfileList.js +33 -0
- package/dist/components/ProfileForm/profileColumns.js +67 -0
- package/dist/components/ProfileForm/profileSchema.js +50 -0
- package/dist/components/SettingsPage/SettingsPage.js +240 -0
- package/dist/components/api/settings-api.js +131 -0
- package/dist/components/common/Form/FormActionButtons.js +6 -0
- package/dist/components/common/Form/FormLabel.js +6 -0
- package/dist/components/common/ListTable/ListHeader.js +5 -0
- package/dist/components/common/ListTable/ListTable.js +31 -0
- package/dist/components/common/Modal/Modal.js +6 -0
- package/dist/config/EnvConfig.js +13 -0
- package/dist/config/amplifyConfig.js +45 -0
- package/dist/configureAppHost.js +5 -0
- package/dist/customGraphQL/customMutations.js +53 -0
- package/dist/customGraphQL/customQueries.js +104 -0
- package/dist/domain/input/input-types.js +1 -0
- package/dist/domain/model/BranchDto.js +8 -0
- package/dist/domain/model/ComponentMappingDto.js +19 -0
- package/dist/domain/model/MappingDto.js +16 -0
- package/dist/domain/model/PrefixDescriptionDto.js +13 -0
- package/dist/domain/model/ProfileDto.js +20 -0
- package/dist/domain/model/RoleMappingDto.js +19 -0
- package/dist/domain/model/SettingsDto.js +7 -0
- package/dist/domain/model/UserMappingDto.js +28 -0
- package/dist/domain/model/imageDto.js +1 -0
- package/dist/domain/type/EntityTypes.js +6 -0
- package/dist/domain/type/MappingOptions.js +1 -0
- package/dist/domain/type/MappingTypes.js +7 -0
- package/dist/domain/type/Nullable.js +1 -0
- package/dist/domain/type/ResettingPeriodOptions.js +8 -0
- package/dist/domain/type/RolesEnum.js +7 -0
- package/dist/domain/type/SelectType.js +1 -0
- package/dist/domain/type/StatusEnum.js +6 -0
- package/dist/domain/type/signUpOptions.js +4 -0
- package/dist/domain/type/statusOptions.js +4 -0
- package/dist/graphql/profileQueries.js +89 -0
- package/dist/hoc/withSyzyAuth.js +87 -0
- package/dist/hooks/useCurrentUser.js +6 -0
- package/dist/hooks/useDispatch.js +7 -0
- package/dist/hooks/usePermission.js +7 -0
- package/dist/index.js +3 -15
- package/dist/main.js +60 -0
- package/dist/services/Client.Service.js +96 -0
- package/dist/services/Storage-service.js +26 -0
- package/dist/services/navigationMenu.js +9 -0
- package/dist/static/constants.js +34 -0
- package/dist/store/AppAction.js +5 -0
- package/dist/store/AppContext.js +3 -0
- package/dist/store/AppContextType.js +6 -0
- package/dist/store/AppProvider.js +32 -0
- package/dist/store/HostedInContainerContext.js +11 -0
- package/dist/store/SesssionReducer.js +16 -0
- package/dist/types/App.d.ts +4 -0
- package/dist/types/AppHostProvider.d.ts +6 -0
- package/dist/types/AppHostRoutes.d.ts +1 -0
- package/dist/types/api/image-api.d.ts +8 -0
- package/dist/types/api/mapping-api.d.ts +80 -0
- package/dist/types/bookingModule/components/AmenityForm.d.ts +3 -0
- package/dist/types/bookingModule/components/BillingManagement.d.ts +3 -0
- package/dist/types/bookingModule/components/CreateRoomForm.d.ts +3 -0
- package/dist/types/bookingModule/components/ExtraRequirementForm.d.ts +3 -0
- package/dist/types/bookingModule/components/ReservationForm.d.ts +3 -0
- package/dist/types/bookingModule/components/RoomCategoryForm.d.ts +3 -0
- package/dist/types/bookingModule/components/RoomCategoryPriceForm.d.ts +3 -0
- package/dist/types/bookingModule/components/RoomExtraRequirementCapture.d.ts +3 -0
- package/dist/types/bookingModule/components/RoomFacilityForm.d.ts +3 -0
- package/dist/types/bookingModule/components/RoomReservationAction.d.ts +3 -0
- package/dist/types/components/Home/Home.d.ts +3 -0
- package/dist/types/components/Loader/Loader.d.ts +2 -0
- package/dist/types/components/Login/Login.d.ts +7 -0
- package/dist/types/components/Login/loginSchema.d.ts +27 -0
- package/dist/types/components/Mappings/BranchMapping/Branch.d.ts +5 -0
- package/dist/types/components/Mappings/BranchMapping/BranchTableColumns.d.ts +10 -0
- package/dist/types/components/Mappings/BranchMapping/MappingFormBranchUser.d.ts +3 -0
- package/dist/types/components/Mappings/BranchMapping/MappingTableColumns.d.ts +14 -0
- package/dist/types/components/Mappings/BranchMapping/branchSchema.d.ts +37 -0
- package/dist/types/components/Mappings/ComponentMapping/ComponentRoleMapping.d.ts +3 -0
- package/dist/types/components/Mappings/ComponentMapping/componentRoleColumns.d.ts +3 -0
- package/dist/types/components/Mappings/MappingForm/MappingForm.d.ts +35 -0
- package/dist/types/components/Mappings/MappingForm/mappingSchema.d.ts +23 -0
- package/dist/types/components/Mappings/RoleMapping/MappingFormUserRole.d.ts +5 -0
- package/dist/types/components/Mappings/RoleMapping/UserRoleTableColumns.d.ts +3 -0
- package/dist/types/components/NavBar/Sidebar.d.ts +4 -0
- package/dist/types/components/ProfileForm/ProfileForm.d.ts +3 -0
- package/dist/types/components/ProfileForm/ProfileList.d.ts +3 -0
- package/dist/types/components/ProfileForm/profileColumns.d.ts +3 -0
- package/dist/types/components/ProfileForm/profileSchema.d.ts +52 -0
- package/dist/types/components/SettingsPage/SettingsPage.d.ts +3 -0
- package/dist/types/components/api/settings-api.d.ts +26 -0
- package/dist/types/components/common/Form/FormActionButtons.d.ts +11 -0
- package/dist/types/components/common/Form/FormLabel.d.ts +8 -0
- package/dist/types/components/common/ListTable/ListHeader.d.ts +8 -0
- package/dist/types/components/common/ListTable/ListTable.d.ts +17 -0
- package/dist/types/components/common/Modal/Modal.d.ts +11 -0
- package/dist/types/config/EnvConfig.d.ts +13 -0
- package/dist/types/config/amplifyConfig.d.ts +1 -0
- package/dist/types/configureAppHost.d.ts +6 -0
- package/dist/types/customGraphQL/customMutations.d.ts +3 -0
- package/dist/types/customGraphQL/customQueries.d.ts +7 -0
- package/dist/types/domain/input/input-types.d.ts +47 -0
- package/dist/types/domain/model/BranchDto.d.ts +9 -0
- package/dist/types/domain/model/ComponentMappingDto.d.ts +24 -0
- package/dist/types/domain/model/MappingDto.d.ts +30 -0
- package/dist/types/domain/model/PrefixDescriptionDto.d.ts +16 -0
- package/dist/types/domain/model/ProfileDto.d.ts +21 -0
- package/dist/types/domain/model/RoleMappingDto.d.ts +14 -0
- package/dist/types/domain/model/SettingsDto.d.ts +8 -0
- package/dist/types/domain/model/UserMappingDto.d.ts +14 -0
- package/dist/types/domain/model/imageDto.d.ts +4 -0
- package/dist/types/domain/type/EntityTypes.d.ts +5 -0
- package/dist/types/domain/type/MappingOptions.d.ts +5 -0
- package/dist/types/domain/type/MappingTypes.d.ts +6 -0
- package/dist/types/domain/type/Nullable.d.ts +13 -0
- package/dist/types/domain/type/ResettingPeriodOptions.d.ts +2 -0
- package/dist/types/domain/type/RolesEnum.d.ts +6 -0
- package/dist/types/domain/type/SelectType.d.ts +16 -0
- package/dist/types/domain/type/StatusEnum.d.ts +5 -0
- package/dist/types/domain/type/signUpOptions.d.ts +2 -0
- package/dist/types/domain/type/statusOptions.d.ts +2 -0
- package/dist/types/graphql/profileQueries.d.ts +4 -0
- package/dist/types/hoc/withSyzyAuth.d.ts +2 -0
- package/dist/types/hooks/useCurrentUser.d.ts +3 -0
- package/dist/types/hooks/useDispatch.d.ts +3 -0
- package/dist/types/hooks/usePermission.d.ts +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/main.d.ts +4 -0
- package/dist/types/services/Client.Service.d.ts +12 -0
- package/dist/types/services/Storage-service.d.ts +2 -0
- package/dist/types/services/navigationMenu.d.ts +1 -0
- package/dist/types/static/constants.d.ts +34 -0
- package/dist/types/store/AppAction.d.ts +11 -0
- package/dist/types/store/AppContext.d.ts +3 -0
- package/dist/types/store/AppContextType.d.ts +12 -0
- package/dist/types/store/AppProvider.d.ts +7 -0
- package/dist/types/store/HostedInContainerContext.d.ts +5 -0
- package/dist/types/store/SesssionReducer.d.ts +4 -0
- package/dist/types/types.d.ts +26 -0
- package/dist/types/util/AuthUtils.d.ts +1 -0
- package/dist/types/util/LogEnum.d.ts +6 -0
- package/dist/types/util/Logger.d.ts +6 -0
- package/dist/types/util/SyzyDate.d.ts +69 -0
- package/dist/types/util/dateUtils.d.ts +10 -0
- package/dist/types/util/hostedinContainer.d.ts +1 -0
- package/dist/types/util/model-types.d.ts +96 -0
- package/dist/types/util/prefixAndResettingValidation.d.ts +9 -0
- package/dist/types/util/transformToData.d.ts +1 -0
- package/dist/types.js +14 -0
- package/dist/util/AuthUtils.js +10 -0
- package/dist/util/LogEnum.js +7 -0
- package/dist/util/Logger.js +18 -0
- package/dist/util/SyzyDate.js +265 -0
- package/dist/util/dateUtils.js +24 -0
- package/dist/util/hostedinContainer.js +9 -0
- package/dist/util/model-types.js +18 -0
- package/dist/util/prefixAndResettingValidation.js +54 -0
- package/dist/util/transformToData.js +9 -0
- package/package.json +14 -9
- package/dist/__federation_shared_@tanstack/react-query-DHuUsaNz.js +0 -2517
- package/dist/__federation_shared_react-CikWE6qG.js +0 -7
- package/dist/__federation_shared_react-bootstrap-BKlZRvMR.js +0 -7516
- package/dist/__federation_shared_react-dom-vrQ70Ay8.js +0 -372
- package/dist/__federation_shared_react-router-dom-BKminmS4.js +0 -10448
- package/dist/__federation_shared_react-select-B6kehBDI.js +0 -4056
- package/dist/__federation_shared_react-toastify-B0S0UGr3.js +0 -412
- package/dist/_commonjsHelpers-C6fGbg64.js +0 -6
- package/dist/_virtual___federation_fn_import-XZCKozko.js +0 -217
- package/dist/favicon.ico +0 -0
- package/dist/index-DgtWMtjZ.js +0 -184
- package/dist/index-eZknuYwc.js +0 -1219
- package/dist/jsx-runtime-D_t4bG-_.js +0 -264
- package/dist/manifest.webmanifest +0 -1
- package/dist/pwa/Hotel-icon.jpg +0 -0
- package/dist/pwa/apple-touch-icon-180x180.png +0 -0
- package/dist/pwa/favicon.ico +0 -0
- package/dist/pwa/maskable-icon-512x512.png +0 -0
- package/dist/pwa/pwa-192x192.png +0 -0
- package/dist/pwa/pwa-512x512.png +0 -0
- package/dist/pwa/pwa-64x64.png +0 -0
- package/dist/registerSW.js +0 -1
- package/dist/sw.js +0 -1
- package/dist/workbox-1ef09536.js +0 -1
package/dist/App.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// import { configureAmplify } from "./config/amplifyConfig.ts";
|
|
3
|
+
import { Route, Routes } from 'react-router-dom';
|
|
4
|
+
import { useCurrentUser } from './hooks/useCurrentUser';
|
|
5
|
+
import { withSyzyAuth } from './hoc/withSyzyAuth';
|
|
6
|
+
import React, { useEffect, useState } from 'react';
|
|
7
|
+
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
|
8
|
+
import Sidebar from './components/NavBar/Sidebar';
|
|
9
|
+
import { getSidebarMenu } from './services/navigationMenu';
|
|
10
|
+
import ProfileForm from './components/ProfileForm/ProfileForm';
|
|
11
|
+
import BranchMapping from './components/Mappings/BranchMapping/Branch';
|
|
12
|
+
import MappingFormBranchUser from './components/Mappings/BranchMapping/MappingFormBranchUser';
|
|
13
|
+
import ComponentRoleMapping from './components/Mappings/ComponentMapping/ComponentRoleMapping';
|
|
14
|
+
import MappingFormUserRole from './components/Mappings/RoleMapping/MappingFormUserRole';
|
|
15
|
+
import Home from './components/Home/Home';
|
|
16
|
+
import LoadingSpinner from './components/Loader/Loader';
|
|
17
|
+
// import { isHostedInContainer } from "./util/hostedinContainer.ts";
|
|
18
|
+
// configureAmplify();
|
|
19
|
+
export const componentMap = {
|
|
20
|
+
BranchMapping,
|
|
21
|
+
ProfileForm,
|
|
22
|
+
MappingFormBranchUser,
|
|
23
|
+
MappingFormUserRole,
|
|
24
|
+
ComponentRoleMapping,
|
|
25
|
+
Home,
|
|
26
|
+
};
|
|
27
|
+
const flattenRoutes = (items) => {
|
|
28
|
+
const flat = [];
|
|
29
|
+
const walk = (arr) => {
|
|
30
|
+
arr.forEach(item => {
|
|
31
|
+
if (item.path && item.requiredComponent) {
|
|
32
|
+
flat.push(item);
|
|
33
|
+
}
|
|
34
|
+
if (item.children) {
|
|
35
|
+
walk(item.children);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
walk(items);
|
|
40
|
+
return flat;
|
|
41
|
+
};
|
|
42
|
+
const withAccessControl = (Component, props, requiredComponent, allowedComponents) => {
|
|
43
|
+
// Check if the user has access
|
|
44
|
+
const isAllowed = !requiredComponent || (allowedComponents?.includes(requiredComponent));
|
|
45
|
+
if (!isAllowed) {
|
|
46
|
+
return () => (_jsx("div", { className: "text-center mt-5", children: _jsx("h3", { className: "text-danger", children: "You are not allowed to see this page." }) }));
|
|
47
|
+
}
|
|
48
|
+
return () => _jsx(Component, { ...props });
|
|
49
|
+
};
|
|
50
|
+
function App({ isSessionReady }) {
|
|
51
|
+
const { user } = useCurrentUser();
|
|
52
|
+
const [routes, setRoutes] = useState([]);
|
|
53
|
+
const flatRoutes = flattenRoutes(routes);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const fetchMenu = async () => {
|
|
56
|
+
const data = await getSidebarMenu();
|
|
57
|
+
setRoutes(data);
|
|
58
|
+
};
|
|
59
|
+
fetchMenu();
|
|
60
|
+
}, []);
|
|
61
|
+
// useEffect(() => {
|
|
62
|
+
// isHostedInContainer();
|
|
63
|
+
// }, []);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
const fetchMenu = async () => {
|
|
66
|
+
const data = await getSidebarMenu();
|
|
67
|
+
setRoutes(data);
|
|
68
|
+
};
|
|
69
|
+
fetchMenu();
|
|
70
|
+
}, []);
|
|
71
|
+
// useEffect(() => {
|
|
72
|
+
// isHostedInContainer();
|
|
73
|
+
// configureAmplify();
|
|
74
|
+
// }, []);
|
|
75
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { style: { display: "flex", width: "100%" }, children: [_jsx(Sidebar, {}), _jsx("div", { style: { flex: 1, padding: "10px" }, children: !isSessionReady ? (_jsx(LoadingSpinner, {})) : (_jsx(React.Fragment, { children: _jsxs(Routes, { children: [flatRoutes.map(({ path, requiredComponent, props }) => {
|
|
76
|
+
const PageComponent = componentMap[requiredComponent];
|
|
77
|
+
if (!PageComponent)
|
|
78
|
+
return null;
|
|
79
|
+
const ProtectedComponent = withAccessControl(PageComponent, props, requiredComponent, user.allowedComponents);
|
|
80
|
+
return _jsx(Route, { path: path, element: _jsx(ProtectedComponent, {}) }, path);
|
|
81
|
+
}), _jsx(Route, { path: "*", element: _jsx("h3", { className: "text-danger", children: "Page Not Found" }) })] }) })) })] }), _jsx(ReactQueryDevtools, { initialIsOpen: false })] }));
|
|
82
|
+
}
|
|
83
|
+
export default withSyzyAuth(App);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Routes, Route } from "react-router-dom";
|
|
3
|
+
const Dashboard = () => _jsx("div", { children: "AppHost Dashboard" });
|
|
4
|
+
const Settings = () => _jsx("div", { children: "AppHost Settings" });
|
|
5
|
+
export const AppHostRoutes = () => {
|
|
6
|
+
return (_jsxs(Routes, { children: [_jsx(Route, { path: "/apphost", element: _jsx(Dashboard, {}) }), _jsx(Route, { path: "/apphost/settings", element: _jsx(Settings, {}) })] }));
|
|
7
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { keepPreviousData, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
2
|
+
import { LogCategoryEnum } from "../util/LogEnum";
|
|
3
|
+
import { logger } from "../util/Logger";
|
|
4
|
+
import { getImageUrl } from "../services/Storage-service";
|
|
5
|
+
import { uploadData } from "aws-amplify/storage";
|
|
6
|
+
import { toast } from "react-toastify";
|
|
7
|
+
export const GETIMAGEPRESIGNEDURL_QUERYKEY = "downloadimage";
|
|
8
|
+
export const useGetImageURL = (fileName) => {
|
|
9
|
+
logger.debug(LogCategoryEnum.Info, "fileName", fileName);
|
|
10
|
+
logger.debug(LogCategoryEnum.Info, "inside of get img url", fileName);
|
|
11
|
+
const { data, isLoading, error } = useQuery({
|
|
12
|
+
queryKey: [GETIMAGEPRESIGNEDURL_QUERYKEY, fileName],
|
|
13
|
+
queryFn: () => getImageUrl(fileName),
|
|
14
|
+
placeholderData: keepPreviousData,
|
|
15
|
+
staleTime: 300000,
|
|
16
|
+
enabled: fileName !== undefined
|
|
17
|
+
});
|
|
18
|
+
return { fetchedImg: data, fetchedImgLoading: isLoading, fetchedImgError: error };
|
|
19
|
+
};
|
|
20
|
+
export const useImageMutation = (imgInfo) => {
|
|
21
|
+
logger.debug(LogCategoryEnum.Info, "inside upload image mutation", imgInfo);
|
|
22
|
+
const uploadImage = async (image) => {
|
|
23
|
+
logger.debug(LogCategoryEnum.Info, "inside upload image function", image);
|
|
24
|
+
return uploadData({
|
|
25
|
+
key: image.imageKey,
|
|
26
|
+
data: image.file,
|
|
27
|
+
options: {
|
|
28
|
+
accessLevel: 'guest',
|
|
29
|
+
contentType: image.file.type,
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
const queryClient = useQueryClient();
|
|
34
|
+
return useMutation({
|
|
35
|
+
mutationFn: uploadImage,
|
|
36
|
+
onSuccess: () => {
|
|
37
|
+
logger.debug(LogCategoryEnum.Info, "inside invalidate queries", imgInfo);
|
|
38
|
+
queryClient.invalidateQueries({ queryKey: [GETIMAGEPRESIGNEDURL_QUERYKEY, imgInfo?.imageKey] });
|
|
39
|
+
},
|
|
40
|
+
onError: (error) => {
|
|
41
|
+
logger.debug(LogCategoryEnum.Info, "Image Upload failed ", error);
|
|
42
|
+
toast.error("Failed in uploading Image ");
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
import { keepPreviousData, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
2
|
+
import { EnvConfig } from "../config/EnvConfig";
|
|
3
|
+
import { Client } from "../services/Client.Service";
|
|
4
|
+
import { initUserMappingDto, transformtoUserMappingDto } from "../domain/model/UserMappingDto";
|
|
5
|
+
import { initRoleMappingDto, transformtoRoleMappingDto } from "../domain/model/RoleMappingDto";
|
|
6
|
+
import { initComponentMappingDto, transformtoComponentMappingDto } from "../domain/model/ComponentMappingDto";
|
|
7
|
+
import { v4 as uuidv4 } from "uuid";
|
|
8
|
+
import { createProfile, getProfile, listProfiles, updateProfile } from "../graphql/profileQueries";
|
|
9
|
+
import { getCurrentUser } from "aws-amplify/auth";
|
|
10
|
+
import { logger } from "../util/Logger";
|
|
11
|
+
import { createBranchMutationGQL, createMapping, updateMapping } from "../customGraphQL/customMutations";
|
|
12
|
+
import { listBranchesQuery, ListBranchUserMappings, ListComponentRoleMappings, listMapping, ListUserRoleMapping, updateBranchMutationQuery } from "../customGraphQL/customQueries";
|
|
13
|
+
import { Status } from "../domain/type/StatusEnum";
|
|
14
|
+
export const MAPPING_RESOURCE = "mapping";
|
|
15
|
+
export const GET_MAPPING_BY_USERID_QUERYKEY = "mappingbyuserid";
|
|
16
|
+
export const LIST_BRANCHES_RESOURCE = "branches";
|
|
17
|
+
const endpoint = EnvConfig.appHostAPi;
|
|
18
|
+
export const transformtoMappingDto = (mappingData) => {
|
|
19
|
+
logger.info("transform to MappingDto:", mappingData);
|
|
20
|
+
const { __typename, createdAt, updatedAt, ...itm } = mappingData;
|
|
21
|
+
const transformedData = { ...itm };
|
|
22
|
+
logger.info("transformed mapping data:", transformedData);
|
|
23
|
+
return transformedData;
|
|
24
|
+
};
|
|
25
|
+
// ✅ Create Profile
|
|
26
|
+
export const createProfileFn = async (input) => {
|
|
27
|
+
if (!input.name)
|
|
28
|
+
throw new Error("name is required");
|
|
29
|
+
if (!input.email)
|
|
30
|
+
throw new Error("email is required");
|
|
31
|
+
if (!input.customId)
|
|
32
|
+
throw new Error("customId (HMS ID) is required");
|
|
33
|
+
if (!input.dob)
|
|
34
|
+
throw new Error("Date of Birth is required");
|
|
35
|
+
if (!input.contactRelation)
|
|
36
|
+
throw new Error("Contact relation is required");
|
|
37
|
+
if (!input.contactPersonName)
|
|
38
|
+
throw new Error("Contact person name is required");
|
|
39
|
+
if (!input.contactPersonNumber)
|
|
40
|
+
throw new Error("Contact person number is required");
|
|
41
|
+
if (!input.aadhaarNumber)
|
|
42
|
+
throw new Error("Aadhaar number is required");
|
|
43
|
+
const user = await getCurrentUser();
|
|
44
|
+
const currentUserId = user.username || user.userId;
|
|
45
|
+
const aadhaarFileName = input.aadhaarFile ?? "";
|
|
46
|
+
const payload = {
|
|
47
|
+
pk: uuidv4(),
|
|
48
|
+
sk: input.customId,
|
|
49
|
+
name: input.name,
|
|
50
|
+
email: input.email,
|
|
51
|
+
phoneNumber: input.phoneNumber ?? "",
|
|
52
|
+
address: input.address ?? "",
|
|
53
|
+
dob: input.dob,
|
|
54
|
+
contactRelation: input.contactRelation,
|
|
55
|
+
contactPersonName: input.contactPersonName,
|
|
56
|
+
contactPersonNumber: input.contactPersonNumber,
|
|
57
|
+
aadhaarNumber: input.aadhaarNumber,
|
|
58
|
+
aadhaarFile: aadhaarFileName, // you can upload to S3 if needed
|
|
59
|
+
isAdmin: input.isAdmin ?? false,
|
|
60
|
+
status: input.status ?? Status.Active,
|
|
61
|
+
createdDt: input.createdDt ?? new Date().toISOString(),
|
|
62
|
+
createdBy: currentUserId,
|
|
63
|
+
};
|
|
64
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
65
|
+
const response = await client.request(createProfile, { input: payload });
|
|
66
|
+
return response.createProfile;
|
|
67
|
+
};
|
|
68
|
+
// ✅ Update Profile
|
|
69
|
+
export const updateProfileFn = async (input) => {
|
|
70
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
71
|
+
const response = await client.request(updateProfile, { input });
|
|
72
|
+
return response.updateProfile;
|
|
73
|
+
};
|
|
74
|
+
// ✅ Get Profile by ID
|
|
75
|
+
export const getProfileFn = async (pk) => {
|
|
76
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
77
|
+
const response = await client.request(getProfile, { pk });
|
|
78
|
+
return response.getProfile;
|
|
79
|
+
};
|
|
80
|
+
// ✅ List All Profiles
|
|
81
|
+
export const listProfilesFn = async () => {
|
|
82
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
83
|
+
try {
|
|
84
|
+
const response = await client.request(listProfiles);
|
|
85
|
+
return response.listProfiles;
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
throw err;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
// React Query Hooks
|
|
92
|
+
export const useCreateProfileMutation = () => {
|
|
93
|
+
const queryClient = useQueryClient();
|
|
94
|
+
return useMutation({
|
|
95
|
+
mutationFn: createProfileFn,
|
|
96
|
+
onSuccess: () => {
|
|
97
|
+
queryClient.invalidateQueries({ queryKey: ["profiles"] });
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
export const useUpdateProfileMutation = () => {
|
|
102
|
+
const queryClient = useQueryClient();
|
|
103
|
+
return useMutation({
|
|
104
|
+
mutationFn: updateProfileFn,
|
|
105
|
+
onSuccess: () => {
|
|
106
|
+
queryClient.invalidateQueries({ queryKey: ["profiles"] });
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
export const useListProfiles = () => useQuery({ queryKey: ["profiles"], queryFn: listProfilesFn, });
|
|
111
|
+
export const useGetProfile = (pk) => useQuery({ queryKey: ["profile", pk], queryFn: () => getProfileFn(pk), enabled: !!pk });
|
|
112
|
+
export const getBranches = async () => {
|
|
113
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
114
|
+
const response = await client.request(listBranchesQuery);
|
|
115
|
+
return response.listBranch || [];
|
|
116
|
+
};
|
|
117
|
+
export const useListBranches = () => useQuery({
|
|
118
|
+
queryKey: [LIST_BRANCHES_RESOURCE],
|
|
119
|
+
queryFn: getBranches,
|
|
120
|
+
staleTime: 1000 * 60 * 5,
|
|
121
|
+
});
|
|
122
|
+
// ---------- API Function ----------
|
|
123
|
+
export const createBranchFn = async (input) => {
|
|
124
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
125
|
+
const branchData = {
|
|
126
|
+
pk: uuidv4(),
|
|
127
|
+
sk: input.branchName,
|
|
128
|
+
branchAddress: input.branchAddress,
|
|
129
|
+
branchContactNumber: input.branchContactNumber,
|
|
130
|
+
createdDt: new Date().toISOString(),
|
|
131
|
+
status: input.status ?? "ACTIVE",
|
|
132
|
+
};
|
|
133
|
+
const response = await client.request(createBranchMutationGQL, { input: branchData });
|
|
134
|
+
return response.createBranch;
|
|
135
|
+
};
|
|
136
|
+
// ---------- React Query Mutation Hook ----------
|
|
137
|
+
export const useCreateBranchMutation = () => {
|
|
138
|
+
const queryClient = useQueryClient();
|
|
139
|
+
return useMutation({
|
|
140
|
+
mutationFn: createBranchFn,
|
|
141
|
+
onSuccess: (data) => {
|
|
142
|
+
logger.debug("Branch mutation success", data);
|
|
143
|
+
const qkForListBranches = [LIST_BRANCHES_RESOURCE];
|
|
144
|
+
queryClient.invalidateQueries({ queryKey: qkForListBranches });
|
|
145
|
+
},
|
|
146
|
+
onError: (err) => {
|
|
147
|
+
logger.error("Branch mutation error", err);
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
// to get a user from mapping table by passing userId
|
|
152
|
+
export const getUserMappingByUserIdFun = async (userId) => {
|
|
153
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
154
|
+
const variables = {
|
|
155
|
+
filter: {
|
|
156
|
+
entity: { eq: "ROLE" },
|
|
157
|
+
userId: { eq: userId?.toUpperCase() },
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
const response = await client.request(listMapping, variables);
|
|
161
|
+
const mappingData = response.listMapping;
|
|
162
|
+
return mappingData && mappingData.length > 0
|
|
163
|
+
? transformtoUserMappingDto(mappingData[0])
|
|
164
|
+
: initUserMappingDto;
|
|
165
|
+
};
|
|
166
|
+
export const useGetUserMappingByUserId = (userId) => {
|
|
167
|
+
const { data, isLoading, error, isFetching, isSuccess } = useQuery({
|
|
168
|
+
queryKey: [GET_MAPPING_BY_USERID_QUERYKEY, userId],
|
|
169
|
+
queryFn: () => getUserMappingByUserIdFun(userId),
|
|
170
|
+
placeholderData: keepPreviousData,
|
|
171
|
+
staleTime: 1000 * 5 * 60,
|
|
172
|
+
enabled: userId !== "" && userId !== undefined,
|
|
173
|
+
});
|
|
174
|
+
return {
|
|
175
|
+
userMappingByUserId: data,
|
|
176
|
+
userMappingByUserIdError: error,
|
|
177
|
+
userMappingByUserIdLoading: isLoading,
|
|
178
|
+
userMappingByUserIdFetching: isFetching,
|
|
179
|
+
userMappingByUserIdSuccess: isSuccess,
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
// to get roles for a user from mapping table by passing userId and entity as ROLE
|
|
183
|
+
export const getRolesMappingByUserIdAndEntityFun = async (branchId, userId, entity) => {
|
|
184
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
185
|
+
const variables = {
|
|
186
|
+
pk: branchId, // ✅ branchId, not userId
|
|
187
|
+
filter: {
|
|
188
|
+
entity: { eq: entity },
|
|
189
|
+
userId: { eq: userId?.toUpperCase() },
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
const response = await client.request(listMapping, variables);
|
|
193
|
+
const mappingData = response.listMapping;
|
|
194
|
+
return mappingData?.map((itm) => transformtoRoleMappingDto(itm)) || [];
|
|
195
|
+
};
|
|
196
|
+
export const getRoleMappingByUserIdAndRoleNameFun = async (userId, roleName) => {
|
|
197
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
198
|
+
const variables = {
|
|
199
|
+
pk: userId,
|
|
200
|
+
sk: { eq: roleName }
|
|
201
|
+
};
|
|
202
|
+
const response = await client.request(listMapping, variables);
|
|
203
|
+
const mappingData = response.listMapping;
|
|
204
|
+
logger.info("list role mapping by userId and roleName fetched successfully", mappingData);
|
|
205
|
+
return mappingData && mappingData.length > 0 ? transformtoRoleMappingDto(mappingData[0]) : initRoleMappingDto;
|
|
206
|
+
};
|
|
207
|
+
// 🧠 Generic query helper
|
|
208
|
+
export const queryMappings = async (variables) => {
|
|
209
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
210
|
+
const response = await client.request(listMapping, variables);
|
|
211
|
+
logger.info("Fetched mapping data", response);
|
|
212
|
+
return response.listMapping || [];
|
|
213
|
+
};
|
|
214
|
+
export const getUserComponents = async (branchId, userId) => {
|
|
215
|
+
const userRoles = await queryMappings({
|
|
216
|
+
pk: branchId,
|
|
217
|
+
filter: {
|
|
218
|
+
entity: { eq: "ROLE" },
|
|
219
|
+
userId: { eq: userId },
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
const roleComponentsPromises = userRoles.map((r) => queryMappings({
|
|
223
|
+
pk: branchId,
|
|
224
|
+
filter: {
|
|
225
|
+
entity: { eq: "COMPONENT" },
|
|
226
|
+
roleName: { eq: r.roleName },
|
|
227
|
+
},
|
|
228
|
+
}));
|
|
229
|
+
const roleComponentsArrays = await Promise.all(roleComponentsPromises);
|
|
230
|
+
return roleComponentsArrays.flat();
|
|
231
|
+
};
|
|
232
|
+
// to get a component for a role from mapping table by passing roleId and componentId
|
|
233
|
+
export const getCompoMappingByRoleIdAndCompoIdFun = async (roleId, componentId) => {
|
|
234
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
235
|
+
const variables = {
|
|
236
|
+
pk: roleId,
|
|
237
|
+
sk: { eq: componentId }
|
|
238
|
+
};
|
|
239
|
+
const response = await client.request(listMapping, variables);
|
|
240
|
+
const mappingData = response.listMapping;
|
|
241
|
+
logger.info("list component mapping by roleId and componentId fetched successfully", mappingData);
|
|
242
|
+
return mappingData && mappingData.length > 0 ? transformtoComponentMappingDto(mappingData[0]) : initComponentMappingDto;
|
|
243
|
+
};
|
|
244
|
+
export const getCompoMappingByRoleIdAndEntityFun = async (branchId, roleId) => {
|
|
245
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
246
|
+
const variables = {
|
|
247
|
+
pk: branchId,
|
|
248
|
+
filter: {
|
|
249
|
+
entity: { eq: "COMPONENT" }, // must match table column
|
|
250
|
+
roleId: { eq: roleId }, // must match roleId in table
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
const response = await client.request(listMapping, variables);
|
|
254
|
+
const mappingData = response.listMapping;
|
|
255
|
+
logger.info('list component mapping by roleId and entity fetched successfully', mappingData);
|
|
256
|
+
return mappingData?.length
|
|
257
|
+
? mappingData.map((itm) => transformtoComponentMappingDto(itm))
|
|
258
|
+
: [];
|
|
259
|
+
};
|
|
260
|
+
export const getComponentsByRoleOnly = async (roleId) => {
|
|
261
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
262
|
+
const variables = {
|
|
263
|
+
filter: {
|
|
264
|
+
entity: { eq: "COMPONENT" },
|
|
265
|
+
roleId: { eq: roleId },
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
const response = await client.request(listMapping, variables);
|
|
269
|
+
const mappingData = response.listMapping;
|
|
270
|
+
return mappingData?.map((itm) => transformtoComponentMappingDto(itm)) || [];
|
|
271
|
+
};
|
|
272
|
+
//-------------------- Mapping Mutations -------------------------
|
|
273
|
+
export const useCreateMappingMutation = () => {
|
|
274
|
+
async function createMappingFn(mappingData) {
|
|
275
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
276
|
+
const input = {
|
|
277
|
+
...mappingData,
|
|
278
|
+
};
|
|
279
|
+
const response = await client.request(createMapping, { input });
|
|
280
|
+
logger.info("Mapping posted successfully", response);
|
|
281
|
+
return response;
|
|
282
|
+
}
|
|
283
|
+
const queryClient = useQueryClient();
|
|
284
|
+
return useMutation({
|
|
285
|
+
mutationFn: createMappingFn,
|
|
286
|
+
onSuccess: (_data, variables) => {
|
|
287
|
+
const queryKeyForMappingByUserId = [GET_MAPPING_BY_USERID_QUERYKEY, variables.pk];
|
|
288
|
+
queryClient.invalidateQueries({ queryKey: queryKeyForMappingByUserId });
|
|
289
|
+
},
|
|
290
|
+
});
|
|
291
|
+
};
|
|
292
|
+
export const useUpdateMappingMutation = () => {
|
|
293
|
+
async function updateMappingFn(mappingData) {
|
|
294
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
295
|
+
const input = mappingData;
|
|
296
|
+
const response = await client.request(updateMapping, { input: input, });
|
|
297
|
+
logger.info("Mapping updated successfully", response);
|
|
298
|
+
return response;
|
|
299
|
+
}
|
|
300
|
+
const queryClient = useQueryClient();
|
|
301
|
+
return useMutation({
|
|
302
|
+
mutationFn: updateMappingFn,
|
|
303
|
+
onSuccess: (_data, variables) => {
|
|
304
|
+
const queryKeyForMappingByUserId = [GET_MAPPING_BY_USERID_QUERYKEY, variables.pk];
|
|
305
|
+
queryClient.invalidateQueries({ queryKey: queryKeyForMappingByUserId });
|
|
306
|
+
queryClient.invalidateQueries({ queryKey: [LIST_USER_ROLE_MAPPING_KEY] });
|
|
307
|
+
queryClient.invalidateQueries({ queryKey: [LIST_COMPONENT_ROLE_MAPPING_KEY], });
|
|
308
|
+
},
|
|
309
|
+
});
|
|
310
|
+
};
|
|
311
|
+
export const getBranchIdByUserId = async (userId) => {
|
|
312
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
313
|
+
const filter = {
|
|
314
|
+
entity: { eq: "USER" },
|
|
315
|
+
userId: { eq: userId },
|
|
316
|
+
status: { eq: "ACTIVE" },
|
|
317
|
+
};
|
|
318
|
+
try {
|
|
319
|
+
const response = await client.request(`
|
|
320
|
+
query ListMappingForUsers($pk: String, $filter: ModelMappingFilterInput) {
|
|
321
|
+
listMapping(pk: $pk, filter: $filter) {
|
|
322
|
+
pk
|
|
323
|
+
userId
|
|
324
|
+
entity
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
`, { pk: null, filter });
|
|
328
|
+
const mappingData = response.listMapping;
|
|
329
|
+
if (mappingData && mappingData.length > 0) {
|
|
330
|
+
return mappingData.map(item => item.pk);
|
|
331
|
+
}
|
|
332
|
+
return [];
|
|
333
|
+
}
|
|
334
|
+
catch (err) {
|
|
335
|
+
logger.error("Error fetching branch for user", err);
|
|
336
|
+
return [];
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
export const getBranchNameById = async (branchId) => {
|
|
340
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
341
|
+
try {
|
|
342
|
+
const response = await client.request(listBranchesQuery);
|
|
343
|
+
// Remove "BRANCH#" prefix if exists
|
|
344
|
+
const cleanBranchId = branchId.replace(/^BRANCH#/, "");
|
|
345
|
+
const branch = response.listBranch.find(b => b.pk === cleanBranchId);
|
|
346
|
+
return branch?.sk || "User is not assigned to any branch. Please assign a branch.";
|
|
347
|
+
}
|
|
348
|
+
catch (err) {
|
|
349
|
+
logger.error("Error fetching branch name", err);
|
|
350
|
+
return "Unknown Branch";
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
// ---------- Update Branch Function ----------
|
|
354
|
+
export const updateBranchFn = async (input) => {
|
|
355
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
356
|
+
const response = await client.request(updateBranchMutationQuery, { input });
|
|
357
|
+
return response.updateBranch;
|
|
358
|
+
};
|
|
359
|
+
// ---------- React Query Mutation Hook ----------
|
|
360
|
+
export const useUpdateBranchMutation = () => {
|
|
361
|
+
const queryClient = useQueryClient();
|
|
362
|
+
return useMutation({
|
|
363
|
+
mutationFn: updateBranchFn,
|
|
364
|
+
onSuccess: () => {
|
|
365
|
+
queryClient.invalidateQueries({ queryKey: [LIST_BRANCHES_RESOURCE] });
|
|
366
|
+
},
|
|
367
|
+
});
|
|
368
|
+
};
|
|
369
|
+
export const fetchBranchUserMappings = async (branchesMap) => {
|
|
370
|
+
const endpoint = EnvConfig.appHostAPi;
|
|
371
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
372
|
+
const response = await client.request(ListBranchUserMappings);
|
|
373
|
+
return response.listMapping.map((m) => {
|
|
374
|
+
const transformed = transformtoMappingDto(m);
|
|
375
|
+
return {
|
|
376
|
+
pk: transformed.pk,
|
|
377
|
+
sk: transformed.sk,
|
|
378
|
+
branchName: branchesMap[transformed.pk.replace(/^BRANCH#/, "")] || transformed.pk,
|
|
379
|
+
userId: transformed.userId,
|
|
380
|
+
userName: transformed.userName,
|
|
381
|
+
status: transformed.status?.toUpperCase() === "INACTIVE" ? Status.Inactive : Status.Active,
|
|
382
|
+
createdDt: transformed.createdDt,
|
|
383
|
+
disabledDt: transformed.disabledDt || undefined,
|
|
384
|
+
};
|
|
385
|
+
});
|
|
386
|
+
};
|
|
387
|
+
export const fetchUserRoleMappings = async () => {
|
|
388
|
+
const endpoint = EnvConfig.appHostAPi;
|
|
389
|
+
const client = await Client.getCustomGraphqlClient(endpoint);
|
|
390
|
+
const response = await client.request(ListUserRoleMapping);
|
|
391
|
+
return response.listMapping.map(m => ({
|
|
392
|
+
...m,
|
|
393
|
+
status: m.status
|
|
394
|
+
}));
|
|
395
|
+
};
|
|
396
|
+
export const LIST_USER_ROLE_MAPPING_KEY = "userRoleMappings";
|
|
397
|
+
export const useUserRoleMappings = () => {
|
|
398
|
+
return useQuery({
|
|
399
|
+
queryKey: ["userRoleMappings"],
|
|
400
|
+
queryFn: fetchUserRoleMappings,
|
|
401
|
+
staleTime: 1000 * 60 * 5,
|
|
402
|
+
});
|
|
403
|
+
};
|
|
404
|
+
export const fetchComponentRoleMappings = async () => {
|
|
405
|
+
const client = await Client.getCustomGraphqlClient(EnvConfig.appHostAPi);
|
|
406
|
+
const response = await client.request(ListComponentRoleMappings);
|
|
407
|
+
return response.listMapping.map((m) => {
|
|
408
|
+
const transformed = transformtoMappingDto(m);
|
|
409
|
+
return {
|
|
410
|
+
pk: transformed.pk,
|
|
411
|
+
sk: transformed.sk,
|
|
412
|
+
roleName: transformed.roleName,
|
|
413
|
+
componentTitle: transformed.componentTitle,
|
|
414
|
+
status: transformed.status?.toUpperCase() === "INACTIVE"
|
|
415
|
+
? Status.Inactive
|
|
416
|
+
: Status.Active,
|
|
417
|
+
createdDt: transformed.createdDt,
|
|
418
|
+
disabledDt: transformed.disabledDt || undefined,
|
|
419
|
+
};
|
|
420
|
+
});
|
|
421
|
+
};
|
|
422
|
+
export const LIST_COMPONENT_ROLE_MAPPING_KEY = "component-role-mapping";
|
|
423
|
+
export const useListComponentRoleMappings = () => useQuery({
|
|
424
|
+
queryKey: [LIST_COMPONENT_ROLE_MAPPING_KEY],
|
|
425
|
+
queryFn: fetchComponentRoleMappings,
|
|
426
|
+
staleTime: 1000 * 60 * 5,
|
|
427
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { Suspense, useContext } from 'react';
|
|
3
|
+
import AppContext from '../../store/AppContext';
|
|
4
|
+
const RemoteAmenityForm = React.lazy(() => import("bookingUIApp/AmenityForm"));
|
|
5
|
+
const AmenityForm = () => {
|
|
6
|
+
const { user } = useContext(AppContext) ?? { user: undefined };
|
|
7
|
+
const rawBranch = user?.branchId ?? "";
|
|
8
|
+
const parts = rawBranch.split("#");
|
|
9
|
+
const branchId = parts[1];
|
|
10
|
+
const isSuperAdmin = user?.roles?.includes("SUPERADMIN") ?? false;
|
|
11
|
+
return (_jsx("div", { children: _jsx(Suspense, { children: _jsx(RemoteAmenityForm, { branchId: branchId, isSuperAdmin: isSuperAdmin, classNames: {
|
|
12
|
+
fontTitle: "font-title",
|
|
13
|
+
fontLabel: "font-label",
|
|
14
|
+
formGroup: "form-group",
|
|
15
|
+
buttonPrimary: "btn-primary-global",
|
|
16
|
+
buttonSecondary: "btn-secondary-global"
|
|
17
|
+
} }) }) }));
|
|
18
|
+
};
|
|
19
|
+
export default AmenityForm;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { Suspense, useContext } from "react";
|
|
3
|
+
import AppContext from "../../store/AppContext";
|
|
4
|
+
import logo from "../../../src/assets/images/Hotel-Logo.jpg";
|
|
5
|
+
const RemoteBillingManagement = React.lazy(() => import("bookingUIApp/BillingManagement"));
|
|
6
|
+
const BillingManagement = () => {
|
|
7
|
+
const { user } = useContext(AppContext) ?? { user: undefined };
|
|
8
|
+
const rawBranch = user?.branchId ?? "";
|
|
9
|
+
const parts = rawBranch.split("#");
|
|
10
|
+
const branchId = parts[1] ?? "";
|
|
11
|
+
return (_jsx("div", { children: _jsx(Suspense, { children: _jsx(RemoteBillingManagement, { branchId: branchId, logoUrl: logo, classNames: {
|
|
12
|
+
fontTitle: "font-title",
|
|
13
|
+
buttonPrimary: "btn-primary-global",
|
|
14
|
+
card: "card shadow-lg border-0",
|
|
15
|
+
} }) }) }));
|
|
16
|
+
};
|
|
17
|
+
export default BillingManagement;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { Suspense, useContext } from 'react';
|
|
3
|
+
import AppContext from '../../store/AppContext';
|
|
4
|
+
const RemoteCreateRoomForm = React.lazy(() => import("bookingUIApp/CreateRoomForm"));
|
|
5
|
+
const CreateRoomForm = () => {
|
|
6
|
+
const { user } = useContext(AppContext) ?? { user: undefined };
|
|
7
|
+
const rawBranch = user?.branchId ?? "";
|
|
8
|
+
const parts = rawBranch.split("#");
|
|
9
|
+
const branchId = parts[1];
|
|
10
|
+
const isSuperAdmin = user?.roles?.includes("SUPERADMIN") ?? false;
|
|
11
|
+
return (_jsx("div", { children: _jsx(Suspense, { children: _jsx(RemoteCreateRoomForm, { branchId: branchId, isSuperAdmin: isSuperAdmin, classNames: {
|
|
12
|
+
fontTitle: "font-title",
|
|
13
|
+
fontLabel: "font-label",
|
|
14
|
+
formGroup: "form-group",
|
|
15
|
+
buttonPrimary: "btn-primary-global",
|
|
16
|
+
buttonSecondary: "btn-secondary-global"
|
|
17
|
+
} }) }) }));
|
|
18
|
+
};
|
|
19
|
+
export default CreateRoomForm;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { Suspense, useContext } from 'react';
|
|
3
|
+
import AppContext from '../../store/AppContext';
|
|
4
|
+
const RemoteExtraRequirementForm = React.lazy(() => import("bookingUIApp/ExtraRequirementForm"));
|
|
5
|
+
const ExtraRequirementForm = () => {
|
|
6
|
+
const { user } = useContext(AppContext) ?? { user: undefined };
|
|
7
|
+
const rawBranch = user?.branchId ?? "";
|
|
8
|
+
const parts = rawBranch.split("#");
|
|
9
|
+
const branchId = parts[1];
|
|
10
|
+
const isSuperAdmin = user?.roles?.includes("SUPERADMIN") ?? false;
|
|
11
|
+
return (_jsx("div", { children: _jsx(Suspense, { children: _jsx(RemoteExtraRequirementForm, { branchId: branchId, isSuperAdmin: isSuperAdmin, classNames: {
|
|
12
|
+
fontTitle: "font-title",
|
|
13
|
+
fontLabel: "font-label",
|
|
14
|
+
formGroup: "form-group",
|
|
15
|
+
buttonPrimary: "btn-primary-global",
|
|
16
|
+
buttonSecondary: "btn-secondary-global"
|
|
17
|
+
} }) }) }));
|
|
18
|
+
};
|
|
19
|
+
export default ExtraRequirementForm;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { Suspense, useContext } from 'react';
|
|
3
|
+
import AppContext from '../../store/AppContext';
|
|
4
|
+
const RemoteReservationForm = React.lazy(() => import("bookingUIApp/ReservationForm"));
|
|
5
|
+
const ReservationForm = () => {
|
|
6
|
+
const { user } = useContext(AppContext) ?? { user: undefined };
|
|
7
|
+
const rawBranch = user?.branchId ?? "";
|
|
8
|
+
const parts = rawBranch.split("#");
|
|
9
|
+
const branchId = parts[1];
|
|
10
|
+
return (_jsx("div", { children: _jsx(Suspense, { children: _jsx(RemoteReservationForm, { branchId: branchId, classNames: {
|
|
11
|
+
fontTitle: "font-title",
|
|
12
|
+
fontLabel: "font-label",
|
|
13
|
+
formGroup: "form-group",
|
|
14
|
+
buttonPrimary: "btn-primary-global",
|
|
15
|
+
buttonSecondary: "btn-secondary-global"
|
|
16
|
+
} }) }) }));
|
|
17
|
+
};
|
|
18
|
+
export default ReservationForm;
|