@abcagency/hc-ui-components 1.3.13 → 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 +3 -15
  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 +4 -16
  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
@@ -1,195 +1,195 @@
1
- import { getDistinctItemsByProximity } from '~/util/mapUtil';
2
-
3
- export const getFilterOptions = (listings, filteredListings, field, excludeZeroCount = null) => {
4
- const options = new Set();
5
- listings.forEach(listing => {
6
- if (listing.fields[field]) {
7
- options.add(listing.fields[field]);
8
- }
9
- });
10
-
11
- const optionCounts = {};
12
- options.forEach(option => {
13
- optionCounts[option] = 0;
14
- });
15
-
16
- filteredListings.forEach(listing => {
17
- const value = listing.fields[field];
18
- if (value && optionCounts.hasOwnProperty(value)) {
19
- optionCounts[value] += 1;
20
- }
21
- });
22
-
23
- return Array.from(options)
24
- .sort()
25
- .map(option => ({
26
- name: option,
27
- count: optionCounts[option] || 0
28
- }))
29
- .filter(option => !(excludeZeroCount === true && option.count === 0));
30
- };
31
-
32
- export const getSpecialFeatureOptions = (listings, filteredListings, siteConfig, favorites) => {
33
- const specialFeatures = siteConfig.specialFeatures;
34
- const featureCounts = Object.keys(specialFeatures).sort().reduce((acc, key) => {
35
- acc[specialFeatures[key]] = 0;
36
- return acc;
37
- }, {});
38
-
39
- filteredListings.forEach(listing => {
40
- Object.entries(specialFeatures).forEach(([featureKey, featureName]) => {
41
- if (listing.fields[featureKey] === 1) {
42
- featureCounts[featureName] += 1;
43
- }
44
- });
45
- });
46
-
47
- const specialFeatureOptions = Object.entries(featureCounts).map(([name, count]) => ({
48
- name,
49
- count
50
- }));
51
-
52
- for (let option of specialFeatureOptions) {
53
- if (option.name === 'Favorite') {
54
- option.count = filteredListings.filter(x => favorites.includes(x.id)).length;
55
- }
56
- }
57
-
58
- return specialFeatureOptions;
59
- };
60
-
61
- const getPointsOfInterestOptions = pointsOfInterestNames => {
62
- return Object.entries(pointsOfInterestNames).sort().map(([key, name]) => ({
63
- key,
64
- name
65
- }));
66
- };
67
-
68
- export const generateFilterOptions = (
69
- filteredListings,
70
- allListings,
71
- siteConfig,
72
- filterOptions,
73
- parentField = null,
74
- favorites
75
- ) => {
76
- if (allListings.length > 0) {
77
- const dynamicFilters = siteConfig.fieldFiltersShown.map(fieldName => {
78
- if (fieldName === parentField && filterOptions?.filters) {
79
- return filterOptions.filters.find(filter => filter.id === fieldName);
80
- }
81
- if (fieldName == "specialFeatures") {
82
- return {
83
- id: fieldName,
84
- title: siteConfig.fieldNames[fieldName],
85
- items: getSpecialFeatureOptions(allListings, filteredListings, siteConfig, favorites).sort()
86
- };
87
- }
88
- return {
89
- id: fieldName,
90
- title: siteConfig.fieldNames[fieldName],
91
- items: getFilterOptions(allListings, filteredListings, fieldName)
92
- };
93
- });
94
-
95
- const locations =
96
- siteConfig.locationFiltersShown.map((fieldName, index) => {
97
- if (index === 0 && filterOptions?.locations) {
98
- return filterOptions.locations.find(filter => filter.id === fieldName);
99
- }
100
- return {
101
- id: fieldName,
102
- title: siteConfig.fieldNames[fieldName],
103
- items: getFilterOptions(allListings, filteredListings, fieldName, true)
104
- };
105
- });
106
-
107
- const pointsOfInterest = {
108
- id: "pointsOfInterest",
109
- title: siteConfig.pointsOfInterestConfig.title,
110
- items: getPointsOfInterestOptions(
111
- siteConfig.pointsOfInterestConfig.pointsOfInterestNames
112
- )
113
- };
114
-
115
- return {
116
- filters: dynamicFilters,
117
- locations: locations,
118
- pointsOfInterest: pointsOfInterest
119
- };
120
- }
121
-
122
- return null;
123
- };
124
-
125
- export const applyFilters = (
126
- allListings,
127
- selectedFilters,
128
- query,
129
- listingEntities,
130
- favorites,
131
- siteConfig
132
- ) => {
133
- let results = allListings;
134
- let invertedSpecialFeaturesMap;
135
- if (siteConfig.specialFeatures) {
136
- invertedSpecialFeaturesMap = Object.entries(siteConfig.specialFeatures).reduce((acc, [key, value]) => {
137
- acc[value] = key;
138
- return acc;
139
- }, {});
140
-
141
- }
142
- const hasFavorite = !!selectedFilters.specialFeatures && !!selectedFilters.specialFeatures.Favorite;
143
-
144
- if (hasFavorite && selectedFilters.specialFeatures.Favorite == true) {
145
- results = results.filter(x => favorites.includes(x.id));
146
- }
147
- var favorite;
148
- if (hasFavorite) {
149
- favorite = selectedFilters.specialFeatures.Favorite;
150
- delete selectedFilters.specialFeatures.Favorite;
151
- }
152
- for (const [field, filterItems] of Object.entries(selectedFilters)) {
153
- const formattedField = field;
154
- if (field === "pointsOfInterest") continue;
155
- if (field === "specialFeatures" && invertedSpecialFeaturesMap && Object.keys(filterItems).length > 0) {
156
- results = results.filter(listing => {
157
- return Object.entries(filterItems).some(([filterName, filterValue]) => {
158
- const listingFieldName = invertedSpecialFeaturesMap[filterName];
159
- return filterValue && listing.fields[listingFieldName] === 1;
160
- });
161
- });
162
- } else if (Object.keys(filterItems).length > 0) {
163
- results = results.filter(listing =>
164
- filterItems.hasOwnProperty(listing.fields[formattedField])
165
- );
166
- }
167
- }
168
- if (query) {
169
- results = results.filter(listing =>
170
- Object.values(listing.fields)?.some(value =>
171
- value?.toString().toLowerCase().includes(query.toLowerCase())
172
- )
173
- );
174
- }
175
- const distinctItems = getDistinctItemsByProximity(results, listingEntities);
176
- if (hasFavorite) {
177
- selectedFilters.specialFeatures.Favorite = favorite;
178
- }
179
- return { filteredListings: results, mapItems: distinctItems };
180
- };
181
-
182
- export const filterListingsByLocation = (
183
- allListings,
184
- selectedLocation,
185
- listingEntities
186
- ) => {
187
- let results = allListings;
188
- if (selectedLocation !== null) {
189
- results = results.filter(item =>
190
- selectedLocation.items.hasOwnProperty(item.id)
191
- );
192
- }
193
- const mapItems = getDistinctItemsByProximity(results, listingEntities);
194
- return { filteredListings: results, mapItems: mapItems };
195
- };
1
+ import { getDistinctItemsByProximity } from '~/util/mapUtil';
2
+
3
+ export const getFilterOptions = (listings, filteredListings, field, excludeZeroCount = null) => {
4
+ const options = new Set();
5
+ listings.forEach(listing => {
6
+ if (listing.fields[field]) {
7
+ options.add(listing.fields[field]);
8
+ }
9
+ });
10
+
11
+ const optionCounts = {};
12
+ options.forEach(option => {
13
+ optionCounts[option] = 0;
14
+ });
15
+
16
+ filteredListings.forEach(listing => {
17
+ const value = listing.fields[field];
18
+ if (value && optionCounts.hasOwnProperty(value)) {
19
+ optionCounts[value] += 1;
20
+ }
21
+ });
22
+
23
+ return Array.from(options)
24
+ .sort()
25
+ .map(option => ({
26
+ name: option,
27
+ count: optionCounts[option] || 0
28
+ }))
29
+ .filter(option => !(excludeZeroCount === true && option.count === 0));
30
+ };
31
+
32
+ export const getSpecialFeatureOptions = (listings, filteredListings, siteConfig, favorites) => {
33
+ const specialFeatures = siteConfig.specialFeatures;
34
+ const featureCounts = Object.keys(specialFeatures).sort().reduce((acc, key) => {
35
+ acc[specialFeatures[key]] = 0;
36
+ return acc;
37
+ }, {});
38
+
39
+ filteredListings.forEach(listing => {
40
+ Object.entries(specialFeatures).forEach(([featureKey, featureName]) => {
41
+ if (listing.fields[featureKey] === 1) {
42
+ featureCounts[featureName] += 1;
43
+ }
44
+ });
45
+ });
46
+
47
+ const specialFeatureOptions = Object.entries(featureCounts).map(([name, count]) => ({
48
+ name,
49
+ count
50
+ }));
51
+
52
+ for (let option of specialFeatureOptions) {
53
+ if (option.name === 'Favorite') {
54
+ option.count = filteredListings.filter(x => favorites.includes(x.id)).length;
55
+ }
56
+ }
57
+
58
+ return specialFeatureOptions;
59
+ };
60
+
61
+ const getPointsOfInterestOptions = pointsOfInterestNames => {
62
+ return Object.entries(pointsOfInterestNames).sort().map(([key, name]) => ({
63
+ key,
64
+ name
65
+ }));
66
+ };
67
+
68
+ export const generateFilterOptions = (
69
+ filteredListings,
70
+ allListings,
71
+ siteConfig,
72
+ filterOptions,
73
+ parentField = null,
74
+ favorites
75
+ ) => {
76
+ if (allListings.length > 0) {
77
+ const dynamicFilters = siteConfig.fieldFiltersShown.map(fieldName => {
78
+ if (fieldName === parentField && filterOptions?.filters) {
79
+ return filterOptions.filters.find(filter => filter.id === fieldName);
80
+ }
81
+ if (fieldName == "specialFeatures") {
82
+ return {
83
+ id: fieldName,
84
+ title: siteConfig.fieldNames[fieldName],
85
+ items: getSpecialFeatureOptions(allListings, filteredListings, siteConfig, favorites).sort()
86
+ };
87
+ }
88
+ return {
89
+ id: fieldName,
90
+ title: siteConfig.fieldNames[fieldName],
91
+ items: getFilterOptions(allListings, filteredListings, fieldName)
92
+ };
93
+ });
94
+
95
+ const locations =
96
+ siteConfig.locationFiltersShown.map((fieldName, index) => {
97
+ if (index === 0 && filterOptions?.locations) {
98
+ return filterOptions.locations.find(filter => filter.id === fieldName);
99
+ }
100
+ return {
101
+ id: fieldName,
102
+ title: siteConfig.fieldNames[fieldName],
103
+ items: getFilterOptions(allListings, filteredListings, fieldName, true)
104
+ };
105
+ });
106
+
107
+ const pointsOfInterest = {
108
+ id: "pointsOfInterest",
109
+ title: siteConfig.pointsOfInterestConfig.title,
110
+ items: getPointsOfInterestOptions(
111
+ siteConfig.pointsOfInterestConfig.pointsOfInterestNames
112
+ )
113
+ };
114
+
115
+ return {
116
+ filters: dynamicFilters,
117
+ locations: locations,
118
+ pointsOfInterest: pointsOfInterest
119
+ };
120
+ }
121
+
122
+ return null;
123
+ };
124
+
125
+ export const applyFilters = (
126
+ allListings,
127
+ selectedFilters,
128
+ query,
129
+ listingEntities,
130
+ favorites,
131
+ siteConfig
132
+ ) => {
133
+ let results = allListings;
134
+ let invertedSpecialFeaturesMap;
135
+ if (siteConfig.specialFeatures) {
136
+ invertedSpecialFeaturesMap = Object.entries(siteConfig.specialFeatures).reduce((acc, [key, value]) => {
137
+ acc[value] = key;
138
+ return acc;
139
+ }, {});
140
+
141
+ }
142
+ const hasFavorite = !!selectedFilters.specialFeatures && !!selectedFilters.specialFeatures.Favorite;
143
+
144
+ if (hasFavorite && selectedFilters.specialFeatures.Favorite == true) {
145
+ results = results.filter(x => favorites.includes(x.id));
146
+ }
147
+ var favorite;
148
+ if (hasFavorite) {
149
+ favorite = selectedFilters.specialFeatures.Favorite;
150
+ delete selectedFilters.specialFeatures.Favorite;
151
+ }
152
+ for (const [field, filterItems] of Object.entries(selectedFilters)) {
153
+ const formattedField = field;
154
+ if (field === "pointsOfInterest") continue;
155
+ if (field === "specialFeatures" && invertedSpecialFeaturesMap && Object.keys(filterItems).length > 0) {
156
+ results = results.filter(listing => {
157
+ return Object.entries(filterItems).some(([filterName, filterValue]) => {
158
+ const listingFieldName = invertedSpecialFeaturesMap[filterName];
159
+ return filterValue && listing.fields[listingFieldName] === 1;
160
+ });
161
+ });
162
+ } else if (Object.keys(filterItems).length > 0) {
163
+ results = results.filter(listing =>
164
+ filterItems.hasOwnProperty(listing.fields[formattedField])
165
+ );
166
+ }
167
+ }
168
+ if (query) {
169
+ results = results.filter(listing =>
170
+ Object.values(listing.fields)?.some(value =>
171
+ value?.toString().toLowerCase().includes(query.toLowerCase())
172
+ )
173
+ );
174
+ }
175
+ const distinctItems = getDistinctItemsByProximity(results, listingEntities);
176
+ if (hasFavorite) {
177
+ selectedFilters.specialFeatures.Favorite = favorite;
178
+ }
179
+ return { filteredListings: results, mapItems: distinctItems };
180
+ };
181
+
182
+ export const filterListingsByLocation = (
183
+ allListings,
184
+ selectedLocation,
185
+ listingEntities
186
+ ) => {
187
+ let results = allListings;
188
+ if (selectedLocation !== null) {
189
+ results = results.filter(item =>
190
+ selectedLocation.items.hasOwnProperty(item.id)
191
+ );
192
+ }
193
+ const mapItems = getDistinctItemsByProximity(results, listingEntities);
194
+ return { filteredListings: results, mapItems: mapItems };
195
+ };
@@ -1,17 +1,17 @@
1
- import React from 'react';
2
- import Icon from '~/components/modules/icon';
3
-
4
- const Loading = () => {
5
- return (
6
- <div className="hc-flex hc-items-center hc-justify-center hc-w-full hc-h-full">
7
- <Icon
8
- icon="ph:spinner"
9
- className="hc-animate-spin hc-text-gray-300"
10
- width="40"
11
- height="40"
12
- />
13
- </div>
14
- );
15
- };
16
-
17
- export default Loading;
1
+ import React from 'react';
2
+ import Icon from '~/components/modules/icon';
3
+
4
+ const Loading = () => {
5
+ return (
6
+ <div className="hc-flex hc-items-center hc-justify-center hc-w-full hc-h-full">
7
+ <Icon
8
+ icon="ph:spinner"
9
+ className="hc-animate-spin hc-text-gray-300"
10
+ width="40"
11
+ height="40"
12
+ />
13
+ </div>
14
+ );
15
+ };
16
+
17
+ export default Loading;
@@ -1,27 +1,27 @@
1
- export const getStorageObject = (item, defaultItem = null) =>{
2
- if(typeof window == 'undefined') return defaultItem;
3
- if(localStorage.getItem(item) == null) return defaultItem;
4
- if(localStorage.getItem(item) == 'undefined'){
5
- localStorage.removeItem(item);
6
- }
7
- return JSON.parse(localStorage.getItem(item)) ?? defaultItem;
8
- };
9
-
10
- export const getStorageItem = (item, defaultItem = null) =>{
11
- if(typeof window == 'undefined') return defaultItem;
12
- if(localStorage.getItem(item) == null) return defaultItem;
13
- if(localStorage.getItem(item) == 'undefined'){
14
- localStorage.removeItem(item);
15
- }
16
- return localStorage.getItem(item) ?? defaultItem;
17
- };
18
-
19
- export const setStorageObject = (key, item) =>{
20
- if(typeof window == 'undefined') return;
21
- if(item == undefined)return;
22
- try{
23
- localStorage.setItem(key, JSON.stringify(item));
24
- }catch(err){
25
- console.log(err);
26
- }
1
+ export const getStorageObject = (item, defaultItem = null) =>{
2
+ if(typeof window == 'undefined') return defaultItem;
3
+ if(localStorage.getItem(item) == null) return defaultItem;
4
+ if(localStorage.getItem(item) == 'undefined'){
5
+ localStorage.removeItem(item);
6
+ }
7
+ return JSON.parse(localStorage.getItem(item)) ?? defaultItem;
8
+ };
9
+
10
+ export const getStorageItem = (item, defaultItem = null) =>{
11
+ if(typeof window == 'undefined') return defaultItem;
12
+ if(localStorage.getItem(item) == null) return defaultItem;
13
+ if(localStorage.getItem(item) == 'undefined'){
14
+ localStorage.removeItem(item);
15
+ }
16
+ return localStorage.getItem(item) ?? defaultItem;
17
+ };
18
+
19
+ export const setStorageObject = (key, item) =>{
20
+ if(typeof window == 'undefined') return;
21
+ if(item == undefined)return;
22
+ try{
23
+ localStorage.setItem(key, JSON.stringify(item));
24
+ }catch(err){
25
+ console.log(err);
26
+ }
27
27
  };