@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.
Files changed (213) hide show
  1. package/dist/App.js +83 -0
  2. package/dist/AppHostProvider.js +4 -0
  3. package/dist/AppHostRoutes.js +7 -0
  4. package/dist/api/image-api.js +45 -0
  5. package/dist/api/mapping-api.js +427 -0
  6. package/dist/bookingModule/components/AmenityForm.js +19 -0
  7. package/dist/bookingModule/components/BillingManagement.js +17 -0
  8. package/dist/bookingModule/components/CreateRoomForm.js +19 -0
  9. package/dist/bookingModule/components/ExtraRequirementForm.js +19 -0
  10. package/dist/bookingModule/components/ReservationForm.js +18 -0
  11. package/dist/bookingModule/components/RoomCategoryForm.js +19 -0
  12. package/dist/bookingModule/components/RoomCategoryPriceForm.js +20 -0
  13. package/dist/bookingModule/components/RoomExtraRequirementCapture.js +18 -0
  14. package/dist/bookingModule/components/RoomFacilityForm.js +19 -0
  15. package/dist/bookingModule/components/RoomReservationAction.js +18 -0
  16. package/dist/components/Home/Home.js +14 -0
  17. package/dist/components/Loader/Loader.js +5 -0
  18. package/dist/components/Login/Login.js +149 -0
  19. package/dist/components/Login/loginSchema.js +41 -0
  20. package/dist/components/Mappings/BranchMapping/Branch.js +135 -0
  21. package/dist/components/Mappings/BranchMapping/BranchTableColumns.js +21 -0
  22. package/dist/components/Mappings/BranchMapping/MappingFormBranchUser.js +150 -0
  23. package/dist/components/Mappings/BranchMapping/MappingTableColumns.js +29 -0
  24. package/dist/components/Mappings/BranchMapping/branchSchema.js +34 -0
  25. package/dist/components/Mappings/ComponentMapping/ComponentRoleMapping.js +98 -0
  26. package/dist/components/Mappings/ComponentMapping/componentRoleColumns.js +29 -0
  27. package/dist/components/Mappings/MappingForm/MappingForm.js +142 -0
  28. package/dist/components/Mappings/MappingForm/mappingSchema.js +32 -0
  29. package/dist/components/Mappings/RoleMapping/MappingFormUserRole.js +194 -0
  30. package/dist/components/Mappings/RoleMapping/UserRoleTableColumns.js +33 -0
  31. package/dist/components/NavBar/Sidebar.js +56 -0
  32. package/dist/components/ProfileForm/ProfileForm.js +190 -0
  33. package/dist/components/ProfileForm/ProfileList.js +33 -0
  34. package/dist/components/ProfileForm/profileColumns.js +67 -0
  35. package/dist/components/ProfileForm/profileSchema.js +50 -0
  36. package/dist/components/SettingsPage/SettingsPage.js +240 -0
  37. package/dist/components/api/settings-api.js +131 -0
  38. package/dist/components/common/Form/FormActionButtons.js +6 -0
  39. package/dist/components/common/Form/FormLabel.js +6 -0
  40. package/dist/components/common/ListTable/ListHeader.js +5 -0
  41. package/dist/components/common/ListTable/ListTable.js +31 -0
  42. package/dist/components/common/Modal/Modal.js +6 -0
  43. package/dist/config/EnvConfig.js +13 -0
  44. package/dist/config/amplifyConfig.js +45 -0
  45. package/dist/configureAppHost.js +5 -0
  46. package/dist/customGraphQL/customMutations.js +53 -0
  47. package/dist/customGraphQL/customQueries.js +104 -0
  48. package/dist/domain/input/input-types.js +1 -0
  49. package/dist/domain/model/BranchDto.js +8 -0
  50. package/dist/domain/model/ComponentMappingDto.js +19 -0
  51. package/dist/domain/model/MappingDto.js +16 -0
  52. package/dist/domain/model/PrefixDescriptionDto.js +13 -0
  53. package/dist/domain/model/ProfileDto.js +20 -0
  54. package/dist/domain/model/RoleMappingDto.js +19 -0
  55. package/dist/domain/model/SettingsDto.js +7 -0
  56. package/dist/domain/model/UserMappingDto.js +28 -0
  57. package/dist/domain/model/imageDto.js +1 -0
  58. package/dist/domain/type/EntityTypes.js +6 -0
  59. package/dist/domain/type/MappingOptions.js +1 -0
  60. package/dist/domain/type/MappingTypes.js +7 -0
  61. package/dist/domain/type/Nullable.js +1 -0
  62. package/dist/domain/type/ResettingPeriodOptions.js +8 -0
  63. package/dist/domain/type/RolesEnum.js +7 -0
  64. package/dist/domain/type/SelectType.js +1 -0
  65. package/dist/domain/type/StatusEnum.js +6 -0
  66. package/dist/domain/type/signUpOptions.js +4 -0
  67. package/dist/domain/type/statusOptions.js +4 -0
  68. package/dist/graphql/profileQueries.js +89 -0
  69. package/dist/hoc/withSyzyAuth.js +87 -0
  70. package/dist/hooks/useCurrentUser.js +6 -0
  71. package/dist/hooks/useDispatch.js +7 -0
  72. package/dist/hooks/usePermission.js +7 -0
  73. package/dist/index.js +3 -15
  74. package/dist/main.js +60 -0
  75. package/dist/services/Client.Service.js +96 -0
  76. package/dist/services/Storage-service.js +26 -0
  77. package/dist/services/navigationMenu.js +9 -0
  78. package/dist/static/constants.js +34 -0
  79. package/dist/store/AppAction.js +5 -0
  80. package/dist/store/AppContext.js +3 -0
  81. package/dist/store/AppContextType.js +6 -0
  82. package/dist/store/AppProvider.js +32 -0
  83. package/dist/store/HostedInContainerContext.js +11 -0
  84. package/dist/store/SesssionReducer.js +16 -0
  85. package/dist/types/App.d.ts +4 -0
  86. package/dist/types/AppHostProvider.d.ts +6 -0
  87. package/dist/types/AppHostRoutes.d.ts +1 -0
  88. package/dist/types/api/image-api.d.ts +8 -0
  89. package/dist/types/api/mapping-api.d.ts +80 -0
  90. package/dist/types/bookingModule/components/AmenityForm.d.ts +3 -0
  91. package/dist/types/bookingModule/components/BillingManagement.d.ts +3 -0
  92. package/dist/types/bookingModule/components/CreateRoomForm.d.ts +3 -0
  93. package/dist/types/bookingModule/components/ExtraRequirementForm.d.ts +3 -0
  94. package/dist/types/bookingModule/components/ReservationForm.d.ts +3 -0
  95. package/dist/types/bookingModule/components/RoomCategoryForm.d.ts +3 -0
  96. package/dist/types/bookingModule/components/RoomCategoryPriceForm.d.ts +3 -0
  97. package/dist/types/bookingModule/components/RoomExtraRequirementCapture.d.ts +3 -0
  98. package/dist/types/bookingModule/components/RoomFacilityForm.d.ts +3 -0
  99. package/dist/types/bookingModule/components/RoomReservationAction.d.ts +3 -0
  100. package/dist/types/components/Home/Home.d.ts +3 -0
  101. package/dist/types/components/Loader/Loader.d.ts +2 -0
  102. package/dist/types/components/Login/Login.d.ts +7 -0
  103. package/dist/types/components/Login/loginSchema.d.ts +27 -0
  104. package/dist/types/components/Mappings/BranchMapping/Branch.d.ts +5 -0
  105. package/dist/types/components/Mappings/BranchMapping/BranchTableColumns.d.ts +10 -0
  106. package/dist/types/components/Mappings/BranchMapping/MappingFormBranchUser.d.ts +3 -0
  107. package/dist/types/components/Mappings/BranchMapping/MappingTableColumns.d.ts +14 -0
  108. package/dist/types/components/Mappings/BranchMapping/branchSchema.d.ts +37 -0
  109. package/dist/types/components/Mappings/ComponentMapping/ComponentRoleMapping.d.ts +3 -0
  110. package/dist/types/components/Mappings/ComponentMapping/componentRoleColumns.d.ts +3 -0
  111. package/dist/types/components/Mappings/MappingForm/MappingForm.d.ts +35 -0
  112. package/dist/types/components/Mappings/MappingForm/mappingSchema.d.ts +23 -0
  113. package/dist/types/components/Mappings/RoleMapping/MappingFormUserRole.d.ts +5 -0
  114. package/dist/types/components/Mappings/RoleMapping/UserRoleTableColumns.d.ts +3 -0
  115. package/dist/types/components/NavBar/Sidebar.d.ts +4 -0
  116. package/dist/types/components/ProfileForm/ProfileForm.d.ts +3 -0
  117. package/dist/types/components/ProfileForm/ProfileList.d.ts +3 -0
  118. package/dist/types/components/ProfileForm/profileColumns.d.ts +3 -0
  119. package/dist/types/components/ProfileForm/profileSchema.d.ts +52 -0
  120. package/dist/types/components/SettingsPage/SettingsPage.d.ts +3 -0
  121. package/dist/types/components/api/settings-api.d.ts +26 -0
  122. package/dist/types/components/common/Form/FormActionButtons.d.ts +11 -0
  123. package/dist/types/components/common/Form/FormLabel.d.ts +8 -0
  124. package/dist/types/components/common/ListTable/ListHeader.d.ts +8 -0
  125. package/dist/types/components/common/ListTable/ListTable.d.ts +17 -0
  126. package/dist/types/components/common/Modal/Modal.d.ts +11 -0
  127. package/dist/types/config/EnvConfig.d.ts +13 -0
  128. package/dist/types/config/amplifyConfig.d.ts +1 -0
  129. package/dist/types/configureAppHost.d.ts +6 -0
  130. package/dist/types/customGraphQL/customMutations.d.ts +3 -0
  131. package/dist/types/customGraphQL/customQueries.d.ts +7 -0
  132. package/dist/types/domain/input/input-types.d.ts +47 -0
  133. package/dist/types/domain/model/BranchDto.d.ts +9 -0
  134. package/dist/types/domain/model/ComponentMappingDto.d.ts +24 -0
  135. package/dist/types/domain/model/MappingDto.d.ts +30 -0
  136. package/dist/types/domain/model/PrefixDescriptionDto.d.ts +16 -0
  137. package/dist/types/domain/model/ProfileDto.d.ts +21 -0
  138. package/dist/types/domain/model/RoleMappingDto.d.ts +14 -0
  139. package/dist/types/domain/model/SettingsDto.d.ts +8 -0
  140. package/dist/types/domain/model/UserMappingDto.d.ts +14 -0
  141. package/dist/types/domain/model/imageDto.d.ts +4 -0
  142. package/dist/types/domain/type/EntityTypes.d.ts +5 -0
  143. package/dist/types/domain/type/MappingOptions.d.ts +5 -0
  144. package/dist/types/domain/type/MappingTypes.d.ts +6 -0
  145. package/dist/types/domain/type/Nullable.d.ts +13 -0
  146. package/dist/types/domain/type/ResettingPeriodOptions.d.ts +2 -0
  147. package/dist/types/domain/type/RolesEnum.d.ts +6 -0
  148. package/dist/types/domain/type/SelectType.d.ts +16 -0
  149. package/dist/types/domain/type/StatusEnum.d.ts +5 -0
  150. package/dist/types/domain/type/signUpOptions.d.ts +2 -0
  151. package/dist/types/domain/type/statusOptions.d.ts +2 -0
  152. package/dist/types/graphql/profileQueries.d.ts +4 -0
  153. package/dist/types/hoc/withSyzyAuth.d.ts +2 -0
  154. package/dist/types/hooks/useCurrentUser.d.ts +3 -0
  155. package/dist/types/hooks/useDispatch.d.ts +3 -0
  156. package/dist/types/hooks/usePermission.d.ts +1 -0
  157. package/dist/types/index.d.ts +3 -0
  158. package/dist/types/main.d.ts +4 -0
  159. package/dist/types/services/Client.Service.d.ts +12 -0
  160. package/dist/types/services/Storage-service.d.ts +2 -0
  161. package/dist/types/services/navigationMenu.d.ts +1 -0
  162. package/dist/types/static/constants.d.ts +34 -0
  163. package/dist/types/store/AppAction.d.ts +11 -0
  164. package/dist/types/store/AppContext.d.ts +3 -0
  165. package/dist/types/store/AppContextType.d.ts +12 -0
  166. package/dist/types/store/AppProvider.d.ts +7 -0
  167. package/dist/types/store/HostedInContainerContext.d.ts +5 -0
  168. package/dist/types/store/SesssionReducer.d.ts +4 -0
  169. package/dist/types/types.d.ts +26 -0
  170. package/dist/types/util/AuthUtils.d.ts +1 -0
  171. package/dist/types/util/LogEnum.d.ts +6 -0
  172. package/dist/types/util/Logger.d.ts +6 -0
  173. package/dist/types/util/SyzyDate.d.ts +69 -0
  174. package/dist/types/util/dateUtils.d.ts +10 -0
  175. package/dist/types/util/hostedinContainer.d.ts +1 -0
  176. package/dist/types/util/model-types.d.ts +96 -0
  177. package/dist/types/util/prefixAndResettingValidation.d.ts +9 -0
  178. package/dist/types/util/transformToData.d.ts +1 -0
  179. package/dist/types.js +14 -0
  180. package/dist/util/AuthUtils.js +10 -0
  181. package/dist/util/LogEnum.js +7 -0
  182. package/dist/util/Logger.js +18 -0
  183. package/dist/util/SyzyDate.js +265 -0
  184. package/dist/util/dateUtils.js +24 -0
  185. package/dist/util/hostedinContainer.js +9 -0
  186. package/dist/util/model-types.js +18 -0
  187. package/dist/util/prefixAndResettingValidation.js +54 -0
  188. package/dist/util/transformToData.js +9 -0
  189. package/package.json +14 -9
  190. package/dist/__federation_shared_@tanstack/react-query-DHuUsaNz.js +0 -2517
  191. package/dist/__federation_shared_react-CikWE6qG.js +0 -7
  192. package/dist/__federation_shared_react-bootstrap-BKlZRvMR.js +0 -7516
  193. package/dist/__federation_shared_react-dom-vrQ70Ay8.js +0 -372
  194. package/dist/__federation_shared_react-router-dom-BKminmS4.js +0 -10448
  195. package/dist/__federation_shared_react-select-B6kehBDI.js +0 -4056
  196. package/dist/__federation_shared_react-toastify-B0S0UGr3.js +0 -412
  197. package/dist/_commonjsHelpers-C6fGbg64.js +0 -6
  198. package/dist/_virtual___federation_fn_import-XZCKozko.js +0 -217
  199. package/dist/favicon.ico +0 -0
  200. package/dist/index-DgtWMtjZ.js +0 -184
  201. package/dist/index-eZknuYwc.js +0 -1219
  202. package/dist/jsx-runtime-D_t4bG-_.js +0 -264
  203. package/dist/manifest.webmanifest +0 -1
  204. package/dist/pwa/Hotel-icon.jpg +0 -0
  205. package/dist/pwa/apple-touch-icon-180x180.png +0 -0
  206. package/dist/pwa/favicon.ico +0 -0
  207. package/dist/pwa/maskable-icon-512x512.png +0 -0
  208. package/dist/pwa/pwa-192x192.png +0 -0
  209. package/dist/pwa/pwa-512x512.png +0 -0
  210. package/dist/pwa/pwa-64x64.png +0 -0
  211. package/dist/registerSW.js +0 -1
  212. package/dist/sw.js +0 -1
  213. package/dist/workbox-1ef09536.js +0 -1
