@abcagency/hc-ui-components 1.3.14 → 1.3.15

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 (147) hide show
  1. package/dist/_virtual/_rollupPluginBabelHelpers.js +1 -1
  2. package/dist/apis/hcApi.js +1 -1
  3. package/dist/apis/hcApi.js.map +1 -1
  4. package/dist/clientToken.js.map +1 -1
  5. package/dist/components/HireControlMap.js.map +1 -1
  6. package/dist/components/modules/accordions/MapAccordionItem.js.map +1 -1
  7. package/dist/components/modules/accordions/default.js.map +1 -1
  8. package/dist/components/modules/accordions/filterItem.js +2 -1
  9. package/dist/components/modules/accordions/filterItem.js.map +1 -1
  10. package/dist/components/modules/accordions/filters.js +0 -3
  11. package/dist/components/modules/accordions/filters.js.map +1 -1
  12. package/dist/components/modules/buttons/button-group-apply.js.map +1 -1
  13. package/dist/components/modules/buttons/commute-pill.js.map +1 -1
  14. package/dist/components/modules/buttons/default.js.map +1 -1
  15. package/dist/components/modules/buttons/items-pill.js.map +1 -1
  16. package/dist/components/modules/buttons/pill-wrapper.js.map +1 -1
  17. package/dist/components/modules/buttons/show-all-button.js.map +1 -1
  18. package/dist/components/modules/cards/default.js.map +1 -1
  19. package/dist/components/modules/cards/filter.js.map +1 -1
  20. package/dist/components/modules/dialogs/apply-dialog.js.map +1 -1
  21. package/dist/components/modules/filter/commute.js.map +1 -1
  22. package/dist/components/modules/filter/item.js +6 -1
  23. package/dist/components/modules/filter/item.js.map +1 -1
  24. package/dist/components/modules/filter/location.js +5 -3
  25. package/dist/components/modules/filter/location.js.map +1 -1
  26. package/dist/components/modules/filter/points-of-interest.js.map +1 -1
  27. package/dist/components/modules/filter/radio-item.js.map +1 -1
  28. package/dist/components/modules/filter/search.js.map +1 -1
  29. package/dist/components/modules/filter/sort.js.map +1 -1
  30. package/dist/components/modules/grid.js.map +1 -1
  31. package/dist/components/modules/icon.js.map +1 -1
  32. package/dist/components/modules/jobListing/listing-details.js.map +1 -1
  33. package/dist/components/modules/maps/info-window-card.js.map +1 -1
  34. package/dist/components/modules/maps/info-window-content.js.map +1 -1
  35. package/dist/components/modules/maps/list/field-mapper.js.map +1 -1
  36. package/dist/components/modules/maps/list/header-item.js.map +1 -1
  37. package/dist/components/modules/maps/list/header.js.map +1 -1
  38. package/dist/components/modules/maps/list/index.js +11 -10
  39. package/dist/components/modules/maps/list/index.js.map +1 -1
  40. package/dist/components/modules/maps/list/item-expand-card/index.js.map +1 -1
  41. package/dist/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js.map +1 -1
  42. package/dist/components/modules/maps/list/item-expand-card/recruiter-details.js.map +1 -1
  43. package/dist/components/modules/maps/list/item-expand-card/recruiter-headshot.js.map +1 -1
  44. package/dist/components/modules/maps/list/list-item/index.js.map +1 -1
  45. package/dist/components/modules/maps/map-list.js.map +1 -1
  46. package/dist/components/modules/maps/map-marker.js.map +1 -1
  47. package/dist/components/modules/maps/map.js.map +1 -1
  48. package/dist/components/modules/maps/place-marker.js.map +1 -1
  49. package/dist/components/modules/maps/tabs.js.map +1 -1
  50. package/dist/constants/placeTypes.js.map +1 -1
  51. package/dist/contexts/mapContext.js +9 -27
  52. package/dist/contexts/mapContext.js.map +1 -1
  53. package/dist/contexts/mapListContext.js +54 -37
  54. package/dist/contexts/mapListContext.js.map +1 -1
  55. package/dist/contexts/placesContext.js.map +1 -1
  56. package/dist/hooks/useList.js +1 -13
  57. package/dist/hooks/useList.js.map +1 -1
  58. package/dist/services/apis/hcApi.js +1 -1
  59. package/dist/services/apis/hcApi.js.map +1 -1
  60. package/dist/services/clientToken.js.map +1 -1
  61. package/dist/services/configService.js.map +1 -1
  62. package/dist/services/googlePlacesNearbyService.js.map +1 -1
  63. package/dist/services/listingAggregatorService.js +43 -16
  64. package/dist/services/listingAggregatorService.js.map +1 -1
  65. package/dist/services/listingEntityService.js.map +1 -1
  66. package/dist/services/listingService.js.map +1 -1
  67. package/dist/services/recruiterService.js.map +1 -1
  68. package/dist/util/filterUtil.js.map +1 -1
  69. package/dist/util/loading.js.map +1 -1
  70. package/dist/util/localStorageUtil.js.map +1 -1
  71. package/dist/util/mapIconUtil.js.map +1 -1
  72. package/dist/util/mapUtil.js.map +1 -1
  73. package/dist/util/sortUtil.js.map +1 -1
  74. package/dist/util/stringUtils.js.map +1 -1
  75. package/jsconfig.json +7 -7
  76. package/package.json +7 -7
  77. package/postcss.config.js +13 -13
  78. package/preset.default.js +15 -15
  79. package/rollup.config.mjs +88 -87
  80. package/src/apis/hcApi.js +93 -93
  81. package/src/clientToken.js +9 -9
  82. package/src/components/HireControlMap.js +124 -124
  83. package/src/components/modules/accordions/MapAccordionItem.js +72 -72
  84. package/src/components/modules/accordions/default.js +171 -171
  85. package/src/components/modules/accordions/filterItem.js +3 -1
  86. package/src/components/modules/accordions/filters.js +1 -1
  87. package/src/components/modules/buttons/button-group-apply.js +116 -116
  88. package/src/components/modules/buttons/commute-pill.js +22 -22
  89. package/src/components/modules/buttons/default.js +194 -194
  90. package/src/components/modules/buttons/items-pill.js +35 -35
  91. package/src/components/modules/buttons/pill-wrapper.js +27 -27
  92. package/src/components/modules/buttons/show-all-button.js +20 -20
  93. package/src/components/modules/cards/default.js +167 -167
  94. package/src/components/modules/cards/filter.js +56 -56
  95. package/src/components/modules/dialogs/apply-dialog.js +48 -48
  96. package/src/components/modules/filter/commute.js +149 -149
  97. package/src/components/modules/filter/item.js +5 -0
  98. package/src/components/modules/filter/location.js +5 -3
  99. package/src/components/modules/filter/points-of-interest.js +44 -44
  100. package/src/components/modules/filter/radio-item.js +53 -53
  101. package/src/components/modules/filter/search.js +92 -92
  102. package/src/components/modules/filter/sort.js +83 -83
  103. package/src/components/modules/grid.js +54 -54
  104. package/src/components/modules/icon.js +33 -33
  105. package/src/components/modules/jobListing/listing-details.js +95 -95
  106. package/src/components/modules/maps/info-window-card.js +17 -17
  107. package/src/components/modules/maps/info-window-content.js +74 -74
  108. package/src/components/modules/maps/list/field-mapper.js +112 -112
  109. package/src/components/modules/maps/list/header-item.js +91 -91
  110. package/src/components/modules/maps/list/header.js +47 -47
  111. package/src/components/modules/maps/list/index.js +7 -7
  112. package/src/components/modules/maps/list/item-expand-card/index.js +22 -22
  113. package/src/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js +50 -50
  114. package/src/components/modules/maps/list/item-expand-card/recruiter-details.js +68 -68
  115. package/src/components/modules/maps/list/item-expand-card/recruiter-headshot.js +22 -22
  116. package/src/components/modules/maps/list/list-item/index.js +133 -133
  117. package/src/components/modules/maps/map-list.js +74 -74
  118. package/src/components/modules/maps/map-marker.js +86 -86
  119. package/src/components/modules/maps/map.js +230 -230
  120. package/src/components/modules/maps/place-marker.js +41 -41
  121. package/src/components/modules/maps/tabs.js +81 -81
  122. package/src/constants/placeTypes.js +8 -8
  123. package/src/contexts/mapContext.js +0 -14
  124. package/src/contexts/mapListContext.js +26 -8
  125. package/src/contexts/placesContext.js +102 -102
  126. package/src/hooks/useList.js +2 -13
  127. package/src/index.js +3 -3
  128. package/src/services/configService.js +16 -16
  129. package/src/services/googlePlacesNearbyService.js +33 -33
  130. package/src/services/listingAggregatorService.js +9 -4
  131. package/src/services/listingEntityService.js +15 -15
  132. package/src/services/listingService.js +26 -26
  133. package/src/services/recruiterService.js +17 -17
  134. package/src/styles/index.css +23 -23
  135. package/src/util/arrayUtil.js +3 -3
  136. package/src/util/fieldMapper.js +22 -22
  137. package/src/util/filterUtil.js +195 -195
  138. package/src/util/loading.js +17 -17
  139. package/src/util/localStorageUtil.js +26 -26
  140. package/src/util/mapIconUtil.js +180 -180
  141. package/src/util/mapUtil.js +91 -91
  142. package/src/util/sortUtil.js +32 -32
  143. package/src/util/stringUtils.js +6 -6
  144. package/tailwind.config.js +126 -126
  145. package/.editorconfig +0 -12
  146. package/.eslintrc +0 -105
  147. package/.prettierignore +0 -3
