@abcagency/hc-ui-components 1.3.14 → 1.3.16

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 (166) 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 +15 -5
  6. package/dist/components/HireControlMap.js.map +1 -1
  7. package/dist/components/modules/accordions/MapAccordionItem.js +11 -1
  8. package/dist/components/modules/accordions/MapAccordionItem.js.map +1 -1
  9. package/dist/components/modules/accordions/default.js.map +1 -1
  10. package/dist/components/modules/accordions/filterItem.js +2 -1
  11. package/dist/components/modules/accordions/filterItem.js.map +1 -1
  12. package/dist/components/modules/accordions/filters.js +0 -3
  13. package/dist/components/modules/accordions/filters.js.map +1 -1
  14. package/dist/components/modules/buttons/button-group-apply.js +36 -15
  15. package/dist/components/modules/buttons/button-group-apply.js.map +1 -1
  16. package/dist/components/modules/buttons/commute-pill.js.map +1 -1
  17. package/dist/components/modules/buttons/default.js.map +1 -1
  18. package/dist/components/modules/buttons/items-pill.js.map +1 -1
  19. package/dist/components/modules/buttons/pill-wrapper.js.map +1 -1
  20. package/dist/components/modules/buttons/show-all-button.js.map +1 -1
  21. package/dist/components/modules/cards/default.js.map +1 -1
  22. package/dist/components/modules/cards/filter.js.map +1 -1
  23. package/dist/components/modules/dialogs/apply-dialog.js.map +1 -1
  24. package/dist/components/modules/filter/commute.js +22 -6
  25. package/dist/components/modules/filter/commute.js.map +1 -1
  26. package/dist/components/modules/filter/index.js +7 -0
  27. package/dist/components/modules/filter/index.js.map +1 -1
  28. package/dist/components/modules/filter/item.js +16 -1
  29. package/dist/components/modules/filter/item.js.map +1 -1
  30. package/dist/components/modules/filter/location.js +1 -1
  31. package/dist/components/modules/filter/location.js.map +1 -1
  32. package/dist/components/modules/filter/points-of-interest.js.map +1 -1
  33. package/dist/components/modules/filter/radio-item.js +7 -0
  34. package/dist/components/modules/filter/radio-item.js.map +1 -1
  35. package/dist/components/modules/filter/search.js.map +1 -1
  36. package/dist/components/modules/filter/sort.js.map +1 -1
  37. package/dist/components/modules/grid.js.map +1 -1
  38. package/dist/components/modules/icon.js.map +1 -1
  39. package/dist/components/modules/jobListing/listing-details.js +6 -0
  40. package/dist/components/modules/jobListing/listing-details.js.map +1 -1
  41. package/dist/components/modules/maps/info-window-card.js.map +1 -1
  42. package/dist/components/modules/maps/info-window-content.js +20 -0
  43. package/dist/components/modules/maps/info-window-content.js.map +1 -1
  44. package/dist/components/modules/maps/list/field-mapper.js.map +1 -1
  45. package/dist/components/modules/maps/list/header-item.js.map +1 -1
  46. package/dist/components/modules/maps/list/header.js.map +1 -1
  47. package/dist/components/modules/maps/list/index.js +21 -12
  48. package/dist/components/modules/maps/list/index.js.map +1 -1
  49. package/dist/components/modules/maps/list/item-expand-card/index.js.map +1 -1
  50. package/dist/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js.map +1 -1
  51. package/dist/components/modules/maps/list/item-expand-card/recruiter-details.js.map +1 -1
  52. package/dist/components/modules/maps/list/item-expand-card/recruiter-headshot.js.map +1 -1
  53. package/dist/components/modules/maps/list/list-item/index.js +12 -2
  54. package/dist/components/modules/maps/list/list-item/index.js.map +1 -1
  55. package/dist/components/modules/maps/map-list.js.map +1 -1
  56. package/dist/components/modules/maps/map-marker.js +10 -0
  57. package/dist/components/modules/maps/map-marker.js.map +1 -1
  58. package/dist/components/modules/maps/map.js.map +1 -1
  59. package/dist/components/modules/maps/place-marker.js.map +1 -1
  60. package/dist/components/modules/maps/tabs.js.map +1 -1
  61. package/dist/constants/eventTypes.js +16 -0
  62. package/dist/constants/eventTypes.js.map +1 -0
  63. package/dist/constants/placeTypes.js.map +1 -1
  64. package/dist/contexts/mapContext.js +9 -27
  65. package/dist/contexts/mapContext.js.map +1 -1
  66. package/dist/contexts/mapListContext.js +57 -38
  67. package/dist/contexts/mapListContext.js.map +1 -1
  68. package/dist/contexts/placesContext.js.map +1 -1
  69. package/dist/contexts/trackEventContext.js +20 -0
  70. package/dist/contexts/trackEventContext.js.map +1 -0
  71. package/dist/hooks/useList.js +1 -13
  72. package/dist/hooks/useList.js.map +1 -1
  73. package/dist/services/apis/hcApi.js +1 -1
  74. package/dist/services/apis/hcApi.js.map +1 -1
  75. package/dist/services/clientToken.js.map +1 -1
  76. package/dist/services/configService.js.map +1 -1
  77. package/dist/services/googlePlacesNearbyService.js.map +1 -1
  78. package/dist/services/listingAggregatorService.js +43 -16
  79. package/dist/services/listingAggregatorService.js.map +1 -1
  80. package/dist/services/listingEntityService.js.map +1 -1
  81. package/dist/services/listingService.js.map +1 -1
  82. package/dist/services/recruiterService.js.map +1 -1
  83. package/dist/util/filterUtil.js.map +1 -1
  84. package/dist/util/loading.js.map +1 -1
  85. package/dist/util/localStorageUtil.js.map +1 -1
  86. package/dist/util/mapIconUtil.js.map +1 -1
  87. package/dist/util/mapUtil.js.map +1 -1
  88. package/dist/util/sortUtil.js.map +1 -1
  89. package/dist/util/stringUtils.js.map +1 -1
  90. package/jsconfig.json +7 -7
  91. package/package.json +60 -60
  92. package/postcss.config.js +13 -13
  93. package/preset.default.js +15 -15
  94. package/rollup.config.mjs +88 -87
  95. package/src/apis/hcApi.js +93 -93
  96. package/src/clientToken.js +9 -9
  97. package/src/components/HireControlMap.js +129 -124
  98. package/src/components/modules/accordions/MapAccordionItem.js +74 -72
  99. package/src/components/modules/accordions/default.js +171 -171
  100. package/src/components/modules/accordions/filterItem.js +55 -53
  101. package/src/components/modules/accordions/filters.js +47 -47
  102. package/src/components/modules/buttons/button-group-apply.js +123 -116
  103. package/src/components/modules/buttons/commute-pill.js +22 -22
  104. package/src/components/modules/buttons/default.js +194 -194
  105. package/src/components/modules/buttons/items-pill.js +35 -35
  106. package/src/components/modules/buttons/pill-wrapper.js +27 -27
  107. package/src/components/modules/buttons/show-all-button.js +20 -20
  108. package/src/components/modules/cards/default.js +167 -167
  109. package/src/components/modules/cards/filter.js +56 -56
  110. package/src/components/modules/dialogs/apply-dialog.js +48 -48
  111. package/src/components/modules/filter/commute.js +154 -149
  112. package/src/components/modules/filter/index.js +89 -87
  113. package/src/components/modules/filter/item.js +87 -76
  114. package/src/components/modules/filter/location.js +71 -71
  115. package/src/components/modules/filter/points-of-interest.js +44 -44
  116. package/src/components/modules/filter/radio-item.js +57 -53
  117. package/src/components/modules/filter/search.js +92 -92
  118. package/src/components/modules/filter/sort.js +83 -83
  119. package/src/components/modules/grid.js +54 -54
  120. package/src/components/modules/icon.js +33 -33
  121. package/src/components/modules/jobListing/listing-details.js +99 -95
  122. package/src/components/modules/maps/info-window-card.js +17 -17
  123. package/src/components/modules/maps/info-window-content.js +81 -74
  124. package/src/components/modules/maps/list/field-mapper.js +112 -112
  125. package/src/components/modules/maps/list/header-item.js +91 -91
  126. package/src/components/modules/maps/list/header.js +47 -47
  127. package/src/components/modules/maps/list/index.js +112 -107
  128. package/src/components/modules/maps/list/item-expand-card/index.js +22 -22
  129. package/src/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js +50 -50
  130. package/src/components/modules/maps/list/item-expand-card/recruiter-details.js +68 -68
  131. package/src/components/modules/maps/list/item-expand-card/recruiter-headshot.js +22 -22
  132. package/src/components/modules/maps/list/list-item/index.js +135 -133
  133. package/src/components/modules/maps/map-list.js +74 -74
  134. package/src/components/modules/maps/map-marker.js +88 -86
  135. package/src/components/modules/maps/map.js +230 -230
  136. package/src/components/modules/maps/place-marker.js +41 -41
  137. package/src/components/modules/maps/tabs.js +81 -81
  138. package/src/constants/eventTypes.js +13 -0
  139. package/src/constants/placeTypes.js +8 -8
  140. package/src/contexts/mapContext.js +101 -115
  141. package/src/contexts/mapListContext.js +242 -222
  142. package/src/contexts/placesContext.js +102 -102
  143. package/src/contexts/trackEventContext.js +14 -0
  144. package/src/hooks/useList.js +89 -100
  145. package/src/index.js +3 -3
  146. package/src/services/configService.js +16 -16
  147. package/src/services/googlePlacesNearbyService.js +33 -33
  148. package/src/services/listingAggregatorService.js +50 -45
  149. package/src/services/listingEntityService.js +15 -15
  150. package/src/services/listingService.js +26 -26
  151. package/src/services/recruiterService.js +17 -17
  152. package/src/styles/index.css +23 -23
  153. package/src/util/arrayUtil.js +3 -3
  154. package/src/util/fieldMapper.js +22 -22
  155. package/src/util/filterUtil.js +195 -195
  156. package/src/util/loading.js +17 -17
  157. package/src/util/localStorageUtil.js +26 -26
  158. package/src/util/mapIconUtil.js +180 -180
  159. package/src/util/mapUtil.js +91 -91
  160. package/src/util/sortUtil.js +32 -32
  161. package/src/util/stringUtils.js +6 -6
  162. package/src/util/urlFilterUtil.js +90 -90
  163. package/tailwind.config.js +126 -126
  164. package/.editorconfig +0 -12
  165. package/.eslintrc +0 -105
  166. package/.prettierignore +0 -3