@@ -0,0 +1,89 @@
1
+ // src/graphql/profileQueries.ts
2
+ export const createProfile = /* GraphQL */ `
3
+ mutation CreateProfile($input: ProfileInput!) {
4
+ createProfile(input: $input) {
5
+ pk
6
+ sk
7
+ name
8
+ email
9
+ phoneNumber
10
+ address
11
+ dob
12
+ contactRelation
13
+ contactPersonName
14
+ contactPersonNumber
15
+ aadhaarNumber
16
+ aadhaarFile
17
+ isAdmin
18
+ status
19
+ createdDt
20
+ createdBy
21
+ }
22
+ }
23
+ `;
24
+ export const updateProfile = /* GraphQL */ `
25
+ mutation UpdateProfile($input: ProfileInput!) {
26
+ updateProfile(input: $input) {
27
+ pk
28
+ sk
29
+ name
30
+ email
31
+ phoneNumber
32
+ address
33
+ dob
34
+ contactRelation
35
+ contactPersonName
36
+ contactPersonNumber
37
+ aadhaarNumber
38
+ aadhaarFile
39
+ isAdmin
40
+ status
41
+ createdDt
42
+ createdBy
43
+ }
44
+ }
45
+ `;
46
+ export const listProfiles = /* GraphQL */ `
47
+ query ListProfiles {
48
+ listProfiles {
49
+ pk
50
+ sk
51
+ name
52
+ email
53
+ phoneNumber
54
+ address
55
+ dob
56
+ contactRelation
57
+ contactPersonName
58
+ contactPersonNumber
59
+ aadhaarNumber
60
+ aadhaarFile
61
+ isAdmin
62
+ status
63
+ createdDt
64
+ createdBy
65
+ }
66
+ }
67
+ `;
68
+ export const getProfile = /* GraphQL */ `
69
+ query GetProfile($pk: ID!) {
70
+ getProfile(pk: $pk) {
71
+ pk
72
+ sk
73
+ name
74
+ email
75
+ phoneNumber
76
+ address
77
+ dob
78
+ contactRelation
79
+ contactPersonName
80
+ contactPersonNumber
81
+ aadhaarNumber
82
+ aadhaarFile
83
+ isAdmin
84
+ status
85
+ createdDt
86
+ createdBy
87
+ }
88
+ }
89
+ `;
@@ -0,0 +1,87 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useContext, useEffect, useState } from "react";
3
+ import AppContext from "../store/AppContext";
4
+ import LoginForm from "../components/Login/Login";
5
+ import { getCurrentUser } from "aws-amplify/auth";
6
+ import { AppActionEnum } from "../store/AppAction";
7
+ import './withSyzyAuth.css';
8
+ import { Client } from "../services/Client.Service";
9
+ import { fetchAuthSession } from 'aws-amplify/auth';
10
+ import { getComponentsByRoleOnly, getRolesMappingByUserIdAndEntityFun, useGetUserMappingByUserId } from "../api/mapping-api";
11
+ import { EntityTypes } from "../domain/type/EntityTypes";
12
+ import { Status } from "../domain/type/StatusEnum";
13
+ export function withSyzyAuth(WrappedComponent) {
14
+ const ComponentWithAuthenticator = (props) => {
15
+ const [currentUser, setCurrentUser] = useState();
16
+ const { user, dispatch } = useContext(AppContext) || { user: undefined, allowedComponents: undefined, dispatch: undefined };
17
+ const [_isLoggedIn, setIsLoggedIn] = useState(false);
18
+ const [_emailVerifiedStatus, setEmailVerifiedStatus] = useState("");
19
+ const [isSessionReady, setIsSessionReady] = useState(false);
20
+ useEffect(() => {
21
+ if (!user?.userName) {
22
+ setCurrentUser(null);
23
+ setIsSessionReady(false);
24
+ }
25
+ }, [user]);
26
+ const fetchSession = async () => {
27
+ try {
28
+ const session = await getCurrentUser();
29
+ const userInfo = await fetchAuthSession({ forceRefresh: true });
30
+ setEmailVerifiedStatus(userInfo.tokens?.idToken?.payload.email_verified?.toString() ?? "");
31
+ if (session) {
32
+ const userId = session.signInDetails?.loginId ?? session.username;
33
+ setCurrentUser(userId);
34
+ }
35
+ else {
36
+ setCurrentUser(null);
37
+ }
38
+ }
39
+ catch (err) {
40
+ setCurrentUser(null);
41
+ }
42
+ };
43
+ useEffect(() => {
44
+ fetchSession();
45
+ }, []);
46
+ useEffect(() => {
47
+ const stopResetScheduler = Client.startClientResetScheduler();
48
+ return () => stopResetScheduler();
49
+ }, []);
50
+ useEffect(() => {
51
+ setIsLoggedIn(!!user?.userName);
52
+ }, [user]);
53
+ const { userMappingByUserId } = useGetUserMappingByUserId(currentUser ?? "");
54
+ useEffect(() => {
55
+ const updateSession = async () => {
56
+ if (!currentUser)
57
+ return;
58
+ const branchId = userMappingByUserId?.pk ?? "";
59
+ // Fetch roles of this user
60
+ const roleData = await getRolesMappingByUserIdAndEntityFun(branchId, currentUser, EntityTypes.ROLE);
61
+ const activeRoles = roleData.filter(r => r.status === Status.Active);
62
+ const roleNames = activeRoles.map(r => r.roleName);
63
+ // Fetch components for each active role
64
+ const compData = await Promise.all(activeRoles.map(role => getComponentsByRoleOnly(role.roleId)));
65
+ const allowedComponents = compData.flat().map(c => c.componentTitle);
66
+ // Build and dispatch user session
67
+ const userSession = {
68
+ userName: currentUser,
69
+ branchId,
70
+ roles: roleNames,
71
+ allowedComponents: [...new Set(allowedComponents)],
72
+ };
73
+ dispatch?.({ session: userSession, type: AppActionEnum.SignIn });
74
+ setIsSessionReady(true);
75
+ };
76
+ updateSession();
77
+ }, [currentUser, userMappingByUserId]);
78
+ // Login handler
79
+ const login = (loggedIn) => {
80
+ setIsLoggedIn(loggedIn);
81
+ if (loggedIn)
82
+ fetchSession();
83
+ };
84
+ return (_jsx("div", { children: currentUser === null ? _jsx(LoginForm, { login: login }) : _jsx(WrappedComponent, { ...props, isSessionReady: isSessionReady }) }));
85
+ };
86
+ return ComponentWithAuthenticator;
87
+ }
@@ -0,0 +1,6 @@
1
+ import { useContext } from "react";
2
+ import AppContext from "../store/AppContext";
3
+ export const useCurrentUser = () => {
4
+ const { user } = useContext(AppContext);
5
+ return { user };
6
+ };
@@ -0,0 +1,7 @@
1
+ import { useContext } from "react";
2
+ import AppContext from "../store/AppContext";
3
+ import { defaultSession } from "../store/AppContextType";
4
+ export const useDispatch = () => {
5
+ const { dispatch } = useContext(AppContext) || { user: defaultSession };
6
+ return { dispatch };
7
+ };
@@ -0,0 +1,7 @@
1
+ // hooks/usePermissions.ts
2
+ import { useContext } from "react";
3
+ import AppContext from "../store/AppContext";
4
+ export function AmIPermitted(componentName) {
5
+ const { user } = useContext(AppContext) || {};
6
+ return user?.allowedComponents?.includes(componentName) ?? false;
7
+ }
package/dist/index.js CHANGED
@@ -1,15 +1,3 @@
1
- import { j as t } from "./jsx-runtime-D_t4bG-_.js";
2
- import { i as r } from "./_virtual___federation_fn_import-XZCKozko.js";
3
- const x = ({ children: s }) => /* @__PURE__ */ t.jsx(t.Fragment, { children: s }), { Routes: p, Route: o } = await r("react-router-dom"), n = () => /* @__PURE__ */ t.jsx("div", { children: "AppHost Dashboard" }), i = () => /* @__PURE__ */ t.jsx("div", { children: "AppHost Settings" }), d = () => /* @__PURE__ */ t.jsxs(p, { children: [
4
- /* @__PURE__ */ t.jsx(o, { path: "/apphost", element: /* @__PURE__ */ t.jsx(n, {}) }),
5
- /* @__PURE__ */ t.jsx(o, { path: "/apphost/settings", element: /* @__PURE__ */ t.jsx(i, {}) })
6
- ] });
7
- let e = {};
8
- const h = (s) => {
9
- e = { ...e, ...s };
10
- };
11
- export {
12
- x as AppHostProvider,
13
- d as AppHostRoutes,
14
- h as configureAppHost
15
- };
1
+ export { AppHostProvider } from "./AppHostProvider";
2
+ export { AppHostRoutes } from "./AppHostRoutes";
3
+ export { configureAppHost } from "./configureAppHost";
package/dist/main.js ADDED
@@ -0,0 +1,60 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { StrictMode, useEffect, useState } from 'react';
3
+ import './index.css';
4
+ import 'bootstrap/dist/css/bootstrap.min.css';
5
+ import 'react-toastify/dist/ReactToastify.css';
6
+ // import AppProvider from './store/AppProvider.tsx';
7
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
8
+ // import { HostedInContainerProvider } from "./store/HostedInContainerContext.tsx";
9
+ import { ToastContainer } from 'react-toastify';
10
+ import { BrowserRouter as Router } from 'react-router-dom';
11
+ import './styles/typography.css';
12
+ import * as ReactDOM from 'react-dom/client';
13
+ import App from './App';
14
+ function registerValidSW(swUrl, config) {
15
+ navigator.serviceWorker
16
+ .register(swUrl)
17
+ .then((registration) => {
18
+ registration.onupdatefound = () => {
19
+ const installingWorker = registration.installing;
20
+ if (installingWorker == null) {
21
+ return;
22
+ }
23
+ installingWorker.onstatechange = () => {
24
+ if (installingWorker.state === 'installed') {
25
+ if (navigator.serviceWorker.controller) {
26
+ // Trigger the callback to notify that a new version is available
27
+ if (config && config.onUpdate) {
28
+ config.onUpdate(registration);
29
+ }
30
+ }
31
+ }
32
+ };
33
+ };
34
+ })
35
+ .catch((error) => {
36
+ console.error('Error during service worker registration:', error);
37
+ });
38
+ }
39
+ const root = ReactDOM.createRoot(document.getElementById('root'));
40
+ const queryClient = new QueryClient();
41
+ const AppWithServiceWorker = () => {
42
+ const [showUpdatePrompt, setShowUpdatePrompt] = useState(false);
43
+ const [swRegistration, setSwRegistration] = useState(null);
44
+ const handleUpdate = (registration) => {
45
+ setSwRegistration(registration); // Save the registration for later use
46
+ setShowUpdatePrompt(true); // Show the update prompt
47
+ };
48
+ // Register the service worker
49
+ useEffect(() => {
50
+ const swUrl = '/sw.js'; // Path to your service worker
51
+ registerValidSW(swUrl, {
52
+ onUpdate: handleUpdate,
53
+ });
54
+ }, []);
55
+ return (_jsxs(StrictMode, { children: [_jsxs(QueryClientProvider, { client: queryClient, children: [_jsx(ToastContainer, { position: "top-right", autoClose: 3000, hideProgressBar: false, newestOnTop: true, closeOnClick: true, pauseOnHover: true, theme: "light", limit: 1 }), _jsx(Router, { children: _jsx(App, {}) })] }), showUpdatePrompt && (_jsxs("div", { className: "update-prompt", children: [_jsx("p", { children: "A new version of the app is available. Please refresh to update." }), _jsx("button", { onClick: () => {
56
+ swRegistration?.waiting?.postMessage({ type: 'SKIP_WAITING' });
57
+ window.location.reload();
58
+ }, children: "Refresh" })] }))] }));
59
+ };
60
+ root.render(_jsx(AppWithServiceWorker, {}));
@@ -0,0 +1,96 @@
1
+ import { fetchAuthSession } from 'aws-amplify/auth';
2
+ import { generateClient } from 'aws-amplify/api';
3
+ import { GraphQLClient } from "graphql-request";
4
+ import { logger } from '../util/Logger';
5
+ import { EnvConfig } from '../config/EnvConfig';
6
+ import { SignatureV4 } from "@aws-sdk/signature-v4";
7
+ import { Sha256 } from "@aws-crypto/sha256-js";
8
+ import { HttpRequest } from "@aws-sdk/protocol-http";
9
+ export class Client {
10
+ static client = undefined;
11
+ static subClient = undefined;
12
+ static async getToken() {
13
+ const session = await fetchAuthSession();
14
+ const credentials = session.credentials;
15
+ const token = session.tokens?.accessToken;
16
+ sessionStorage.setItem('AccessToken', token ?? '');
17
+ sessionStorage.setItem('Credentials', JSON.stringify(credentials)); // for IAM access in payment micro-UI
18
+ return token;
19
+ }
20
+ static async getClient(forceRefresh = false) {
21
+ if (!this.client || forceRefresh) {
22
+ try {
23
+ const token = await this.getToken() ?? "";
24
+ logger.debug("token fetched", token);
25
+ this.client = generateClient({ authMode: 'userPool', headers: { 'Authorization': token } });
26
+ }
27
+ catch (error) {
28
+ logger.error("Get token error while retrieving new token", error);
29
+ }
30
+ }
31
+ return this.client;
32
+ }
33
+ static async getCustomGraphqlClient(endPoint) {
34
+ try {
35
+ const session = await fetchAuthSession();
36
+ const credentials = session.credentials;
37
+ const idToken = session.tokens?.accessToken;
38
+ sessionStorage.setItem('AccessToken', idToken ?? '');
39
+ sessionStorage.setItem('Credentials', JSON.stringify(credentials)); // for IAM access in payment micro-UI
40
+ if (idToken && idToken !== "") {
41
+ // ✅ User Pool auth
42
+ logger.debug("UserPool authentication");
43
+ this.subClient = new GraphQLClient(endPoint, {
44
+ headers: {
45
+ Authorization: idToken,
46
+ "Content-Type": "application/json",
47
+ },
48
+ });
49
+ }
50
+ else if (credentials) {
51
+ // ✅ IAM auth
52
+ logger.debug("IAM authentication");
53
+ const customFetch = async (url, options) => {
54
+ const signer = new SignatureV4({
55
+ service: "appsync",
56
+ region: EnvConfig.region,
57
+ credentials,
58
+ sha256: Sha256,
59
+ });
60
+ const urlObj = new URL(endPoint);
61
+ const request = new HttpRequest({
62
+ method: options.method ?? "POST",
63
+ headers: {
64
+ host: urlObj.hostname, // 👈 must be signed
65
+ "Content-Type": "application/json",
66
+ ...(options.headers || {}),
67
+ },
68
+ body: options.body,
69
+ hostname: urlObj.hostname,
70
+ path: urlObj.pathname,
71
+ protocol: urlObj.protocol,
72
+ });
73
+ const signed = await signer.sign(request);
74
+ return fetch(url, {
75
+ ...options,
76
+ headers: signed.headers,
77
+ });
78
+ };
79
+ this.subClient = new GraphQLClient(endPoint, { fetch: customFetch });
80
+ }
81
+ else {
82
+ throw new Error("No valid authentication method available (IAM or UserPool).");
83
+ }
84
+ return this.subClient;
85
+ }
86
+ catch (err) {
87
+ throw new Error("Error while creating GraphQL client");
88
+ }
89
+ }
90
+ static startClientResetScheduler() {
91
+ const intervalId = setInterval(() => {
92
+ this.client = null;
93
+ }, 2700000); // 45 minutes in milliseconds
94
+ return () => clearInterval(intervalId);
95
+ }
96
+ }
@@ -0,0 +1,26 @@
1
+ import { uploadData } from 'aws-amplify/storage';
2
+ import { LogCategoryEnum } from '../util/LogEnum';
3
+ import { logger } from '../util/Logger';
4
+ import { EnvConfig } from '../config/EnvConfig';
5
+ export const getImageUrl = async (imageKey) => {
6
+ logger.debug(LogCategoryEnum.Info, "imageKey passed", imageKey);
7
+ let returnString = undefined;
8
+ if (imageKey) {
9
+ //Below for hms-ck-dev env image bucket url -------------
10
+ returnString = `${EnvConfig.imageStorageBucketUrl}/${imageKey}`;
11
+ }
12
+ return returnString;
13
+ };
14
+ export const uploadImage = async (imageKey, image) => {
15
+ logger.debug(LogCategoryEnum.Info, "inside upload image function", imageKey);
16
+ logger.debug(LogCategoryEnum.Info, "inside upload image function", image);
17
+ await uploadData({
18
+ key: imageKey,
19
+ data: image,
20
+ options: {
21
+ accessLevel: 'guest',
22
+ contentType: image.type,
23
+ }
24
+ });
25
+ logger.debug(LogCategoryEnum.Info, "image key", imageKey);
26
+ };
@@ -0,0 +1,9 @@
1
+ import navMenuJson from "../config/routes.json";
2
+ export const getSidebarMenu = async () => {
3
+ // Simulated API call
4
+ return new Promise((resolve) => {
5
+ setTimeout(() => {
6
+ resolve(navMenuJson);
7
+ }, 200);
8
+ });
9
+ };
@@ -0,0 +1,34 @@
1
+ export const VITE_API_AUTHMODE = "userPool";
2
+ export const INVOICE_PREFIX_FORMAT = "invoice-prefix-format-settings";
3
+ export const INVOICE_RESETTING_PERIOD = 'invoice-resetting-period';
4
+ export const INVOICE_SEQUENCE_PADDING = 'invoice-sequence-padding';
5
+ export const INVOICE_SERIES_NUMBER = "invoice-series-number-setting";
6
+ export const BOOKING_RECEIPT_PREFIX_FORMAT = "booking-receipt-prefix-format-settings";
7
+ export const BOOKING_RECEIPT_RESETTING_PERIOD = "booking-receipt-resetting-period";
8
+ export const BOOKING_RECEIPT_SEQUENCE_PADDING = "booking-receipt-sequence-padding";
9
+ export const BOOKING_RECEIPT_SERIES_NUMBER = "booking-receipt-series-number-setting";
10
+ export const PURCHASE_ORDER_PREFIX_FORMAT = "purchase-order-prefix-format-settings";
11
+ export const PURCHASE_ORDER_RESETTING_PERIOD = 'purchase-order-resetting-period';
12
+ export const PURCHASE_ORDER_SEQUENCE_PADDING = 'purchase-order-sequence-padding';
13
+ export const PREFIX_CONSTANT_FY = '{FY}';
14
+ export const PREFIX_CONSTANT_fy = '{fy}';
15
+ export const PREFIX_CONSTANT_FYPLUS1 = '{FYPLUS1}';
16
+ export const PREFIX_CONSTANT_fyplus1 = "{fyplus1}";
17
+ export const PREFIX_CONSTANT_FYMINUS1 = "{FYMINUS1}";
18
+ export const PREFIX_CONSTANT_fyminus1 = "{fyminus1}";
19
+ export const PREFIX_CONSTANT_Y = '{Y}';
20
+ export const PREFIX_CONSTANT_y = '{y}';
21
+ export const PREFIX_CONSTANT_M = '{M}';
22
+ export const PREFIX_CONSTANT_D = '{D}';
23
+ export const FINANCIAL_YEARLY = "FINANCIAL YEARLY";
24
+ export const YEARLY = "YEARLY";
25
+ export const MONTHLY = "MONTHLY";
26
+ export const DAILY = "DAILY";
27
+ export const NEVER = "NEVER";
28
+ export const RESERVATION_PREFIX_FORMAT = "reservation-prefix-format";
29
+ export const RESERVATION_RESETTING_PERIOD = "reservation-resetting-period";
30
+ export const RESERVATION_SEQUENCE_PADDING = 'reservation-sequence-padding';
31
+ export const ALL = "All";
32
+ export const HIDE_SIGN_UP = 'hide-sign-up';
33
+ export const HIDE_SIGN_UP_IS_YES = 'Yes';
34
+ export const HIDE_SIGN_UP_IS_NO = 'No';
@@ -0,0 +1,5 @@
1
+ export var AppActionEnum;
2
+ (function (AppActionEnum) {
3
+ AppActionEnum["SignIn"] = "SIGNIN";
4
+ AppActionEnum["SignOut"] = "SIGNOUT";
5
+ })(AppActionEnum || (AppActionEnum = {}));
@@ -0,0 +1,3 @@
1
+ import { createContext } from 'react';
2
+ const AppContext = createContext(undefined);
3
+ export default AppContext;
@@ -0,0 +1,6 @@
1
+ export const defaultSession = {
2
+ userName: '',
3
+ branchId: undefined,
4
+ roles: [],
5
+ allowedComponents: [],
6
+ };
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { defaultSession } from "./AppContextType";
3
+ import AppContext from "./AppContext";
4
+ import { ToastContainer } from 'react-toastify';
5
+ import 'react-toastify/dist/ReactToastify.css';
6
+ import { AppActionEnum } from "./AppAction";
7
+ import { sessionStorage } from "aws-amplify/utils";
8
+ import { APPHOSTSESSION_KEY, useSessionReducer } from "./SesssionReducer";
9
+ import { logger } from "../util/Logger";
10
+ const appContextReducer = (state, action) => {
11
+ logger.debug("Action:", action);
12
+ let newState = state;
13
+ switch (action.type) {
14
+ case AppActionEnum.SignIn:
15
+ newState = {
16
+ ...action.session,
17
+ };
18
+ break;
19
+ case AppActionEnum.SignOut:
20
+ newState = { ...defaultSession };
21
+ sessionStorage.clear();
22
+ break;
23
+ default:
24
+ newState = state;
25
+ }
26
+ return newState;
27
+ };
28
+ const AppProvider = ({ children }) => {
29
+ const [state, dispatch] = useSessionReducer(appContextReducer, defaultSession, APPHOSTSESSION_KEY);
30
+ return (_jsxs(_Fragment, { children: [_jsx(ToastContainer, { position: "top-right", autoClose: 5000 }), _jsx(AppContext.Provider, { value: { user: state, dispatch }, children: children })] }));
31
+ };
32
+ export default AppProvider;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from 'react';
3
+ const HostedInContainerContext = createContext(false);
4
+ export const HostedInContainerProvider = ({ children }) => {
5
+ const isHosted = (() => {
6
+ const urlParams = new URLSearchParams(window.location.search);
7
+ return urlParams.get('hosted_in_container') === 'true';
8
+ })();
9
+ return (_jsx(HostedInContainerContext.Provider, { value: isHosted, children: children }));
10
+ };
11
+ export const useHostedInContainer = () => useContext(HostedInContainerContext);
@@ -0,0 +1,16 @@
1
+ import { useReducer, useEffect } from 'react';
2
+ export const APPHOSTSESSION_KEY = 'AppHostSession';
3
+ export const useSessionReducer = (reducer, initialState, storageKey) => {
4
+ const [state, dispatch] = useReducer(reducer, initialState, () => {
5
+ const value = localStorage.getItem(storageKey); // use storageKey here
6
+ let retState = { ...initialState };
7
+ if (value) {
8
+ retState = JSON.parse(value);
9
+ }
10
+ return retState;
11
+ });
12
+ useEffect(() => {
13
+ localStorage.setItem(storageKey, JSON.stringify(state)); // same key
14
+ }, [storageKey, state]);
15
+ return [state, dispatch];
16
+ };
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const componentMap: Record<string, React.ComponentType<any>>;
3
+ declare const _default: (props: any) => import("react/jsx-runtime").JSX.Element;
4
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from "react";
2
+ interface Props {
3
+ children: ReactNode;
4
+ }
5
+ export declare const AppHostProvider: ({ children }: Props) => import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1 @@
1
+ export declare const AppHostRoutes: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { ImageDto } from "../domain/model/imageDto";
2
+ export declare const GETIMAGEPRESIGNEDURL_QUERYKEY = "downloadimage";
3
+ export declare const useGetImageURL: (fileName: string | undefined) => {
4
+ fetchedImg: string | undefined;
5
+ fetchedImgLoading: boolean;
6
+ fetchedImgError: Error | null;
7
+ };
8
+ export declare const useImageMutation: (imgInfo: ImageDto | undefined) => import("@tanstack/react-query").UseMutationResult<import("aws-amplify/storage").UploadDataOutput, Error, ImageDto, unknown>;
@@ -0,0 +1,80 @@
1
+ import { MappingDto } from "../domain/model/MappingDto";
2
+ import { UndefinedString } from "../domain/type/Nullable";
3
+ import { UserMappingDto } from "../domain/model/UserMappingDto";
4
+ import { RoleMappingDto } from "../domain/model/RoleMappingDto";
5
+ import { ComponentMappingDto, ComponentRoleMapping } from "../domain/model/ComponentMappingDto";
6
+ import { BranchDto } from "../domain/model/BranchDto";
7
+ import { ProfileDto } from "../domain/model/ProfileDto";
8
+ import { Status } from "../domain/type/StatusEnum";
9
+ export declare const MAPPING_RESOURCE: string;
10
+ export declare const GET_MAPPING_BY_USERID_QUERYKEY: string;
11
+ export declare const LIST_BRANCHES_RESOURCE: string;
12
+ export declare const transformtoMappingDto: (mappingData: any) => MappingDto;
13
+ export declare const createProfileFn: (input: Partial<ProfileDto>) => Promise<ProfileDto>;
14
+ export declare const updateProfileFn: (input: ProfileDto) => Promise<ProfileDto>;
15
+ export declare const getProfileFn: (pk: string) => Promise<ProfileDto>;
16
+ export declare const listProfilesFn: () => Promise<ProfileDto[]>;
17
+ export declare const useCreateProfileMutation: () => import("@tanstack/react-query").UseMutationResult<ProfileDto, Error, Partial<ProfileDto>, unknown>;
18
+ export declare const useUpdateProfileMutation: () => import("@tanstack/react-query").UseMutationResult<ProfileDto, Error, ProfileDto, unknown>;
19
+ export declare const useListProfiles: () => import("@tanstack/react-query").UseQueryResult<ProfileDto[], Error>;
20
+ export declare const useGetProfile: (pk: string) => import("@tanstack/react-query").UseQueryResult<ProfileDto, Error>;
21
+ export type BranchInput = {
22
+ pk: string;
23
+ sk: string;
24
+ branchAddress: string;
25
+ branchContactNumber: string;
26
+ createdDt: string;
27
+ status: string;
28
+ };
29
+ export declare const getBranches: () => Promise<any>;
30
+ export declare const useListBranches: () => import("@tanstack/react-query").UseQueryResult<any, Error>;
31
+ export declare const createBranchFn: (input: {
32
+ branchName: string;
33
+ branchAddress: string;
34
+ branchContactNumber: string;
35
+ status?: string;
36
+ }) => Promise<BranchDto>;
37
+ export declare const useCreateBranchMutation: () => import("@tanstack/react-query").UseMutationResult<BranchDto, any, {
38
+ branchName: string;
39
+ branchAddress: string;
40
+ branchContactNumber: string;
41
+ status?: string;
42
+ }, unknown>;
43
+ export declare const getUserMappingByUserIdFun: (userId: UndefinedString) => Promise<UserMappingDto>;
44
+ export declare const useGetUserMappingByUserId: (userId: string) => {
45
+ userMappingByUserId: UserMappingDto | undefined;
46
+ userMappingByUserIdError: Error | null;
47
+ userMappingByUserIdLoading: boolean;
48
+ userMappingByUserIdFetching: boolean;
49
+ userMappingByUserIdSuccess: boolean;
50
+ };
51
+ export declare const getRolesMappingByUserIdAndEntityFun: (branchId: string, userId: string, entity: string) => Promise<RoleMappingDto[]>;
52
+ export declare const getRoleMappingByUserIdAndRoleNameFun: (userId: UndefinedString, roleName: UndefinedString) => Promise<RoleMappingDto>;
53
+ export declare const queryMappings: (variables: any) => Promise<any>;
54
+ export declare const getUserComponents: (branchId: string, userId: string) => Promise<any>;
55
+ export declare const getCompoMappingByRoleIdAndCompoIdFun: (roleId: UndefinedString, componentId: UndefinedString) => Promise<ComponentMappingDto>;
56
+ export declare const getCompoMappingByRoleIdAndEntityFun: (branchId: string, roleId: string) => Promise<ComponentMappingDto[]>;
57
+ export declare const getComponentsByRoleOnly: (roleId: string) => Promise<ComponentMappingDto[]>;
58
+ export declare const useCreateMappingMutation: () => import("@tanstack/react-query").UseMutationResult<any, Error, MappingDto, unknown>;
59
+ export declare const useUpdateMappingMutation: () => import("@tanstack/react-query").UseMutationResult<any, Error, MappingDto, unknown>;
60
+ export declare const getBranchIdByUserId: (userId: string) => Promise<string[]>;
61
+ export declare const getBranchNameById: (branchId: string) => Promise<string>;
62
+ export declare const updateBranchFn: (input: BranchInput) => Promise<BranchDto>;
63
+ export declare const useUpdateBranchMutation: () => import("@tanstack/react-query").UseMutationResult<BranchDto, Error, BranchInput, unknown>;
64
+ export interface BranchUserMapping {
65
+ pk: string;
66
+ sk: string;
67
+ branchName: string;
68
+ userId: string;
69
+ userName: string;
70
+ status: Status;
71
+ createdDt: string;
72
+ disabledDt?: string;
73
+ }
74
+ export declare const fetchBranchUserMappings: (branchesMap: Record<string, string>) => Promise<BranchUserMapping[]>;
75
+ export declare const fetchUserRoleMappings: () => Promise<any[]>;
76
+ export declare const LIST_USER_ROLE_MAPPING_KEY = "userRoleMappings";
77
+ export declare const useUserRoleMappings: () => import("@tanstack/react-query").UseQueryResult<any[], Error>;
78
+ export declare const fetchComponentRoleMappings: () => Promise<ComponentRoleMapping[]>;
79
+ export declare const LIST_COMPONENT_ROLE_MAPPING_KEY = "component-role-mapping";
80
+ export declare const useListComponentRoleMappings: () => import("@tanstack/react-query").UseQueryResult<ComponentRoleMapping[], Error>;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const AmenityForm: React.FC;
3
+ export default AmenityForm;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const BillingManagement: React.FC;
3
+ export default BillingManagement;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const CreateRoomForm: React.FC;
3
+ export default CreateRoomForm;