sr-npm 1.7.272 → 1.7.274

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.
@@ -44,7 +44,7 @@ async function fetchPositionsFromSRAPI() {
44
44
  page++;
45
45
 
46
46
  // Build the API path - first request has no page parameter, subsequent use nextPageId
47
- let apiPath = `/v1/companies/${companyId.value}/postings?offset=${offset}`;
47
+ const apiPath = `/v1/companies/${companyId.value}/postings?offset=${offset}`;
48
48
 
49
49
  console.log(`Fetching page ${page} with path: ${apiPath}`);
50
50
  const response = await makeSmartRecruitersRequest(apiPath,token);
@@ -1,29 +1,20 @@
1
1
  const { secrets } = require("@wix/secrets");
2
2
  const { auth } = require('@wix/essentials');
3
3
 
4
+ const getSecretValue = auth.elevate(secrets.getSecretValue);
4
5
 
5
6
  function getSmartToken() {
6
- const elevatedGetSecretValue = auth.elevate(secrets.getSecretValue);
7
- return elevatedGetSecretValue("x-smarttoken")
7
+ return getSecretValue("x-smarttoken")
8
8
  .then((secret) => {
9
9
  return secret;
10
10
  })
11
- .catch((error) => {
12
- console.error(error);
13
- throw error;
14
- });
15
11
  }
16
12
 
17
13
  function getCompanyId() {
18
- const elevatedGetSecretValue = auth.elevate(secrets.getSecretValue);
19
- return elevatedGetSecretValue("companyID")
14
+ return getSecretValue("companyID")
20
15
  .then((secret) => {
21
16
  return secret;
22
17
  })
23
- .catch((error) => {
24
- console.error(error);
25
- throw error;
26
- });
27
18
  }
28
19
  module.exports = {
29
20
  getSmartToken,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.272",
3
+ "version": "1.7.274",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -7,7 +7,7 @@ const {
7
7
  debounce,
8
8
  getFilter,
9
9
  } = require('../public/filterUtils');
10
-
10
+ const { filterBrokenMarkers } = require('../public/utils');
11
11
  let currentLoadedItems =100;
12
12
  const itemsPerPage = 100;
13
13
  let allJobs=[]
@@ -160,9 +160,8 @@ async function bind(_$w) {
160
160
  }
161
161
 
162
162
  function init(_$w) {
163
- const debouncedSearch = debounce(()=>applyFilters(_$w), 400,thisObjectVar);
164
163
 
165
- _$w('#searchInput').onInput(debouncedSearch);
164
+ _$w('#searchInput').onInput(onchangeSearchInput);
166
165
  _$w('#dropdownDepartment, #dropdownLocation, #dropdownJobType').onChange(()=>applyFilters(_$w));
167
166
  _$w('#resetFiltersButton, #clearSearch').onClick(()=>resetFilters(_$w));
168
167
 
@@ -176,6 +175,12 @@ function init(_$w) {
176
175
 
177
176
  }
178
177
 
178
+ function onchangeSearchInput(_$w){
179
+ const debouncedSearch = debounce(()=>applyFilters(_$w), 400,thisObjectVar);
180
+ debouncedSearch();
181
+ _$w('#searchInput').focus();
182
+ }
183
+
179
184
  async function applyFilters(_$w, skipUrlUpdate = false) {
180
185
  console.log("applying filters");
181
186
  const dropdownFiltersMapping = [
@@ -250,6 +255,8 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
250
255
  // Update reset button state
251
256
  const hasActiveFilters = filters.length > 0;
252
257
  hasActiveFilters? _$w('#resetFiltersButton').enable() : _$w('#resetFiltersButton').disable();
258
+
259
+
253
260
  }
254
261
 
255
262
  async function resetFilters(_$w) {
@@ -349,20 +356,7 @@ async function handleLocationParam(_$w,location) {
349
356
  async function updateMapMarkers(_$w){
350
357
  const numOfItems = await _$w('#jobsDataset').getTotalCount();
351
358
  const items = await _$w('#jobsDataset').getItems(0, numOfItems);
352
- const markers = items.items
353
- .filter(item => {
354
- const locationAddress = item.locationAddress;
355
- const location = locationAddress && locationAddress.location;
356
- return (
357
- location !== undefined &&
358
- location !== null &&
359
- location.latitude !== undefined &&
360
- location.latitude !== null &&
361
- location.longitude !== undefined &&
362
- location.longitude !== null
363
- );
364
- })
365
- .map(item => {
359
+ const markers = filterBrokenMarkers(items.items).map(item => {
366
360
  const location = item.locationAddress.location;
367
361
  return {
368
362
  location: {
package/pages/homePage.js CHANGED
@@ -3,6 +3,7 @@ const {
3
3
  getFilter,
4
4
  } = require('../public/filterUtils');
5
5
  const { handleOnLocationClick } = require('../public/mapUtils');
6
+ const { filterBrokenMarkers } = require('../public/utils');
6
7
  const { location } = require('@wix/site-location');
7
8
  let thisObjectVar;
8
9
  async function homePageOnReady(_$w,thisObject) {
@@ -25,7 +26,7 @@ async function homePageOnReady(_$w,thisObject) {
25
26
  const numOfItems = await _$w('#citiesDataset').getTotalCount();
26
27
  const items = await _$w('#citiesDataset').getItems(0, numOfItems);
27
28
  let baseUrl = await location.baseUrl();
28
- const markers = items.items.map(item => {
29
+ const markers = filterBrokenMarkers(items.items).map(item => {
29
30
  const location = item.locationAddress.location;
30
31
  const cityName = encodeURIComponent(item.title); // Use the city name from the item
31
32
  const cityLinkUrl = `${baseUrl}/positions?location=${cityName}`; // Add city as search parameter
package/public/utils.js CHANGED
@@ -22,7 +22,24 @@ function htmlToText(html) {
22
22
  return text.replace(/\n\s*\n+/g, '\n\n').replace(/[ \t]+\n/g, '\n').trim();
23
23
  }
24
24
 
25
+ function filterBrokenMarkers(items) {
26
+ return items
27
+ .filter(item => {
28
+ const locationAddress = item.locationAddress;
29
+ const location = locationAddress && locationAddress.location;
30
+ return (
31
+ location !== undefined &&
32
+ location !== null &&
33
+ location.latitude !== undefined &&
34
+ location.latitude !== null &&
35
+ location.longitude !== undefined &&
36
+ location.longitude !== null
37
+ );
38
+ })
39
+ }
40
+
25
41
 
26
42
  module.exports = {
27
- htmlToText
43
+ htmlToText,
44
+ filterBrokenMarkers
28
45
  };