@@ -1,48 +1,48 @@
1
- import React from 'react';
2
- import * as Dialog from '@radix-ui/react-dialog';
3
-
4
- import Button from '~/components/modules/buttons/default';
5
- import Icon from '~/components/modules/icon';
6
-
7
- const ApplyDialog = ({ children, applyUrl, internalApplyLink, companyName }) => (
8
-
9
- <Dialog.Root >
10
- <Dialog.Trigger asChild>
11
- {children}
12
- </Dialog.Trigger>
13
- <Dialog.Portal>
14
- <Dialog.Overlay className="hc-bg-black/50 hc-fixed hc-inset-0 hc-animate-overlayShow" />
15
- <Dialog.Content className="hc-fit-content hc-animate-contentShow hc-fixed hc-inset-0 hc-m-auto hc-max-h-[85vh] hc-w-[90vw] hc-max-w-[450px] hc-rounded-[6px] hc-bg-white hc-p-[25px] hc-shadow-lg focus:hc-outline-none hc-flex hc-flex-col hc-items-center hc-text-center">
16
- <Dialog.Title className="hc-text-[17px] hc-font-medium hc-w-full">
17
- Career Opportunities
18
- </Dialog.Title>
19
- <Dialog.Description className="hc-mt-4 hc-mb-5 hc-text-[15px] hc-leading-normal hc-w-full">
20
- Are you currently a {companyName} employee?
21
- </Dialog.Description>
22
- <div className="hc-flex hc-justify-center hc-space-x-4 hc-w-full">
23
- <Dialog.Close asChild>
24
- <Button.Anchor variant="outline" href={internalApplyLink}>
25
- Yes
26
- </Button.Anchor>
27
- </Dialog.Close>
28
- <Dialog.Close asChild>
29
- <Button.Anchor variant="primary" href={applyUrl}>
30
- No
31
- </Button.Anchor>
32
- </Dialog.Close>
33
- </div>
34
- <Dialog.Close asChild>
35
- <Button.Anchor className="hc-absolute hc-top-[10px] hc-right-[10px] hc-inline-flex hc-h-[25px] hc-w-[25px] hc-items-center hc-justify-center hc-rounded-full focus:hc-outline-none"
36
- variant="ghost" aria-label="Close">
37
- <Icon
38
- icon="mdi:times"
39
- className="hc-cursor-pointer hc-text-black hover:hc-text-gray-500 hover:hc-opacity-75"
40
- />
41
- </Button.Anchor>
42
- </Dialog.Close>
43
- </Dialog.Content>
44
- </Dialog.Portal>
45
- </Dialog.Root>
46
- );
47
-
48
- export default ApplyDialog;
1
+ import React from 'react';
2
+ import * as Dialog from '@radix-ui/react-dialog';
3
+
4
+ import Button from '~/components/modules/buttons/default';
5
+ import Icon from '~/components/modules/icon';
6
+
7
+ const ApplyDialog = ({ children, applyUrl, internalApplyLink, companyName }) => (
8
+
9
+ <Dialog.Root >
10
+ <Dialog.Trigger asChild>
11
+ {children}
12
+ </Dialog.Trigger>
13
+ <Dialog.Portal>
14
+ <Dialog.Overlay className="hc-bg-black/50 hc-fixed hc-inset-0 hc-animate-overlayShow" />
15
+ <Dialog.Content className="hc-fit-content hc-animate-contentShow hc-fixed hc-inset-0 hc-m-auto hc-max-h-[85vh] hc-w-[90vw] hc-max-w-[450px] hc-rounded-[6px] hc-bg-white hc-p-[25px] hc-shadow-lg focus:hc-outline-none hc-flex hc-flex-col hc-items-center hc-text-center">
16
+ <Dialog.Title className="hc-text-[17px] hc-font-medium hc-w-full">
17
+ Career Opportunities
18
+ </Dialog.Title>
19
+ <Dialog.Description className="hc-mt-4 hc-mb-5 hc-text-[15px] hc-leading-normal hc-w-full">
20
+ Are you currently a {companyName} employee?
21
+ </Dialog.Description>
22
+ <div className="hc-flex hc-justify-center hc-space-x-4 hc-w-full">
23
+ <Dialog.Close asChild>
24
+ <Button.Anchor variant="outline" href={internalApplyLink}>
25
+ Yes
26
+ </Button.Anchor>
27
+ </Dialog.Close>
28
+ <Dialog.Close asChild>
29
+ <Button.Anchor variant="primary" href={applyUrl}>
30
+ No
31
+ </Button.Anchor>
32
+ </Dialog.Close>
33
+ </div>
34
+ <Dialog.Close asChild>
35
+ <Button.Anchor className="hc-absolute hc-top-[10px] hc-right-[10px] hc-inline-flex hc-h-[25px] hc-w-[25px] hc-items-center hc-justify-center hc-rounded-full focus:hc-outline-none"
36
+ variant="ghost" aria-label="Close">
37
+ <Icon
38
+ icon="mdi:times"
39
+ className="hc-cursor-pointer hc-text-black hover:hc-text-gray-500 hover:hc-opacity-75"
40
+ />
41
+ </Button.Anchor>
42
+ </Dialog.Close>
43
+ </Dialog.Content>
44
+ </Dialog.Portal>
45
+ </Dialog.Root>
46
+ );
47
+
48
+ export default ApplyDialog;
@@ -1,149 +1,154 @@
1
- import React, { Fragment, useRef, useState, useEffect } from 'react';
2
- import { Combobox, Transition } from '@headlessui/react';
3
- import usePlacesAutocomplete, { getGeocode, getLatLng } from 'use-places-autocomplete';
4
-
5
- import Button from '~/components/modules/buttons/default';
6
- import Icon from "~/components/modules/icon";
7
-
8
- import { useMapList } from '~/contexts/mapListContext';
9
- import { getStorageItem } from '~/util/localStorageUtil';
10
-
11
- const FilterCommute = ({ className }) => {
12
- const {
13
- ready,
14
- suggestions: { status, data },
15
- setValue,
16
- clearSuggestions
17
- } = usePlacesAutocomplete();
18
-
19
- const [selected, setSelected] = useState(getStorageItem('selectedCommute', ''));
20
- const inputRef = useRef(null);
21
- const { setCommuteLocation, commuteLocation } = useMapList();
22
- const [isCurrentLocation, setIsCurrentLocation] = useState(getStorageItem('isCurrentLocation', false));
23
-
24
- useEffect(() => {
25
- if (commuteLocation !== null && commuteLocation != '') return;
26
- setIsCurrentLocation(false);
27
- localStorage.removeItem('isCurrentLocation');
28
- localStorage.removeItem('selectedCommute');
29
- setSelected("");
30
- }, [commuteLocation]);
31
-
32
- const handleSelect = async (val, isCurrLocation = false) => {
33
- setValue(val, false);
34
- setSelected(val);
35
- localStorage.setItem('selectedCommute', val);
36
- clearSuggestions();
37
- if (isCurrLocation) return;
38
- try {
39
- const results = await getGeocode({ address: val });
40
- const { lat, lng } = await getLatLng(results[0]);
41
- setCommuteLocation({ lat, lng });
42
- } catch (error) {
43
- // no-op
44
- }
45
- };
46
-
47
- const fetchLocation = () => {
48
- if (!navigator.geolocation) {
49
- console.error("Geolocation is not supported by this browser.");
50
- return;
51
- }
52
- navigator.geolocation.getCurrentPosition(
53
- position => {
54
- setCommuteLocation({
55
- lat: position.coords.latitude,
56
- lng: position.coords.longitude
57
- });
58
- handleSelect("Current Location");
59
- },
60
- error => {
61
- console.error("Error fetching location", error);
62
- }
63
- );
64
- };
65
-
66
- return (
67
- <div className={`relative ${className ?? ""}`}>
68
- <label
69
- htmlFor="commute"
70
- className="hc-flex hc-items-center hc-gap-2 hc-mb-2 hc-text-xs hc-uppercase hc-font-bold hc-text-uiText"
71
- >
72
- <Icon
73
- icon="ri:pin-distance-fill"
74
- size="hc-size-5"
75
- className="hc-text-uiAccent/30"
76
- />
77
- <span>
78
- <span className="md:hc-hidden lg:hc-inline">Calculate your</span> commute
79
- </span>
80
- </label>
81
-
82
- <Combobox value={selected} onChange={handleSelect}>
83
- <div className="hc-relative hc-mt-1">
84
- <div className="hc-relative hc-flex hc-items-center hc-w-full hc-pr-2 hc-cursor-default hc-overflow-hidden hc-rounded hc-bg-white hc-text-left hc-border hc-border-uiAccent/20 focus-within:hc-ring-1 focus-within:hc-ring-uiAccent focus:hc-outline-none">
85
- <Combobox.Input
86
- className="hc-w-full hc-border-none hc-py-2 hc-pl-4 hc-pr-1 hc-text-sm hc-leading-5 hc-text-gray-900 focus:hc-ring-0 placeholder:hc-text-gray-400"
87
- onChange={e => {
88
- setValue(e.target.value);
89
- setSelected(e.target.value);
90
- }}
91
- value={selected}
92
- disabled={!ready}
93
- placeholder="Starting point"
94
- ref={inputRef}
95
- />
96
- <Button.Btn
97
- variant="icon"
98
- size="sqsm"
99
- onClick={() => {
100
- setIsCurrentLocation(!isCurrentLocation);
101
- localStorage.setItem('isCurrentLocation', !isCurrentLocation);
102
- if (isCurrentLocation || commuteLocation) {
103
- setCommuteLocation("");
104
- setSelected("");
105
- } else if (!commuteLocation) { fetchLocation(); }
106
- }}
107
-
108
- className=""
109
- >
110
- <span className="hc-sr-only">Use your location</span>
111
- {commuteLocation ? <Icon icon="mdi:times"></Icon> : <Button.Icon className={isCurrentLocation ? 'hc-text-blue-500' : 'hc-text-current'} icon="mdi:hc-my-location" />}
112
- </Button.Btn>
113
- </div>
114
- <Transition
115
- as={Fragment}
116
- leave="hc-transition hc-ease-in hc-duration-100"
117
- leaveFrom="hc-opacity-100"
118
- leaveTo="hc-opacity-0"
119
- afterLeave={clearSuggestions}
120
- >
121
- <Combobox.Options className="hc-absolute hc-z-20 hc-mt-1 hc-max-h-60 hc-w-full hc-overflow-auto hc-rounded hc-bg-white hc-py-1 hc-text-base hc-shadow hc-ring-1 hc-ring-uiAccent/10 focus:hc-outline-none sm:hc-text-sm">
122
- {status === "OK" &&
123
- data.map(data => (
124
- <Combobox.Option
125
- key={data.place_id}
126
- value={data.description}
127
- className={({ active }) =>
128
- `hc-relative hc-cursor-default hc-select-none hc-px-4 hc-py-2 ${active ? "hc-bg-primary hc-text-white" : "hc-text-uiText"
129
- }`
130
- }
131
- >
132
- {({ selected }) => (
133
- <span
134
- className={`hc-block hc-truncate ${selected ? "hc-font-bold" : "hc-font-medium"}`}
135
- >
136
- {data.description}
137
- </span>
138
- )}
139
- </Combobox.Option>
140
- ))}
141
- </Combobox.Options>
142
- </Transition>
143
- </div>
144
- </Combobox>
145
- </div>
146
- );
147
- };
148
-
149
- export default FilterCommute;
1
+ import React, { Fragment, useRef, useState, useEffect } from 'react';
2
+ import { Combobox, Transition } from '@headlessui/react';
3
+ import usePlacesAutocomplete, { getGeocode, getLatLng } from 'use-places-autocomplete';
4
+
5
+ import Button from '~/components/modules/buttons/default';
6
+ import Icon from "~/components/modules/icon";
7
+
8
+ import { useMapList } from '~/contexts/mapListContext';
9
+ import { useTrackEvent } from '~/contexts/trackEventContext';
10
+ import { getStorageItem } from '~/util/localStorageUtil';
11
+
12
+ const FilterCommute = ({ className }) => {
13
+ const {
14
+ ready,
15
+ suggestions: { status, data },
16
+ setValue,
17
+ clearSuggestions
18
+ } = usePlacesAutocomplete();
19
+
20
+ const [selected, setSelected] = useState(getStorageItem('selectedCommute', ''));
21
+ const inputRef = useRef(null);
22
+ const { setCommuteLocation, commuteLocation } = useMapList();
23
+ const [isCurrentLocation, setIsCurrentLocation] = useState(getStorageItem('isCurrentLocation', false));
24
+ const { trackEvent, eventTypes } = useTrackEvent();
25
+
26
+ useEffect(() => {
27
+ if (commuteLocation !== null && commuteLocation != '') return;
28
+ setIsCurrentLocation(false);
29
+ localStorage.removeItem('isCurrentLocation');
30
+ localStorage.removeItem('selectedCommute');
31
+ setSelected("");
32
+ }, [commuteLocation]);
33
+
34
+ const handleSelect = async (val, isCurrLocation = false) => {
35
+ setValue(val, false);
36
+ setSelected(val);
37
+ localStorage.setItem('selectedCommute', val);
38
+ clearSuggestions();
39
+ if (isCurrLocation) return;
40
+ try {
41
+ const results = await getGeocode({ address: val });
42
+ const { lat, lng } = await getLatLng(results[0]);
43
+ trackEvent(eventTypes.COMMUTE_ORIGIN_ADDED, { commuteLocation: { lat, lng }, isCurrentLocation: false });
44
+ setCommuteLocation({ lat, lng });
45
+ } catch (error) {
46
+ // no-op
47
+ }
48
+ };
49
+
50
+ const fetchLocation = () => {
51
+ if (!navigator.geolocation) {
52
+ console.error("Geolocation is not supported by this browser.");
53
+ return;
54
+ }
55
+ navigator.geolocation.getCurrentPosition(
56
+ position => {
57
+ const location = {
58
+ lat: position.coords.latitude,
59
+ lng: position.coords.longitude
60
+ };
61
+ setCommuteLocation(location);
62
+ trackEvent(eventTypes.COMMUTE_ORIGIN_ADDED, { commuteLocation: location, isCurrentLocation: true });
63
+ handleSelect("Current Location");
64
+ },
65
+ error => {
66
+ console.error("Error fetching location", error);
67
+ }
68
+ );
69
+ };
70
+
71
+ return (
72
+ <div className={`relative ${className ?? ""}`}>
73
+ <label
74
+ htmlFor="commute"
75
+ className="hc-flex hc-items-center hc-gap-2 hc-mb-2 hc-text-xs hc-uppercase hc-font-bold hc-text-uiText"
76
+ >
77
+ <Icon
78
+ icon="ri:pin-distance-fill"
79
+ size="hc-size-5"
80
+ className="hc-text-uiAccent/30"
81
+ />
82
+ <span>
83
+ <span className="md:hc-hidden lg:hc-inline">Calculate your</span> commute
84
+ </span>
85
+ </label>
86
+
87
+ <Combobox value={selected} onChange={handleSelect}>
88
+ <div className="hc-relative hc-mt-1">
89
+ <div className="hc-relative hc-flex hc-items-center hc-w-full hc-pr-2 hc-cursor-default hc-overflow-hidden hc-rounded hc-bg-white hc-text-left hc-border hc-border-uiAccent/20 focus-within:hc-ring-1 focus-within:hc-ring-uiAccent focus:hc-outline-none">
90
+ <Combobox.Input
91
+ className="hc-w-full hc-border-none hc-py-2 hc-pl-4 hc-pr-1 hc-text-sm hc-leading-5 hc-text-gray-900 focus:hc-ring-0 placeholder:hc-text-gray-400"
92
+ onChange={e => {
93
+ setValue(e.target.value);
94
+ setSelected(e.target.value);
95
+ }}
96
+ value={selected}
97
+ disabled={!ready}
98
+ placeholder="Starting point"
99
+ ref={inputRef}
100
+ />
101
+ <Button.Btn
102
+ variant="icon"
103
+ size="sqsm"
104
+ onClick={() => {
105
+ setIsCurrentLocation(!isCurrentLocation);
106
+ localStorage.setItem('isCurrentLocation', !isCurrentLocation);
107
+ if (isCurrentLocation || commuteLocation) {
108
+ setCommuteLocation("");
109
+ setSelected("");
110
+ } else if (!commuteLocation) { fetchLocation(); }
111
+ }}
112
+
113
+ className=""
114
+ >
115
+ <span className="hc-sr-only">Use your location</span>
116
+ {commuteLocation ? <Icon icon="mdi:times"></Icon> : <Button.Icon className={isCurrentLocation ? 'hc-text-blue-500' : 'hc-text-current'} icon="mdi:hc-my-location" />}
117
+ </Button.Btn>
118
+ </div>
119
+ <Transition
120
+ as={Fragment}
121
+ leave="hc-transition hc-ease-in hc-duration-100"
122
+ leaveFrom="hc-opacity-100"
123
+ leaveTo="hc-opacity-0"
124
+ afterLeave={clearSuggestions}
125
+ >
126
+ <Combobox.Options className="hc-absolute hc-z-20 hc-mt-1 hc-max-h-60 hc-w-full hc-overflow-auto hc-rounded hc-bg-white hc-py-1 hc-text-base hc-shadow hc-ring-1 hc-ring-uiAccent/10 focus:hc-outline-none sm:hc-text-sm">
127
+ {status === "OK" &&
128
+ data.map(data => (
129
+ <Combobox.Option
130
+ key={data.place_id}
131
+ value={data.description}
132
+ className={({ active }) =>
133
+ `hc-relative hc-cursor-default hc-select-none hc-px-4 hc-py-2 ${active ? "hc-bg-primary hc-text-white" : "hc-text-uiText"
134
+ }`
135
+ }
136
+ >
137
+ {({ selected }) => (
138
+ <span
139
+ className={`hc-block hc-truncate ${selected ? "hc-font-bold" : "hc-font-medium"}`}
140
+ >
141
+ {data.description}
142
+ </span>
143
+ )}
144
+ </Combobox.Option>
145
+ ))}
146
+ </Combobox.Options>
147
+ </Transition>
148
+ </div>
149
+ </Combobox>
150
+ </div>
151
+ );
152
+ };
153
+
154
+ export default FilterCommute;
@@ -1,87 +1,89 @@
1
- import React, { useState } from 'react';
2
-
3
- import FilterSearch from '~/components/modules/filter/search';
4
- import FiltersAccordion from '~/components/modules/accordions/filters';
5
- import FilterLocations from '~/components/modules/filter/location';
6
- import Button from '~/components/modules/buttons/default';
7
-
8
- import { useMap } from '~/contexts/mapContext';
9
- import { useMapList } from '~/contexts/mapListContext';
10
-
11
- const Filter = ({
12
- className,
13
- showMap
14
- }) => {
15
- const [hasActiveFilters, setHasActiveFilters] = useState(false);
16
- const [defaultValue, setDefaultValue] = useState(null);
17
- const { setSelectedListItem, setLocation, filterReset } = useMap();
18
- const {
19
- filteredListings,
20
- selectedFilters,
21
- setSelectedFilters,
22
- setMobileTab,
23
- handleSettingFavorites,
24
- setQuery,
25
- siteConfig
26
- } = useMapList();
27
-
28
- return (
29
- <div
30
- className={`
31
- hc-relative hc-max-h-[95vh] md:hc-max-h-screen hc-overflow-y-auto hc-overflow-x-auto
32
- ${className ?? ""}
33
- `}
34
- >
35
- <div className="hc-px-4 md:hc-pt-4 hc-space-y-4">
36
- <FiltersAccordion
37
- setHasActiveFilters={setHasActiveFilters}
38
- defaultValue={defaultValue}
39
- setDefaultValue={value => { setDefaultValue(value == defaultValue ? "" : value); }}
40
- setLocation={setLocation}
41
- setSelectedListItem={setSelectedListItem}
42
- />
43
- <FilterSearch />
44
- {siteConfig.hideLocations !== true &&
45
- <FilterLocations
46
- setHasActiveFilters={setHasActiveFilters}
47
- defaultValue={defaultValue}
48
- showMap={showMap}
49
- setDefaultValue={value => { setDefaultValue(value == defaultValue ? "" : value); }}
50
- setLocation={setLocation}
51
- setSelectedListItem={setSelectedListItem}
52
- />
53
- }
54
- </div>
55
- <div className="hc-sticky hc-bottom-0 hc-inset-x-0 hc-flex hc-items-center hc-justify-between hc-gap-2 hc-py-2 hc-px-4 hc-mt-2 hc-bg-white md:hc-bg-gray-100">
56
- <Button.Btn
57
- onClick={() => { filterReset(); setSelectedFilters({}); setQuery(null); handleSettingFavorites(null); }}
58
- variant="outline"
59
- size="sm"
60
- >
61
- Reset
62
- </Button.Btn>
63
- {selectedFilters && Object.keys(selectedFilters).length > 0 &&
64
- <Button.Btn
65
- onClick={() => setMobileTab("listTab")}
66
- variant="primary"
67
- size="sm"
68
- className={`
69
- md:hc-hidden
70
- ${hasActiveFilters ? "hc-opacity-0 hc-pointer-events-none" : "hc-opacity-100"}
71
- `}
72
- >
73
- <Button.Body>
74
- <Button.Icon
75
- icon="fluent:search-12-filled"
76
- size="hc-size-3.5"
77
- />
78
- Show {filteredListings.length} Jobs
79
- </Button.Body>
80
- </Button.Btn>
81
- }
82
- </div>
83
- </div>
84
- );
85
- };
86
-
87
- export default Filter;
1
+ import React, { useState } from 'react';
2
+
3
+ import FilterSearch from '~/components/modules/filter/search';
4
+ import FiltersAccordion from '~/components/modules/accordions/filters';
5
+ import FilterLocations from '~/components/modules/filter/location';
6
+ import Button from '~/components/modules/buttons/default';
7
+
8
+ import { useMap } from '~/contexts/mapContext';
9
+ import { useMapList } from '~/contexts/mapListContext';
10
+ import { useTrackEvent } from '~/contexts/trackEventContext';
11
+
12
+ const Filter = ({
13
+ className,
14
+ showMap
15
+ }) => {
16
+ const { trackEvent, eventTypes } = useTrackEvent();
17
+ const [hasActiveFilters, setHasActiveFilters] = useState(false);
18
+ const [defaultValue, setDefaultValue] = useState(null);
19
+ const { setSelectedListItem, setLocation, filterReset } = useMap();
20
+ const {
21
+ filteredListings,
22
+ selectedFilters,
23
+ setSelectedFilters,
24
+ setMobileTab,
25
+ handleSettingFavorites,
26
+ setQuery,
27
+ siteConfig
28
+ } = useMapList();
29
+
30
+ return (
31
+ <div
32
+ className={`
33
+ hc-relative hc-max-h-[95vh] md:hc-max-h-screen hc-overflow-y-auto hc-overflow-x-auto
34
+ ${className ?? ""}
35
+ `}
36
+ >
37
+ <div className="hc-px-4 md:hc-pt-4 hc-space-y-4">
38
+ <FiltersAccordion
39
+ setHasActiveFilters={setHasActiveFilters}
40
+ defaultValue={defaultValue}
41
+ setDefaultValue={value => { setDefaultValue(value == defaultValue ? "" : value); }}
42
+ setLocation={setLocation}
43
+ setSelectedListItem={setSelectedListItem}
44
+ />
45
+ <FilterSearch />
46
+ {siteConfig.hideLocations !== true &&
47
+ <FilterLocations
48
+ setHasActiveFilters={setHasActiveFilters}
49
+ defaultValue={defaultValue}
50
+ showMap={showMap}
51
+ setDefaultValue={value => { setDefaultValue(value == defaultValue ? "" : value); }}
52
+ setLocation={setLocation}
53
+ setSelectedListItem={setSelectedListItem}
54
+ />
55
+ }
56
+ </div>
57
+ <div className="hc-sticky hc-bottom-0 hc-inset-x-0 hc-flex hc-items-center hc-justify-between hc-gap-2 hc-py-2 hc-px-4 hc-mt-2 hc-bg-white md:hc-bg-gray-100">
58
+ <Button.Btn
59
+ onClick={() => {trackEvent(eventTypes.FILTERS_RESET, { filtersRemoved: selectedFilters }); filterReset(); setSelectedFilters({}); setQuery(null); handleSettingFavorites(null); }}
60
+ variant="outline"
61
+ size="sm"
62
+ >
63
+ Reset
64
+ </Button.Btn>
65
+ {selectedFilters && Object.keys(selectedFilters).length > 0 &&
66
+ <Button.Btn
67
+ onClick={() => setMobileTab("listTab")}
68
+ variant="primary"
69
+ size="sm"
70
+ className={`
71
+ md:hc-hidden
72
+ ${hasActiveFilters ? "hc-opacity-0 hc-pointer-events-none" : "hc-opacity-100"}
73
+ `}
74
+ >
75
+ <Button.Body>
76
+ <Button.Icon
77
+ icon="fluent:search-12-filled"
78
+ size="hc-size-3.5"
79
+ />
80
+ Show {filteredListings.length} Jobs
81
+ </Button.Body>
82
+ </Button.Btn>
83
+ }
84
+ </div>
85
+ </div>
86
+ );
87
+ };
88
+
89
+ export default Filter;