@abcagency/hc-ui-components 1.0.4 → 1.0.5
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/index.js +22 -124
- package/package.json +1 -1
- package/src/components/modules/navigation/navbar.js +0 -3
- package/src/contexts/mapListContext.js +19 -18
- package/src/index.js +0 -13
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useContext, useState, useEffect, createContext, useRef, forwardRef, memo, Fragment } from 'react';
|
|
2
|
-
import { useLocation, useNavigate, Link, BrowserRouter } from 'react-router-dom';
|
|
3
2
|
import { twMerge } from 'tailwind-merge';
|
|
4
3
|
import { useScroll, useTransform, useSpring, motion } from 'framer-motion';
|
|
4
|
+
import { Link } from 'react-router-dom';
|
|
5
5
|
import { Icon } from '@iconify/react';
|
|
6
6
|
import * as RadixAccordion from '@radix-ui/react-accordion';
|
|
7
7
|
import { Combobox, Transition } from '@headlessui/react';
|
|
@@ -1189,110 +1189,18 @@ var setStorageObject = function setStorageObject(key, item) {
|
|
|
1189
1189
|
}
|
|
1190
1190
|
};
|
|
1191
1191
|
|
|
1192
|
-
var updateURLWithFilters = function updateURLWithFilters(filters, location, navigate, query) {
|
|
1193
|
-
var searchParams = new URLSearchParams(location.search);
|
|
1194
|
-
Object.keys(Object.fromEntries(searchParams)).forEach(function (key) {
|
|
1195
|
-
if (!key.includes('.') && key !== 'query') {
|
|
1196
|
-
searchParams.set(key, searchParams.get(key));
|
|
1197
|
-
}
|
|
1198
|
-
});
|
|
1199
|
-
if (query) {
|
|
1200
|
-
searchParams.set('query', query);
|
|
1201
|
-
}
|
|
1202
|
-
Object.keys(filters).forEach(function (category) {
|
|
1203
|
-
Object.keys(filters[category]).forEach(function (filter) {
|
|
1204
|
-
var key = "".concat(category, ".").concat(filter);
|
|
1205
|
-
if (filters[category][filter]) {
|
|
1206
|
-
searchParams.set(key, 'true');
|
|
1207
|
-
} else {
|
|
1208
|
-
searchParams["delete"](key);
|
|
1209
|
-
}
|
|
1210
|
-
});
|
|
1211
|
-
});
|
|
1212
|
-
navigate({
|
|
1213
|
-
search: searchParams.toString()
|
|
1214
|
-
}, {
|
|
1215
|
-
replace: true
|
|
1216
|
-
});
|
|
1217
|
-
notifyParentOfUrlChange();
|
|
1218
|
-
};
|
|
1219
|
-
function notifyParentOfUrlChange() {
|
|
1220
|
-
setTimeout(function () {
|
|
1221
|
-
var message = {
|
|
1222
|
-
type: 'URL_CHANGE',
|
|
1223
|
-
url: window.location.href
|
|
1224
|
-
};
|
|
1225
|
-
window.parent.postMessage(message, "*");
|
|
1226
|
-
}, 500);
|
|
1227
|
-
}
|
|
1228
|
-
var parseQueryParams = function parseQueryParams(search) {
|
|
1229
|
-
var queryParams = {};
|
|
1230
|
-
if (!search) return queryParams;
|
|
1231
|
-
var queryString = search.split('?')[1];
|
|
1232
|
-
if (!queryString) {
|
|
1233
|
-
return queryParams;
|
|
1234
|
-
}
|
|
1235
|
-
queryString = queryString.replaceAll('+', ' ');
|
|
1236
|
-
queryString.split('&').forEach(function (param) {
|
|
1237
|
-
var _param$split = param.split('='),
|
|
1238
|
-
_param$split2 = _slicedToArray(_param$split, 2),
|
|
1239
|
-
key = _param$split2[0],
|
|
1240
|
-
value = _param$split2[1];
|
|
1241
|
-
queryParams[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
1242
|
-
});
|
|
1243
|
-
return queryParams;
|
|
1244
|
-
};
|
|
1245
|
-
var filtersFromURL = function filtersFromURL(location) {
|
|
1246
|
-
if (!location || !location.search) return;
|
|
1247
|
-
var filters = {};
|
|
1248
|
-
var queryParam = null;
|
|
1249
|
-
var queryParams = parseQueryParams(location.search);
|
|
1250
|
-
if (!queryParams) return;
|
|
1251
|
-
Object.keys(queryParams).forEach(function (key) {
|
|
1252
|
-
if (key && key.includes('.')) {
|
|
1253
|
-
var _key$split = key.split('.'),
|
|
1254
|
-
_key$split2 = _slicedToArray(_key$split, 2),
|
|
1255
|
-
category = _key$split2[0],
|
|
1256
|
-
filter = _key$split2[1];
|
|
1257
|
-
if (!filters[category]) {
|
|
1258
|
-
filters[category] = {};
|
|
1259
|
-
}
|
|
1260
|
-
filters[category][filter] = queryParams[key] === 'true';
|
|
1261
|
-
} else if (key === 'query') {
|
|
1262
|
-
queryParam = queryParams[key];
|
|
1263
|
-
}
|
|
1264
|
-
});
|
|
1265
|
-
return {
|
|
1266
|
-
filters: filters,
|
|
1267
|
-
query: queryParam
|
|
1268
|
-
};
|
|
1269
|
-
};
|
|
1270
|
-
var hasFiltersInURL = function hasFiltersInURL(location) {
|
|
1271
|
-
if (!location || !location.search) return;
|
|
1272
|
-
var queryParams = parseQueryParams(location.search);
|
|
1273
|
-
if (!queryParams) return;
|
|
1274
|
-
return Object.keys(queryParams).some(function (key) {
|
|
1275
|
-
return key.includes('.');
|
|
1276
|
-
});
|
|
1277
|
-
};
|
|
1278
|
-
var hasQueryInUrl = function hasQueryInUrl(location) {
|
|
1279
|
-
if (!location || !location.search) return;
|
|
1280
|
-
var queryParams = parseQueryParams(location.search);
|
|
1281
|
-
if (!queryParams) return;
|
|
1282
|
-
return Object.keys(queryParams).includes('query');
|
|
1283
|
-
};
|
|
1284
|
-
|
|
1285
1192
|
var MapListContext = /*#__PURE__*/createContext();
|
|
1286
1193
|
var useMapList = function useMapList() {
|
|
1287
1194
|
return useContext(MapListContext);
|
|
1288
1195
|
};
|
|
1289
|
-
var getQuery = function getQuery(
|
|
1196
|
+
var getQuery = function getQuery() {
|
|
1290
1197
|
var query;
|
|
1291
|
-
if (!hasQueryInUrl(location)) {
|
|
1292
|
-
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
|
|
1198
|
+
//if (!hasQueryInUrl(location)) {
|
|
1199
|
+
query = typeof window !== 'undefined' ? localStorage.getItem('query') : '';
|
|
1200
|
+
// }
|
|
1201
|
+
//else {
|
|
1202
|
+
// query = filtersFromURL(location).query;
|
|
1203
|
+
// }
|
|
1296
1204
|
return query;
|
|
1297
1205
|
};
|
|
1298
1206
|
var MapListProvider = function MapListProvider(_ref) {
|
|
@@ -1300,8 +1208,8 @@ var MapListProvider = function MapListProvider(_ref) {
|
|
|
1300
1208
|
siteConfig = _ref.siteConfig,
|
|
1301
1209
|
resetFilters = _ref.resetFilters,
|
|
1302
1210
|
navigateToDetails = _ref.navigateToDetails;
|
|
1303
|
-
|
|
1304
|
-
|
|
1211
|
+
// const location = useLocation();
|
|
1212
|
+
// const navigate = useNavigate();
|
|
1305
1213
|
var _useState = useState(getStorageObject("listings", [])),
|
|
1306
1214
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1307
1215
|
allListings = _useState2[0],
|
|
@@ -1319,7 +1227,7 @@ var MapListProvider = function MapListProvider(_ref) {
|
|
|
1319
1227
|
mapItems = _useState8[0],
|
|
1320
1228
|
setMapItems = _useState8[1];
|
|
1321
1229
|
var _useState9 = useState(function () {
|
|
1322
|
-
return resetFilters ? null : getQuery(
|
|
1230
|
+
return resetFilters ? null : getQuery();
|
|
1323
1231
|
}),
|
|
1324
1232
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
1325
1233
|
query = _useState10[0],
|
|
@@ -1337,11 +1245,11 @@ var MapListProvider = function MapListProvider(_ref) {
|
|
|
1337
1245
|
commuteLocation = _useState16[0],
|
|
1338
1246
|
setCommuteLocation = _useState16[1];
|
|
1339
1247
|
var _useState17 = useState(function () {
|
|
1340
|
-
return resetFilters ? {} :
|
|
1248
|
+
return resetFilters ? {} : getStorageObject('selectedFilters', {});
|
|
1341
1249
|
}),
|
|
1342
1250
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
1343
1251
|
selectedFilters = _useState18[0],
|
|
1344
|
-
setSelectedFilters = _useState18[1];
|
|
1252
|
+
setSelectedFilters = _useState18[1]; //hasFiltersInURL(location) ? filtersFromURL(location).filters : getStorageObject('selectedFilters', {}));
|
|
1345
1253
|
var _useState19 = useState(),
|
|
1346
1254
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
1347
1255
|
filterOptions = _useState20[0],
|
|
@@ -1476,19 +1384,16 @@ var MapListProvider = function MapListProvider(_ref) {
|
|
|
1476
1384
|
});
|
|
1477
1385
|
}
|
|
1478
1386
|
setFilteredListings(filteredListings);
|
|
1479
|
-
if (firstLoad && hasFiltersInURL(location)) {
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
if (firstLoad && selectedFilters) {
|
|
1485
|
-
updateURLWithFilters(selectedFilters, location, navigate, query);
|
|
1486
|
-
} else if (Object.keys(selectedFilters).length === 0 && !firstLoad) {
|
|
1387
|
+
// if (firstLoad && hasFiltersInURL(location)) {
|
|
1388
|
+
// const { filters } = filtersFromURL(location);
|
|
1389
|
+
// setSelectedFilters(filters);
|
|
1390
|
+
// }
|
|
1391
|
+
if (firstLoad && selectedFilters) ; else if (Object.keys(selectedFilters).length === 0 && !firstLoad) {
|
|
1487
1392
|
localStorage.removeItem('selectedFilters');
|
|
1488
|
-
updateURLWithFilters(selectedFilters,
|
|
1393
|
+
//updateURLWithFilters(selectedFilters,location, navigate, query);
|
|
1489
1394
|
} else if (!firstLoad) {
|
|
1490
1395
|
setStorageObject('selectedFilters', selectedFilters);
|
|
1491
|
-
updateURLWithFilters(selectedFilters,
|
|
1396
|
+
//updateURLWithFilters(selectedFilters,location, navigate, query);
|
|
1492
1397
|
}
|
|
1493
1398
|
query != null ? localStorage.setItem('query', query) : localStorage.removeItem('query');
|
|
1494
1399
|
setMapItems(mapItems);
|
|
@@ -4598,23 +4503,16 @@ var HireControlMap = function HireControlMap(_ref) {
|
|
|
4598
4503
|
};
|
|
4599
4504
|
}();
|
|
4600
4505
|
fetchSiteConfig();
|
|
4601
|
-
var handlePopState = function handlePopState(event) {
|
|
4602
|
-
window.location.reload();
|
|
4603
|
-
};
|
|
4604
|
-
window.addEventListener('popstate', handlePopState);
|
|
4605
|
-
return function () {
|
|
4606
|
-
window.removeEventListener('popstate', handlePopState);
|
|
4607
|
-
};
|
|
4608
4506
|
}, [clientToken]);
|
|
4609
4507
|
var _useLoadScript = useLoadScript({
|
|
4610
4508
|
googleMapsApiKey: "AIzaSyAXPlfaoMCrmjNV1u-vFYdLBi7GkGeh4S4",
|
|
4611
4509
|
libraries: libraries
|
|
4612
4510
|
}),
|
|
4613
4511
|
isLoaded = _useLoadScript.isLoaded;
|
|
4614
|
-
return /*#__PURE__*/React.createElement(
|
|
4512
|
+
return /*#__PURE__*/React.createElement(RootLayout, null, isLoaded && siteConfig && /*#__PURE__*/React.createElement(HomeBody, {
|
|
4615
4513
|
siteConfig: siteConfig,
|
|
4616
4514
|
navigateToDetails: navigateToDetails
|
|
4617
|
-
}))
|
|
4515
|
+
}));
|
|
4618
4516
|
};
|
|
4619
4517
|
var HomeBody = function HomeBody(_ref3) {
|
|
4620
4518
|
var _siteConfig$pointsOfI, _siteConfig$pointsOfI2;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { createContext, useState, useEffect, useContext } from 'react';
|
|
2
|
-
import { useLocation, useNavigate } from 'react-router-dom';
|
|
2
|
+
// import { useLocation, useNavigate } from 'react-router-dom';
|
|
3
3
|
import fetchListings from '~/services/listingAggregatorService';
|
|
4
4
|
import {
|
|
5
5
|
generateFilterOptions,
|
|
@@ -7,35 +7,36 @@ import {
|
|
|
7
7
|
filterListingsByLocation
|
|
8
8
|
} from '~/util/filterUtil';
|
|
9
9
|
import { getStorageObject, setStorageObject } from '~/util/localStorageUtil';
|
|
10
|
-
import { updateURLWithFilters, hasFiltersInURL, filtersFromURL, hasQueryInUrl } from '~/util/urlFilterUtil';
|
|
10
|
+
//import { updateURLWithFilters, hasFiltersInURL, filtersFromURL, hasQueryInUrl } from '~/util/urlFilterUtil';
|
|
11
11
|
import { getListingEntities } from "~/services/listingEntityService";
|
|
12
12
|
|
|
13
13
|
const MapListContext = createContext();
|
|
14
14
|
|
|
15
15
|
export const useMapList = () => useContext(MapListContext);
|
|
16
16
|
|
|
17
|
-
const getQuery = (
|
|
17
|
+
const getQuery = () => {
|
|
18
18
|
let query;
|
|
19
|
-
if (!hasQueryInUrl(location)) {
|
|
19
|
+
//if (!hasQueryInUrl(location)) {
|
|
20
20
|
query = typeof window !== 'undefined' ? localStorage.getItem('query') : '';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
// }
|
|
22
|
+
//else {
|
|
23
|
+
// query = filtersFromURL(location).query;
|
|
24
|
+
// }
|
|
24
25
|
return query;
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
export const MapListProvider = ({ children, siteConfig, resetFilters, navigateToDetails }) => {
|
|
28
|
-
const location = useLocation();
|
|
29
|
-
const navigate = useNavigate();
|
|
29
|
+
// const location = useLocation();
|
|
30
|
+
// const navigate = useNavigate();
|
|
30
31
|
const [allListings, setAllListings] = useState(getStorageObject("listings",[]));
|
|
31
32
|
const [filteredListings, setFilteredListings] = useState([]);
|
|
32
33
|
const [loading, setLoading] = useState(false);
|
|
33
34
|
const [mapItems, setMapItems] = useState(getStorageObject('mapItems', []));
|
|
34
|
-
const [query, setQuery] = useState(() => resetFilters ? null : getQuery(
|
|
35
|
+
const [query, setQuery] = useState(() => resetFilters ? null : getQuery());
|
|
35
36
|
const [listingEntities, setListingEntities] = useState(getStorageObject("listingEntities",null));
|
|
36
37
|
const [firstLoad, setFirstLoad] = useState(true);
|
|
37
38
|
const [commuteLocation, setCommuteLocation] = useState(null);
|
|
38
|
-
const [selectedFilters, setSelectedFilters] = useState(() => resetFilters ? {} : hasFiltersInURL(location) ? filtersFromURL(location).filters : getStorageObject('selectedFilters', {}));
|
|
39
|
+
const [selectedFilters, setSelectedFilters] = useState(() => resetFilters ? {} : getStorageObject('selectedFilters', {}));//hasFiltersInURL(location) ? filtersFromURL(location).filters : getStorageObject('selectedFilters', {}));
|
|
39
40
|
const [filterOptions, setFilterOptions] = useState();
|
|
40
41
|
const [recruiters, setRecruiters] = useState(getStorageObject("recruiters", {}));
|
|
41
42
|
const [filterDialogIsOpen, setFilterDialogIsOpen] = useState(false);
|
|
@@ -123,18 +124,18 @@ export const MapListProvider = ({ children, siteConfig, resetFilters, navigateTo
|
|
|
123
124
|
filteredListings = filteredListings.filter(x => favorites.includes(x.id));
|
|
124
125
|
}
|
|
125
126
|
setFilteredListings(filteredListings);
|
|
126
|
-
if (firstLoad && hasFiltersInURL(location)) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
127
|
+
// if (firstLoad && hasFiltersInURL(location)) {
|
|
128
|
+
// const { filters } = filtersFromURL(location);
|
|
129
|
+
// setSelectedFilters(filters);
|
|
130
|
+
// }
|
|
130
131
|
if (firstLoad && selectedFilters) {
|
|
131
|
-
updateURLWithFilters(selectedFilters,location, navigate, query);
|
|
132
|
+
//updateURLWithFilters(selectedFilters,location, navigate, query);
|
|
132
133
|
} else if (Object.keys(selectedFilters).length === 0 && !firstLoad) {
|
|
133
134
|
localStorage.removeItem('selectedFilters');
|
|
134
|
-
updateURLWithFilters(selectedFilters,location, navigate, query);
|
|
135
|
+
//updateURLWithFilters(selectedFilters,location, navigate, query);
|
|
135
136
|
} else if (!firstLoad) {
|
|
136
137
|
setStorageObject('selectedFilters', selectedFilters);
|
|
137
|
-
updateURLWithFilters(selectedFilters,location, navigate, query);
|
|
138
|
+
//updateURLWithFilters(selectedFilters,location, navigate, query);
|
|
138
139
|
}
|
|
139
140
|
query != null ? localStorage.setItem('query', query) : localStorage.removeItem('query');
|
|
140
141
|
setMapItems(mapItems);
|
package/src/index.js
CHANGED
|
@@ -7,7 +7,6 @@ import { useLoadScript } from '@react-google-maps/api';
|
|
|
7
7
|
import { MapProvider } from '~/contexts/mapContext';
|
|
8
8
|
import { PlacesProvider } from '~/contexts/placesContext';
|
|
9
9
|
import { MapListProvider } from '~/contexts/mapListContext';
|
|
10
|
-
import { BrowserRouter as Router } from 'react-router-dom';
|
|
11
10
|
import './index.css';
|
|
12
11
|
import RootLayout from './components/layout/layout';
|
|
13
12
|
import { getMapConfig } from '~/services/configService';
|
|
@@ -30,16 +29,6 @@ export const HireControlMap = ({ clientToken, navigateToDetails = null }) => {
|
|
|
30
29
|
};
|
|
31
30
|
|
|
32
31
|
fetchSiteConfig();
|
|
33
|
-
|
|
34
|
-
const handlePopState = (event) => {
|
|
35
|
-
window.location.reload();
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
window.addEventListener('popstate', handlePopState);
|
|
39
|
-
|
|
40
|
-
return () => {
|
|
41
|
-
window.removeEventListener('popstate', handlePopState);
|
|
42
|
-
};
|
|
43
32
|
}, [clientToken]);
|
|
44
33
|
|
|
45
34
|
const { isLoaded } = useLoadScript({
|
|
@@ -48,13 +37,11 @@ export const HireControlMap = ({ clientToken, navigateToDetails = null }) => {
|
|
|
48
37
|
});
|
|
49
38
|
|
|
50
39
|
return (
|
|
51
|
-
<Router>
|
|
52
40
|
<RootLayout>
|
|
53
41
|
{isLoaded && siteConfig && (
|
|
54
42
|
<HomeBody siteConfig={siteConfig} navigateToDetails={navigateToDetails} />
|
|
55
43
|
)}
|
|
56
44
|
</RootLayout>
|
|
57
|
-
</Router>
|
|
58
45
|
);
|
|
59
46
|
};
|
|
60
47
|
|