package/rollup.config.mjs CHANGED
@@ -1,87 +1,88 @@
1
- import babel from '@rollup/plugin-babel';
2
- import { nodeResolve as resolve } from '@rollup/plugin-node-resolve';
3
- import external from 'rollup-plugin-peer-deps-external';
4
- import alias from '@rollup/plugin-alias';
5
- import path from 'path';
6
- import commonjs from '@rollup/plugin-commonjs';
7
- import replace from '@rollup/plugin-replace';
8
- import dotenv from 'dotenv';
9
- import postcss from 'rollup-plugin-postcss';
10
- import { fileURLToPath } from 'url';
11
- import tailwindcss from 'tailwindcss';
12
- import autoprefixer from 'autoprefixer';
13
-
14
- // Load environment variables from .env file
15
- dotenv.config();
16
-
17
- // Convert file URL to file path
18
- const __filename = fileURLToPath(import.meta.url);
19
- const __dirname = path.dirname(__filename);
20
-
21
- // Resolve the project root directory
22
- const projectRootDir = path.resolve(__dirname);
23
-
24
- const plugins = [
25
- external(),
26
- resolve(),
27
- postcss({
28
- extensions: ['.css'],
29
- extract: 'styles/index.css',
30
- minimize: true,
31
- plugins: [
32
- tailwindcss,
33
- autoprefixer,
34
- ],
35
- }),
36
- replace({
37
- preventAssignment: true,
38
- 'process.env.GOOGLE_MAPS_API_KEY': JSON.stringify(process.env.GOOGLE_MAPS_API_KEY),
39
- 'process.env.GOOGLE_MAPS_API_URL': JSON.stringify(process.env.GOOGLE_MAPS_API_URL),
40
- 'process.env.HC_API_BASE_URL': JSON.stringify(process.env.HC_API_BASE_URL),
41
- }),
42
- alias({
43
- entries: [{ find: '~', replacement: path.resolve(projectRootDir, 'src') }],
44
- }),
45
- babel({
46
- babelHelpers: 'bundled',
47
- exclude: 'node_modules/**',
48
- presets: ['@babel/preset-env', '@babel/preset-react'],
49
- }),
50
- commonjs(),
51
- ];
52
-
53
- const externalDependencies = [
54
- 'react', 'react-dom', 'react-router-dom', 'form-data',
55
- 'react/jsx-runtime', 'tailwind-merge'
56
- ];
57
-
58
- export default [
59
- {
60
- input: 'src/index.js',
61
- output: {
62
- dir: 'dist',
63
- format: 'es',
64
- exports: 'named',
65
- sourcemap: true,
66
- preserveModules: true,
67
- preserveModulesRoot: 'src',
68
- },
69
- plugins,
70
- external: externalDependencies,
71
- treeshake: true,
72
- },
73
- {
74
- input: 'src/services/listingService.js',
75
- output: {
76
- dir: 'dist/services',
77
- format: 'es',
78
- exports: 'named',
79
- sourcemap: true,
80
- preserveModules: true,
81
- preserveModulesRoot: 'src/services',
82
- },
83
- plugins,
84
- external: externalDependencies,
85
- treeshake: true,
86
- },
87
- ];
1
+ import babel from '@rollup/plugin-babel';
2
+ import { nodeResolve as resolve } from '@rollup/plugin-node-resolve';
3
+ import external from 'rollup-plugin-peer-deps-external';
4
+ import alias from '@rollup/plugin-alias';
5
+ import path from 'path';
6
+ import commonjs from '@rollup/plugin-commonjs';
7
+ import replace from '@rollup/plugin-replace';
8
+ import dotenv from 'dotenv';
9
+ import postcss from 'rollup-plugin-postcss';
10
+ import { fileURLToPath } from 'url';
11
+ import tailwindcss from 'tailwindcss';
12
+ import autoprefixer from 'autoprefixer';
13
+
14
+ // Convert file URL to file path
15
+ const __filename = fileURLToPath(import.meta.url);
16
+ const __dirname = path.dirname(__filename);
17
+
18
+ // Load environment variables from .env file
19
+ dotenv.config({ path: path.resolve(__dirname, '.env') });
20
+ console.log('GOOGLE_MAPS_API_KEY:', process.env.GOOGLE_MAPS_API_KEY);
21
+
22
+ // Resolve the project root directory
23
+ const projectRootDir = path.resolve(__dirname);
24
+
25
+ const plugins = [
26
+ external(),
27
+ resolve(),
28
+ postcss({
29
+ extensions: ['.css'],
30
+ extract: 'styles/index.css',
31
+ minimize: true,
32
+ plugins: [
33
+ tailwindcss(path.resolve(__dirname, 'tailwind.config.js')),
34
+ autoprefixer
35
+ ]
36
+ }),
37
+ replace({
38
+ preventAssignment: true,
39
+ 'process.env.GOOGLE_MAPS_API_KEY': JSON.stringify(process.env.GOOGLE_MAPS_API_KEY),
40
+ 'process.env.GOOGLE_MAPS_API_URL': JSON.stringify(process.env.GOOGLE_MAPS_API_URL),
41
+ 'process.env.HC_API_BASE_URL': JSON.stringify(process.env.HC_API_BASE_URL)
42
+ }),
43
+ alias({
44
+ entries: [{ find: '~', replacement: path.resolve(projectRootDir, 'src') }]
45
+ }),
46
+ babel({
47
+ babelHelpers: 'bundled',
48
+ exclude: 'node_modules/**',
49
+ presets: ['@babel/preset-env', '@babel/preset-react']
50
+ }),
51
+ commonjs()
52
+ ];
53
+
54
+ const externalDependencies = [
55
+ 'react', 'react-dom', 'react-router-dom', 'form-data',
56
+ 'react/jsx-runtime', 'tailwind-merge'
57
+ ];
58
+
59
+ export default [
60
+ {
61
+ input: path.resolve(__dirname, 'src/index.js'),
62
+ output: {
63
+ dir: path.resolve(__dirname, 'dist'),
64
+ format: 'es',
65
+ exports: 'named',
66
+ sourcemap: true,
67
+ preserveModules: true,
68
+ preserveModulesRoot: 'src'
69
+ },
70
+ plugins,
71
+ external: externalDependencies,
72
+ treeshake: true
73
+ },
74
+ {
75
+ input: path.resolve(__dirname, 'src/services/listingService.js'),
76
+ output: {
77
+ dir: path.resolve(__dirname, 'dist/services'),
78
+ format: 'es',
79
+ exports: 'named',
80
+ sourcemap: true,
81
+ preserveModules: true,
82
+ preserveModulesRoot: 'src/services'
83
+ },
84
+ plugins,
85
+ external: externalDependencies,
86
+ treeshake: true
87
+ }
88
+ ];
package/src/apis/hcApi.js CHANGED
@@ -1,93 +1,93 @@
1
- import { getClientAuthKey } from '~/clientToken.js';
2
- const baseURL = process.env.HC_API_BASE_URL;
3
-
4
- const memoryStorage = {
5
- authToken: null,
6
- tokenExpiration: null
7
- };
8
-
9
- function setStorage(key, value) {
10
- try {
11
- sessionStorage.setItem(key, value);
12
- } catch (error) {
13
- memoryStorage[key] = value;
14
- }
15
- }
16
-
17
- function getStorage(key) {
18
- try {
19
- return sessionStorage.getItem(key) || memoryStorage[key];
20
- } catch (error) {
21
- return memoryStorage[key];
22
- }
23
- }
24
-
25
- const login = async () => {
26
- const clientAuthKey = getClientAuthKey();
27
-
28
- try {
29
- const response = await fetch(`${baseURL}/auth/login`, {
30
- method: 'POST',
31
- headers: {
32
- 'Content-Type': 'application/json'
33
- },
34
- body: JSON.stringify({
35
- clientAuthKey: clientAuthKey
36
- })
37
- });
38
-
39
- const data = await response.json();
40
-
41
- if (data.token && data.expiration) {
42
- setStorage('authToken', data.token);
43
- setStorage('tokenExpiration', data.expiration);
44
- return { token: data.token, expiration: data.expiration };
45
- }
46
- } catch (error) {
47
- console.error('Login failed:', error);
48
- throw error;
49
- }
50
- };
51
-
52
- const fetchWithAuth = async (url, options = {}) => {
53
- let token = getStorage('authToken');
54
-
55
- const expirationDateTime = getStorage('tokenExpiration');
56
- const currentTime = new Date();
57
-
58
- if (!token || !expirationDateTime || new Date(expirationDateTime) <= currentTime) {
59
- const authResponse = await login();
60
- token = authResponse.token;
61
- }
62
-
63
- const headers = new Headers(options.headers || {});
64
- headers.append('Authorization', `Bearer ${token}`);
65
-
66
- const finalOptions = {
67
- ...options,
68
- headers
69
- };
70
-
71
- const response = await fetch(`${baseURL}${url}`, finalOptions);
72
-
73
- if (!response.ok) throw new Error('Network response was not ok.');
74
-
75
- return response;
76
- };
77
-
78
- export default {
79
- get: async url => {
80
- const response = await fetchWithAuth(url);
81
- return await response.json();
82
- },
83
- post: async (url, data) => {
84
- const response = await fetchWithAuth(url, {
85
- method: 'POST',
86
- headers: {
87
- 'Content-Type': 'application/json'
88
- },
89
- body: JSON.stringify(data)
90
- });
91
- return await response.json();
92
- }
93
- };
1
+ import { getClientAuthKey } from '~/clientToken.js';
2
+ const baseURL = process.env.HC_API_BASE_URL;
3
+
4
+ const memoryStorage = {
5
+ authToken: null,
6
+ tokenExpiration: null
7
+ };
8
+
9
+ function setStorage(key, value) {
10
+ try {
11
+ sessionStorage.setItem(key, value);
12
+ } catch (error) {
13
+ memoryStorage[key] = value;
14
+ }
15
+ }
16
+
17
+ function getStorage(key) {
18
+ try {
19
+ return sessionStorage.getItem(key) || memoryStorage[key];
20
+ } catch (error) {
21
+ return memoryStorage[key];
22
+ }
23
+ }
24
+
25
+ const login = async () => {
26
+ const clientAuthKey = getClientAuthKey();
27
+
28
+ try {
29
+ const response = await fetch(`${baseURL}/auth/login`, {
30
+ method: 'POST',
31
+ headers: {
32
+ 'Content-Type': 'application/json'
33
+ },
34
+ body: JSON.stringify({
35
+ clientAuthKey: clientAuthKey
36
+ })
37
+ });
38
+
39
+ const data = await response.json();
40
+
41
+ if (data.token && data.expiration) {
42
+ setStorage('authToken', data.token);
43
+ setStorage('tokenExpiration', data.expiration);
44
+ return { token: data.token, expiration: data.expiration };
45
+ }
46
+ } catch (error) {
47
+ console.error('Login failed:', error);
48
+ throw error;
49
+ }
50
+ };
51
+
52
+ const fetchWithAuth = async (url, options = {}) => {
53
+ let token = getStorage('authToken');
54
+
55
+ const expirationDateTime = getStorage('tokenExpiration');
56
+ const currentTime = new Date();
57
+
58
+ if (!token || !expirationDateTime || new Date(expirationDateTime) <= currentTime) {
59
+ const authResponse = await login();
60
+ token = authResponse.token;
61
+ }
62
+
63
+ const headers = new Headers(options.headers || {});
64
+ headers.append('Authorization', `Bearer ${token}`);
65
+
66
+ const finalOptions = {
67
+ ...options,
68
+ headers
69
+ };
70
+
71
+ const response = await fetch(`${baseURL}${url}`, finalOptions);
72
+
73
+ if (!response.ok) throw new Error('Network response was not ok.');
74
+
75
+ return response;
76
+ };
77
+
78
+ export default {
79
+ get: async url => {
80
+ const response = await fetchWithAuth(url);
81
+ return await response.json();
82
+ },
83
+ post: async (url, data) => {
84
+ const response = await fetchWithAuth(url, {
85
+ method: 'POST',
86
+ headers: {
87
+ 'Content-Type': 'application/json'
88
+ },
89
+ body: JSON.stringify(data)
90
+ });
91
+ return await response.json();
92
+ }
93
+ };
@@ -1,9 +1,9 @@
1
- let clientAuthKey = null;
2
-
3
- export const setClientAuthKey = key => {
4
- clientAuthKey = key;
5
- };
6
-
7
- export const getClientAuthKey = () => {
8
- return clientAuthKey;
9
- };
1
+ let clientAuthKey = null;
2
+
3
+ export const setClientAuthKey = key => {
4
+ clientAuthKey = key;
5
+ };
6
+
7
+ export const getClientAuthKey = () => {
8
+ return clientAuthKey;
9
+ };
@@ -1,124 +1,124 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { useLoadScript } from '@react-google-maps/api';
3
-
4
- import Grid from '~/components/modules/grid';
5
- import Filter from '~/components/modules/filter';
6
- import MapList from '~/components/modules/maps/map-list';
7
-
8
- import { MapProvider } from '~/contexts/mapContext';
9
- import { PlacesProvider } from '~/contexts/placesContext';
10
- import { MapListProvider } from '~/contexts/mapListContext';
11
-
12
- import { getMapConfig } from '~/services/configService';
13
- import { setClientAuthKey } from '~/clientToken.js';
14
-
15
- import '../styles/index.css';
16
-
17
- const libraries = ['places'];
18
-
19
- export const HireControlMap = ({
20
- clientToken,
21
- navigateToDetails = null,
22
- navigateToEasyApply = null,
23
- Link = null,
24
- linkFormat = '/jobs/[slug]'
25
- }) => {
26
- const [siteConfig, setSiteconfig] = useState(null);
27
-
28
- useEffect(() => {
29
- setClientAuthKey(clientToken);
30
- const fetchSiteConfig = async () => {
31
- try {
32
- const configData = await getMapConfig(clientToken);
33
- setSiteconfig(configData);
34
- } catch (error) {
35
- console.error('Failed to fetch site configuration:', error);
36
- }
37
- };
38
-
39
- fetchSiteConfig();
40
- }, [clientToken]);
41
-
42
- const { isLoaded } = useLoadScript({
43
- googleMapsApiKey: process.env.GOOGLE_MAPS_API_KEY,
44
- version: 'quarterly',
45
- libraries: libraries
46
- });
47
-
48
- return (
49
- <div>
50
- {isLoaded && siteConfig && (
51
- <HomeBody
52
- siteConfig={siteConfig}
53
- navigateToDetails={navigateToDetails}
54
- navigateToEasyApply={navigateToEasyApply}
55
- Link={Link}
56
- linkFormat={linkFormat}
57
- />
58
- )}
59
- </div>
60
- );
61
- };
62
-
63
- const HomeBody = ({ siteConfig, navigateToDetails, navigateToEasyApply, Link, linkFormat }) => {
64
- const resetFilters = false;
65
-
66
- return (
67
- <MapListProvider
68
- siteConfig={siteConfig}
69
- resetFilters={resetFilters}
70
- avigateToDetails={navigateToDetails}
71
- navigateToEasyApply={navigateToEasyApply}
72
- Link={Link}
73
- linkFormat={linkFormat}
74
- >
75
- <MapProvider resetFilters={resetFilters}>
76
- <PlacesProvider
77
- placeMappings={siteConfig.pointsOfInterestConfig.placeMappings ?? {}}
78
- markerColors={{
79
- fillColor: siteConfig.colors.primary,
80
- strokeColor: siteConfig.colors.primaryDark,
81
- selectedFillColor: siteConfig.colors.secondary,
82
- selectedStrokeColor: siteConfig.colors.secondaryDark,
83
- placeMarkers: {
84
- colors: siteConfig.pointsOfInterestConfig.placeMarkerColors,
85
- size: siteConfig.pointsOfInterestConfig.placeMarkerSize
86
- }
87
- }}
88
- >
89
- <Grid
90
- as='section'
91
- id='job-search-interface'
92
- columns='md:hc-grid-cols-[1fr_2.5fr] lg:hc-grid-cols-[1fr_3.5fr]'
93
- gap='hc-gap-0'
94
- autoRows={false}
95
- className='hc-items-stretch hc-h-screen hc-min-h-[30rem] hc-divide-x hc-divide-uiAccent/20'
96
- >
97
- <Grid.Item className='hc-bg-gray-100'>
98
- <Filter showMap={siteConfig.showMap} className='hc-hidden md:hc-block' />
99
- </Grid.Item>
100
- <MapList
101
- markerConfigs={{
102
- fillColor: siteConfig.colors.primary,
103
- strokeColor: siteConfig.colors.primaryDark,
104
- selectedFillColor: siteConfig.colors.secondary,
105
- selectedStrokeColor: siteConfig.colors.secondaryDark,
106
- placeMarkers: {
107
- colors: siteConfig.pointsOfInterestConfig.placeMarkerColors,
108
- size: siteConfig.pointsOfInterestConfig.placeMarkerSize
109
- }
110
- }}
111
- showMap={siteConfig.showMap}
112
- fieldsShown={siteConfig.fieldsShown}
113
- specialFeatures={siteConfig.specialFeatures}
114
- fieldNames={siteConfig.fieldNames}
115
- placeMappings={siteConfig.pointsOfInterestConfig.placeMappings ?? {}}
116
- />
117
- </Grid>
118
- </PlacesProvider>
119
- </MapProvider>
120
- </MapListProvider>
121
- );
122
- };
123
-
124
- export default HireControlMap;
1
+ import React, { useEffect, useState } from 'react';
2
+ import { useLoadScript } from '@react-google-maps/api';
3
+
4
+ import Grid from '~/components/modules/grid';
5
+ import Filter from '~/components/modules/filter';
6
+ import MapList from '~/components/modules/maps/map-list';
7
+
8
+ import { MapProvider } from '~/contexts/mapContext';
9
+ import { PlacesProvider } from '~/contexts/placesContext';
10
+ import { MapListProvider } from '~/contexts/mapListContext';
11
+
12
+ import { getMapConfig } from '~/services/configService';
13
+ import { setClientAuthKey } from '~/clientToken.js';
14
+
15
+ import '../styles/index.css';
16
+
17
+ const libraries = ['places'];
18
+
19
+ export const HireControlMap = ({
20
+ clientToken,
21
+ navigateToDetails = null,
22
+ navigateToEasyApply = null,
23
+ Link = null,
24
+ linkFormat = '/jobs/[slug]'
25
+ }) => {
26
+ const [siteConfig, setSiteconfig] = useState(null);
27
+
28
+ useEffect(() => {
29
+ setClientAuthKey(clientToken);
30
+ const fetchSiteConfig = async () => {
31
+ try {
32
+ const configData = await getMapConfig(clientToken);
33
+ setSiteconfig(configData);
34
+ } catch (error) {
35
+ console.error('Failed to fetch site configuration:', error);
36
+ }
37
+ };
38
+
39
+ fetchSiteConfig();
40
+ }, [clientToken]);
41
+
42
+ const { isLoaded } = useLoadScript({
43
+ googleMapsApiKey: process.env.GOOGLE_MAPS_API_KEY,
44
+ version: 'quarterly',
45
+ libraries: libraries
46
+ });
47
+
48
+ return (
49
+ <div>
50
+ {isLoaded && siteConfig && (
51
+ <HomeBody
52
+ siteConfig={siteConfig}
53
+ navigateToDetails={navigateToDetails}
54
+ navigateToEasyApply={navigateToEasyApply}
55
+ Link={Link}
56
+ linkFormat={linkFormat}
57
+ />
58
+ )}
59
+ </div>
60
+ );
61
+ };
62
+
63
+ const HomeBody = ({ siteConfig, navigateToDetails, navigateToEasyApply, Link, linkFormat }) => {
64
+ const resetFilters = false;
65
+
66
+ return (
67
+ <MapListProvider
68
+ siteConfig={siteConfig}
69
+ resetFilters={resetFilters}
70
+ avigateToDetails={navigateToDetails}
71
+ navigateToEasyApply={navigateToEasyApply}
72
+ Link={Link}
73
+ linkFormat={linkFormat}
74
+ >
75
+ <MapProvider resetFilters={resetFilters}>
76
+ <PlacesProvider
77
+ placeMappings={siteConfig.pointsOfInterestConfig.placeMappings ?? {}}
78
+ markerColors={{
79
+ fillColor: siteConfig.colors.primary,
80
+ strokeColor: siteConfig.colors.primaryDark,
81
+ selectedFillColor: siteConfig.colors.secondary,
82
+ selectedStrokeColor: siteConfig.colors.secondaryDark,
83
+ placeMarkers: {
84
+ colors: siteConfig.pointsOfInterestConfig.placeMarkerColors,
85
+ size: siteConfig.pointsOfInterestConfig.placeMarkerSize
86
+ }
87
+ }}
88
+ >
89
+ <Grid
90
+ as='section'
91
+ id='job-search-interface'
92
+ columns='md:hc-grid-cols-[1fr_2.5fr] lg:hc-grid-cols-[1fr_3.5fr]'
93
+ gap='hc-gap-0'
94
+ autoRows={false}
95
+ className='hc-items-stretch hc-h-screen hc-min-h-[30rem] hc-divide-x hc-divide-uiAccent/20'
96
+ >
97
+ <Grid.Item className='hc-bg-gray-100'>
98
+ <Filter showMap={siteConfig.showMap} className='hc-hidden md:hc-block' />
99
+ </Grid.Item>
100
+ <MapList
101
+ markerConfigs={{
102
+ fillColor: siteConfig.colors.primary,
103
+ strokeColor: siteConfig.colors.primaryDark,
104
+ selectedFillColor: siteConfig.colors.secondary,
105
+ selectedStrokeColor: siteConfig.colors.secondaryDark,
106
+ placeMarkers: {
107
+ colors: siteConfig.pointsOfInterestConfig.placeMarkerColors,
108
+ size: siteConfig.pointsOfInterestConfig.placeMarkerSize
109
+ }
110
+ }}
111
+ showMap={siteConfig.showMap}
112
+ fieldsShown={siteConfig.fieldsShown}
113
+ specialFeatures={siteConfig.specialFeatures}
114
+ fieldNames={siteConfig.fieldNames}
115
+ placeMappings={siteConfig.pointsOfInterestConfig.placeMappings ?? {}}
116
+ />
117
+ </Grid>
118
+ </PlacesProvider>
119
+ </MapProvider>
120
+ </MapListProvider>
121
+ );
122
+ };
123
+
124
+ export default HireControlMap;