@abcagency/hc-ui-components 1.0.3 → 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 -127
- 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/src/util/urlFilterUtil.js +29 -30
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,113 +1189,18 @@ var setStorageObject = function setStorageObject(key, item) {
|
|
|
1189
1189
|
}
|
|
1190
1190
|
};
|
|
1191
1191
|
|
|
1192
|
-
var updateURLWithFilters = function updateURLWithFilters(filters, location, navigate, query) {
|
|
1193
|
-
console.log("attempting to update url");
|
|
1194
|
-
console.log(filters);
|
|
1195
|
-
console.log(location);
|
|
1196
|
-
console.log(navigate);
|
|
1197
|
-
console.log(query);
|
|
1198
|
-
var searchParams = new URLSearchParams();
|
|
1199
|
-
|
|
1200
|
-
// Add the new filters to search params
|
|
1201
|
-
Object.keys(filters).forEach(function (category) {
|
|
1202
|
-
Object.keys(filters[category]).forEach(function (filter) {
|
|
1203
|
-
if (filters[category][filter]) {
|
|
1204
|
-
var key = "".concat(category, ".").concat(filter);
|
|
1205
|
-
searchParams.set(key, 'true');
|
|
1206
|
-
}
|
|
1207
|
-
});
|
|
1208
|
-
});
|
|
1209
|
-
|
|
1210
|
-
// Add the query to search params if it exists
|
|
1211
|
-
if (query) {
|
|
1212
|
-
searchParams.set('query', query);
|
|
1213
|
-
}
|
|
1214
|
-
navigate({
|
|
1215
|
-
search: searchParams.toString()
|
|
1216
|
-
}, {
|
|
1217
|
-
replace: true
|
|
1218
|
-
});
|
|
1219
|
-
notifyParentOfUrlChange();
|
|
1220
|
-
};
|
|
1221
|
-
function notifyParentOfUrlChange() {
|
|
1222
|
-
setTimeout(function () {
|
|
1223
|
-
var message = {
|
|
1224
|
-
type: 'URL_CHANGE',
|
|
1225
|
-
url: window.location.href
|
|
1226
|
-
};
|
|
1227
|
-
window.parent.postMessage(message, "*");
|
|
1228
|
-
}, 500);
|
|
1229
|
-
}
|
|
1230
|
-
var parseQueryParams = function parseQueryParams(search) {
|
|
1231
|
-
var queryParams = {};
|
|
1232
|
-
if (!search) return queryParams;
|
|
1233
|
-
var queryString = search.split('?')[1];
|
|
1234
|
-
if (!queryString) {
|
|
1235
|
-
return queryParams;
|
|
1236
|
-
}
|
|
1237
|
-
queryString = queryString.replaceAll('+', ' ');
|
|
1238
|
-
queryString.split('&').forEach(function (param) {
|
|
1239
|
-
var _param$split = param.split('='),
|
|
1240
|
-
_param$split2 = _slicedToArray(_param$split, 2),
|
|
1241
|
-
key = _param$split2[0],
|
|
1242
|
-
value = _param$split2[1];
|
|
1243
|
-
queryParams[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
1244
|
-
});
|
|
1245
|
-
return queryParams;
|
|
1246
|
-
};
|
|
1247
|
-
var filtersFromURL = function filtersFromURL(location) {
|
|
1248
|
-
if (!location || !location.search) return;
|
|
1249
|
-
var filters = {};
|
|
1250
|
-
var queryParam = null;
|
|
1251
|
-
var queryParams = parseQueryParams(location.search);
|
|
1252
|
-
if (!queryParams) return;
|
|
1253
|
-
Object.keys(queryParams).forEach(function (key) {
|
|
1254
|
-
if (key && key.includes('.')) {
|
|
1255
|
-
var _key$split = key.split('.'),
|
|
1256
|
-
_key$split2 = _slicedToArray(_key$split, 2),
|
|
1257
|
-
category = _key$split2[0],
|
|
1258
|
-
filter = _key$split2[1];
|
|
1259
|
-
if (!filters[category]) {
|
|
1260
|
-
filters[category] = {};
|
|
1261
|
-
}
|
|
1262
|
-
filters[category][filter] = queryParams[key] === 'true';
|
|
1263
|
-
} else if (key === 'query') {
|
|
1264
|
-
queryParam = queryParams[key];
|
|
1265
|
-
}
|
|
1266
|
-
});
|
|
1267
|
-
return {
|
|
1268
|
-
filters: filters,
|
|
1269
|
-
query: queryParam
|
|
1270
|
-
};
|
|
1271
|
-
};
|
|
1272
|
-
var hasFiltersInURL = function hasFiltersInURL(location) {
|
|
1273
|
-
if (!location || !location.search) return;
|
|
1274
|
-
var queryParams = parseQueryParams(location.search);
|
|
1275
|
-
if (!queryParams) return;
|
|
1276
|
-
return Object.keys(queryParams).some(function (key) {
|
|
1277
|
-
return key.includes('.');
|
|
1278
|
-
});
|
|
1279
|
-
};
|
|
1280
|
-
var hasQueryInUrl = function hasQueryInUrl(location) {
|
|
1281
|
-
console.log(location);
|
|
1282
|
-
if (!location || !location.search) return;
|
|
1283
|
-
var queryParams = parseQueryParams(location.search);
|
|
1284
|
-
if (!queryParams) return;
|
|
1285
|
-
return Object.keys(queryParams).includes('query');
|
|
1286
|
-
};
|
|
1287
|
-
|
|
1288
1192
|
var MapListContext = /*#__PURE__*/createContext();
|
|
1289
1193
|
var useMapList = function useMapList() {
|
|
1290
1194
|
return useContext(MapListContext);
|
|
1291
1195
|
};
|
|
1292
|
-
var getQuery = function getQuery(
|
|
1196
|
+
var getQuery = function getQuery() {
|
|
1293
1197
|
var query;
|
|
1294
|
-
if (!hasQueryInUrl(location)) {
|
|
1295
|
-
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
|
|
1198
|
+
//if (!hasQueryInUrl(location)) {
|
|
1199
|
+
query = typeof window !== 'undefined' ? localStorage.getItem('query') : '';
|
|
1200
|
+
// }
|
|
1201
|
+
//else {
|
|
1202
|
+
// query = filtersFromURL(location).query;
|
|
1203
|
+
// }
|
|
1299
1204
|
return query;
|
|
1300
1205
|
};
|
|
1301
1206
|
var MapListProvider = function MapListProvider(_ref) {
|
|
@@ -1303,8 +1208,8 @@ var MapListProvider = function MapListProvider(_ref) {
|
|
|
1303
1208
|
siteConfig = _ref.siteConfig,
|
|
1304
1209
|
resetFilters = _ref.resetFilters,
|
|
1305
1210
|
navigateToDetails = _ref.navigateToDetails;
|
|
1306
|
-
|
|
1307
|
-
|
|
1211
|
+
// const location = useLocation();
|
|
1212
|
+
// const navigate = useNavigate();
|
|
1308
1213
|
var _useState = useState(getStorageObject("listings", [])),
|
|
1309
1214
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1310
1215
|
allListings = _useState2[0],
|
|
@@ -1322,7 +1227,7 @@ var MapListProvider = function MapListProvider(_ref) {
|
|
|
1322
1227
|
mapItems = _useState8[0],
|
|
1323
1228
|
setMapItems = _useState8[1];
|
|
1324
1229
|
var _useState9 = useState(function () {
|
|
1325
|
-
return resetFilters ? null : getQuery(
|
|
1230
|
+
return resetFilters ? null : getQuery();
|
|
1326
1231
|
}),
|
|
1327
1232
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
1328
1233
|
query = _useState10[0],
|
|
@@ -1340,11 +1245,11 @@ var MapListProvider = function MapListProvider(_ref) {
|
|
|
1340
1245
|
commuteLocation = _useState16[0],
|
|
1341
1246
|
setCommuteLocation = _useState16[1];
|
|
1342
1247
|
var _useState17 = useState(function () {
|
|
1343
|
-
return resetFilters ? {} :
|
|
1248
|
+
return resetFilters ? {} : getStorageObject('selectedFilters', {});
|
|
1344
1249
|
}),
|
|
1345
1250
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
1346
1251
|
selectedFilters = _useState18[0],
|
|
1347
|
-
setSelectedFilters = _useState18[1];
|
|
1252
|
+
setSelectedFilters = _useState18[1]; //hasFiltersInURL(location) ? filtersFromURL(location).filters : getStorageObject('selectedFilters', {}));
|
|
1348
1253
|
var _useState19 = useState(),
|
|
1349
1254
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
1350
1255
|
filterOptions = _useState20[0],
|
|
@@ -1479,19 +1384,16 @@ var MapListProvider = function MapListProvider(_ref) {
|
|
|
1479
1384
|
});
|
|
1480
1385
|
}
|
|
1481
1386
|
setFilteredListings(filteredListings);
|
|
1482
|
-
if (firstLoad && hasFiltersInURL(location)) {
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
if (firstLoad && selectedFilters) {
|
|
1488
|
-
updateURLWithFilters(selectedFilters, location, navigate, query);
|
|
1489
|
-
} 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) {
|
|
1490
1392
|
localStorage.removeItem('selectedFilters');
|
|
1491
|
-
updateURLWithFilters(selectedFilters,
|
|
1393
|
+
//updateURLWithFilters(selectedFilters,location, navigate, query);
|
|
1492
1394
|
} else if (!firstLoad) {
|
|
1493
1395
|
setStorageObject('selectedFilters', selectedFilters);
|
|
1494
|
-
updateURLWithFilters(selectedFilters,
|
|
1396
|
+
//updateURLWithFilters(selectedFilters,location, navigate, query);
|
|
1495
1397
|
}
|
|
1496
1398
|
query != null ? localStorage.setItem('query', query) : localStorage.removeItem('query');
|
|
1497
1399
|
setMapItems(mapItems);
|
|
@@ -4601,23 +4503,16 @@ var HireControlMap = function HireControlMap(_ref) {
|
|
|
4601
4503
|
};
|
|
4602
4504
|
}();
|
|
4603
4505
|
fetchSiteConfig();
|
|
4604
|
-
var handlePopState = function handlePopState(event) {
|
|
4605
|
-
window.location.reload();
|
|
4606
|
-
};
|
|
4607
|
-
window.addEventListener('popstate', handlePopState);
|
|
4608
|
-
return function () {
|
|
4609
|
-
window.removeEventListener('popstate', handlePopState);
|
|
4610
|
-
};
|
|
4611
4506
|
}, [clientToken]);
|
|
4612
4507
|
var _useLoadScript = useLoadScript({
|
|
4613
4508
|
googleMapsApiKey: "AIzaSyAXPlfaoMCrmjNV1u-vFYdLBi7GkGeh4S4",
|
|
4614
4509
|
libraries: libraries
|
|
4615
4510
|
}),
|
|
4616
4511
|
isLoaded = _useLoadScript.isLoaded;
|
|
4617
|
-
return /*#__PURE__*/React.createElement(
|
|
4512
|
+
return /*#__PURE__*/React.createElement(RootLayout, null, isLoaded && siteConfig && /*#__PURE__*/React.createElement(HomeBody, {
|
|
4618
4513
|
siteConfig: siteConfig,
|
|
4619
4514
|
navigateToDetails: navigateToDetails
|
|
4620
|
-
}))
|
|
4515
|
+
}));
|
|
4621
4516
|
};
|
|
4622
4517
|
var HomeBody = function HomeBody(_ref3) {
|
|
4623
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
|
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
export const updateURLWithFilters = (filters, location, navigate, query) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
2
|
+
const searchParams = new URLSearchParams(location.search);
|
|
3
|
+
|
|
4
|
+
Object.keys(Object.fromEntries(searchParams)).forEach(key => {
|
|
5
|
+
if (!key.includes('.') && key !== 'query') {
|
|
6
|
+
searchParams.set(key, searchParams.get(key));
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
if (query) {
|
|
11
|
+
searchParams.set('query', query);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
Object.keys(filters).forEach(category => {
|
|
15
|
+
Object.keys(filters[category]).forEach(filter => {
|
|
16
|
+
const key = `${category}.${filter}`;
|
|
17
|
+
if (filters[category][filter]) {
|
|
18
|
+
searchParams.set(key, 'true');
|
|
19
|
+
} else {
|
|
20
|
+
searchParams.delete(key);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
navigate({
|
|
26
|
+
search: searchParams.toString(),
|
|
27
|
+
}, { replace: true });
|
|
28
|
+
|
|
29
|
+
notifyParentOfUrlChange();
|
|
30
|
+
};
|
|
31
31
|
|
|
32
32
|
function notifyParentOfUrlChange() {
|
|
33
33
|
setTimeout(() => {
|
|
@@ -83,7 +83,6 @@ export const hasFiltersInURL = location => {
|
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
export const hasQueryInUrl = location => {
|
|
86
|
-
console.log(location);
|
|
87
86
|
if (!location || !location.search) return;
|
|
88
87
|
const queryParams = parseQueryParams(location.search);
|
|
89
88
|
if (!queryParams) return;
|