@abcagency/hc-ui-components 1.3.23 → 1.3.24
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/package.json +4 -5
- package/src/.editorconfig +12 -0
- package/src/apis/hcApi.ts +109 -0
- package/src/bundleIndex.js +14 -0
- package/src/clientToken.js +9 -0
- package/src/components/HireControlMap.js +135 -0
- package/src/components/containers/accordions/filter-container.js +48 -0
- package/src/components/containers/accordions/filter-item-container.js +66 -0
- package/src/components/containers/accordions/map-accordion-item-container.js +70 -0
- package/src/components/containers/filter/commute-container.js +89 -0
- package/src/components/containers/filter/filter-container.js +76 -0
- package/src/components/containers/filter/filter-item-container.js +71 -0
- package/src/components/containers/filter/location-container.js +45 -0
- package/src/components/containers/filter/points-of-interest-container.js +33 -0
- package/src/components/containers/filter/points-of-interest-radio-item-container.js +35 -0
- package/src/components/containers/filter/search-container.js +50 -0
- package/src/components/containers/jobListing/listing-details-container.js +40 -0
- package/src/components/containers/list/item-list-container.tsx +81 -0
- package/src/components/containers/list/list-item/list-item-container.js +43 -0
- package/src/components/containers/maps/info-window-content-container.js +51 -0
- package/src/components/containers/maps/map-container.js +204 -0
- package/src/components/containers/maps/map-list-container.js +48 -0
- package/src/components/containers/maps/map-marker-container.js +78 -0
- package/src/components/modules/accordions/MapAccordionItem.js +30 -0
- package/src/components/modules/accordions/default.js +171 -0
- package/src/components/modules/accordions/filterItem.js +27 -0
- package/src/components/modules/accordions/filters.js +32 -0
- package/src/components/modules/buttons/button-group-apply.js +123 -0
- package/src/components/modules/buttons/commute-pill.js +22 -0
- package/src/components/modules/buttons/default.js +194 -0
- package/src/components/modules/buttons/items-pill.js +35 -0
- package/src/components/modules/buttons/pill-wrapper.js +27 -0
- package/src/components/modules/buttons/show-all-button.js +20 -0
- package/src/components/modules/cards/default.js +167 -0
- package/src/components/modules/cards/filter.js +56 -0
- package/src/components/modules/dialogs/apply-dialog.js +48 -0
- package/src/components/modules/filter/commute.js +108 -0
- package/src/components/modules/filter/index.js +55 -0
- package/src/components/modules/filter/item.js +48 -0
- package/src/components/modules/filter/location.js +48 -0
- package/src/components/modules/filter/radio-item.js +42 -0
- package/src/components/modules/filter/search.js +65 -0
- package/src/components/modules/filter/sort.js +83 -0
- package/src/components/modules/grid.js +54 -0
- package/src/components/modules/icon.js +33 -0
- package/src/components/modules/jobListing/listing-details.js +109 -0
- package/src/components/modules/list/field-mapper.js +114 -0
- package/src/components/modules/list/header-item.js +91 -0
- package/src/components/modules/list/header.js +49 -0
- package/src/components/modules/list/item-expand-card/index.js +22 -0
- package/src/components/modules/list/item-expand-card/recruiter-contact-nav.js +50 -0
- package/src/components/modules/list/item-expand-card/recruiter-details.js +68 -0
- package/src/components/modules/list/item-expand-card/recruiter-headshot.js +22 -0
- package/src/components/modules/list/item-list.tsx +84 -0
- package/src/components/modules/list/list-item/list-item.js +130 -0
- package/src/components/modules/maps/info-window-card.js +17 -0
- package/src/components/modules/maps/info-window-content.js +35 -0
- package/src/components/modules/maps/map-list.js +28 -0
- package/src/components/modules/maps/map-marker.js +29 -0
- package/src/components/modules/maps/map.js +76 -0
- package/src/components/modules/maps/place-marker.js +41 -0
- package/src/components/modules/maps/tabs.js +81 -0
- package/src/constants/eventTypes.js +13 -0
- package/src/constants/placeTypes.js +8 -0
- package/src/contexts/mapContext.tsx +129 -0
- package/src/contexts/mapListContext.tsx +311 -0
- package/src/contexts/placesContext.js +102 -0
- package/src/contexts/trackEventContext.js +14 -0
- package/src/enums/SectionType.ts +9 -0
- package/src/hooks/useList.js +89 -0
- package/src/index.js +3 -0
- package/src/services/configService.ts +16 -0
- package/src/services/googlePlacesNearbyService.ts +42 -0
- package/src/services/listingAggregatorService.ts +76 -0
- package/src/services/listingEntityService.ts +16 -0
- package/src/services/listingService.ts +40 -0
- package/src/services/recruiterService.ts +18 -0
- package/src/styles/bundle.css +268 -0
- package/src/styles/index.css +24 -0
- package/src/types/Address.ts +7 -0
- package/src/types/ContentSection.ts +9 -0
- package/src/types/GetListingParams.ts +8 -0
- package/src/types/LatLng.ts +4 -0
- package/src/types/ListingEntity.ts +11 -0
- package/src/types/ListingFields.ts +25 -0
- package/src/types/Listings.ts +32 -0
- package/src/types/Recruiter.ts +9 -0
- package/src/types/SimilarListing.ts +24 -0
- package/src/types/config/Colors.ts +8 -0
- package/src/types/config/MapConfig.ts +31 -0
- package/src/types/config/PointsOfInterestConfig.ts +13 -0
- package/src/types/config/SearchConfig.ts +4 -0
- package/src/util/arrayUtil.js +3 -0
- package/src/util/fieldMapper.js +22 -0
- package/src/util/filterUtil.js +239 -0
- package/src/util/loading.js +17 -0
- package/src/util/localStorageUtil.ts +34 -0
- package/src/util/mapIconUtil.js +180 -0
- package/src/util/mapUtil.js +91 -0
- package/src/util/sortUtil.js +33 -0
- package/src/util/stringUtils.js +6 -0
- package/src/util/urlFilterUtil.js +85 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ListingFields } from './ListingFields';
|
|
2
|
+
import { Recruiter } from './Recruiter';
|
|
3
|
+
import { ListingEntity } from './ListingEntity';
|
|
4
|
+
import { ContentSection } from './ContentSection';
|
|
5
|
+
import { SimilarListing } from './SimilarListing';
|
|
6
|
+
|
|
7
|
+
export type Listing = {
|
|
8
|
+
id: number;
|
|
9
|
+
fields?: ListingFields;
|
|
10
|
+
entityId?: number;
|
|
11
|
+
applyUrl?: string;
|
|
12
|
+
applyOnline?: number;
|
|
13
|
+
detailsUrl?: string;
|
|
14
|
+
displayOnSite: number;
|
|
15
|
+
displayRecruiter: number;
|
|
16
|
+
recruiterId?: number;
|
|
17
|
+
description1?: string;
|
|
18
|
+
description2?: string;
|
|
19
|
+
description3?: string;
|
|
20
|
+
description4?: string;
|
|
21
|
+
custom1: string;
|
|
22
|
+
custom2: string;
|
|
23
|
+
custom3: string;
|
|
24
|
+
custom4: string;
|
|
25
|
+
custom5: string;
|
|
26
|
+
customFlag1: number;
|
|
27
|
+
slug?: string;
|
|
28
|
+
recruiter?: Recruiter;
|
|
29
|
+
entity?: ListingEntity;
|
|
30
|
+
contentSections?: ContentSection[];
|
|
31
|
+
similarListings?: SimilarListing[];
|
|
32
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type SimilarListing = {
|
|
2
|
+
id: number;
|
|
3
|
+
city: string;
|
|
4
|
+
companyName: string;
|
|
5
|
+
companyId: number;
|
|
6
|
+
domain: string;
|
|
7
|
+
refreshedPubDate?: Date;
|
|
8
|
+
clientJobUrl: string;
|
|
9
|
+
refreshNum: number;
|
|
10
|
+
requestURI: string;
|
|
11
|
+
schedule: string;
|
|
12
|
+
scheduleId?: number;
|
|
13
|
+
shift: string;
|
|
14
|
+
sponsored: boolean;
|
|
15
|
+
stateAbbrev: string;
|
|
16
|
+
subTitle: string;
|
|
17
|
+
title: string;
|
|
18
|
+
uniqueId: string;
|
|
19
|
+
zip: string;
|
|
20
|
+
slug?: string;
|
|
21
|
+
dateCreated: Date;
|
|
22
|
+
categoryId: number;
|
|
23
|
+
categoryClassId: number;
|
|
24
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Colors } from "./Colors";
|
|
2
|
+
import { PointsOfInterestConfig } from "./PointsOfInterestConfig";
|
|
3
|
+
import { SearchConfig } from "./SearchConfig";
|
|
4
|
+
|
|
5
|
+
export type MapConfig = {
|
|
6
|
+
title: string;
|
|
7
|
+
titleShort: string;
|
|
8
|
+
description: string;
|
|
9
|
+
jobsDomain: string;
|
|
10
|
+
useDetailsPostMessage: boolean;
|
|
11
|
+
author: string;
|
|
12
|
+
url: string;
|
|
13
|
+
logo: string;
|
|
14
|
+
companyName: string;
|
|
15
|
+
shareImage: string;
|
|
16
|
+
clientAuthKey: string;
|
|
17
|
+
colors: Colors;
|
|
18
|
+
hideLocations: boolean;
|
|
19
|
+
fieldsShown: string[];
|
|
20
|
+
fieldFiltersShown: string[];
|
|
21
|
+
locationFiltersShown: string[];
|
|
22
|
+
fieldNames: Record<string, string>;
|
|
23
|
+
specialFeatures: Record<string, string>;
|
|
24
|
+
searchConfig: SearchConfig;
|
|
25
|
+
internalApplyLink: string;
|
|
26
|
+
useApplyDialog: boolean;
|
|
27
|
+
pointsOfInterestConfig: PointsOfInterestConfig;
|
|
28
|
+
showMap: boolean;
|
|
29
|
+
companyId: string;
|
|
30
|
+
SubcategoryRequireCategory:boolean;
|
|
31
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type PointsOfInterestConfig = {
|
|
2
|
+
title: string;
|
|
3
|
+
pointsOfInterestNames: Record<string, string>;
|
|
4
|
+
pointsOfInterestIcons: Record<string, string>;
|
|
5
|
+
placeMarkerColors: {
|
|
6
|
+
innerFillColor: string;
|
|
7
|
+
innerStrokeColor: string;
|
|
8
|
+
outerFillColor: string;
|
|
9
|
+
outerStrokeColor: string;
|
|
10
|
+
};
|
|
11
|
+
placeMarkerSize: number;
|
|
12
|
+
placeMappings: Record<string, string[]>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import Grid from '~/components/modules/grid';
|
|
4
|
+
|
|
5
|
+
import { capitalize } from '~/util/stringUtils';
|
|
6
|
+
|
|
7
|
+
const mapFieldsToGridItems = (item, fieldsShown) => {
|
|
8
|
+
const orderedFields = fieldsShown.filter(field => field in item.fields);
|
|
9
|
+
|
|
10
|
+
return orderedFields.map(field => {
|
|
11
|
+
let value = item.fields[field];
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Grid.Item key={field}>
|
|
15
|
+
<span className="hc-sr-only">{capitalize(field)}</span>
|
|
16
|
+
{value}
|
|
17
|
+
</Grid.Item>
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default mapFieldsToGridItems;
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { getDistinctItemsByProximity } from '~/util/mapUtil';
|
|
2
|
+
|
|
3
|
+
import Fuse from 'fuse.js';
|
|
4
|
+
|
|
5
|
+
export const getFilterOptions = (listings, filteredListings, field, excludeZeroCount = null) => {
|
|
6
|
+
const options = new Set();
|
|
7
|
+
listings.forEach(listing => {
|
|
8
|
+
if (listing.fields[field]) {
|
|
9
|
+
options.add(listing.fields[field]);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const optionCounts = {};
|
|
14
|
+
options.forEach(option => {
|
|
15
|
+
optionCounts[option] = 0;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
filteredListings.forEach(listing => {
|
|
19
|
+
const value = listing.fields[field];
|
|
20
|
+
if (value && optionCounts.hasOwnProperty(value)) {
|
|
21
|
+
optionCounts[value] += 1;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return Array.from(options)
|
|
26
|
+
.sort()
|
|
27
|
+
.map(option => ({
|
|
28
|
+
name: option,
|
|
29
|
+
count: optionCounts[option] || 0
|
|
30
|
+
}))
|
|
31
|
+
.filter(option => !(excludeZeroCount === true && option.count === 0));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const getSpecialFeatureOptions = (listings, filteredListings, siteConfig, favorites) => {
|
|
35
|
+
const specialFeatures = siteConfig.specialFeatures;
|
|
36
|
+
const featureCounts = Object.keys(specialFeatures).sort().reduce((acc, key) => {
|
|
37
|
+
acc[specialFeatures[key]] = 0;
|
|
38
|
+
return acc;
|
|
39
|
+
}, {});
|
|
40
|
+
|
|
41
|
+
filteredListings.forEach(listing => {
|
|
42
|
+
Object.entries(specialFeatures).forEach(([featureKey, featureName]) => {
|
|
43
|
+
if (listing.fields[featureKey] == 1) {
|
|
44
|
+
featureCounts[featureName] += 1;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const specialFeatureOptions = Object.entries(featureCounts).map(([name, count]) => ({
|
|
50
|
+
name,
|
|
51
|
+
count
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
for (let option of specialFeatureOptions) {
|
|
55
|
+
if (option.name === 'Favorite') {
|
|
56
|
+
option.count = filteredListings.filter(x => favorites.includes(x.id)).length;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return specialFeatureOptions;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const getPointsOfInterestOptions = pointsOfInterestNames => {
|
|
64
|
+
return Object.entries(pointsOfInterestNames).sort().map(([key, name]) => ({
|
|
65
|
+
key,
|
|
66
|
+
name
|
|
67
|
+
}));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const generateFilterOptions = (
|
|
71
|
+
filteredListings,
|
|
72
|
+
allListings,
|
|
73
|
+
siteConfig,
|
|
74
|
+
filterOptions,
|
|
75
|
+
parentField,
|
|
76
|
+
favorites
|
|
77
|
+
) => {
|
|
78
|
+
if (allListings.length > 0) {
|
|
79
|
+
const dynamicFilters = siteConfig.fieldFiltersShown.map(fieldName => {
|
|
80
|
+
if (fieldName === parentField && filterOptions?.filters) {
|
|
81
|
+
return filterOptions.filters.find(filter => filter.id === fieldName);
|
|
82
|
+
}
|
|
83
|
+
if (fieldName == "specialFeatures") {
|
|
84
|
+
return {
|
|
85
|
+
id: fieldName,
|
|
86
|
+
title: siteConfig.fieldNames[fieldName],
|
|
87
|
+
items: getSpecialFeatureOptions(allListings, filteredListings, siteConfig, favorites).sort()
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
id: fieldName,
|
|
92
|
+
title: siteConfig.fieldNames[fieldName],
|
|
93
|
+
items: getFilterOptions(allListings, filteredListings, fieldName)
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const locations =
|
|
98
|
+
siteConfig.locationFiltersShown.map((fieldName, index) => {
|
|
99
|
+
if (index === 0 && filterOptions?.locations) {
|
|
100
|
+
return filterOptions.locations.find(filter => filter.id === fieldName);
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
id: fieldName,
|
|
104
|
+
title: siteConfig.fieldNames[fieldName],
|
|
105
|
+
items: getFilterOptions(allListings, filteredListings, fieldName, true)
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const pointsOfInterest = {
|
|
110
|
+
id: "pointsOfInterest",
|
|
111
|
+
title: siteConfig.pointsOfInterestConfig.title,
|
|
112
|
+
items: getPointsOfInterestOptions(
|
|
113
|
+
siteConfig.pointsOfInterestConfig.pointsOfInterestNames
|
|
114
|
+
)
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
filters: dynamicFilters,
|
|
119
|
+
locations: locations,
|
|
120
|
+
pointsOfInterest: pointsOfInterest
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return null;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const applyFilters = (
|
|
128
|
+
allListings,
|
|
129
|
+
selectedFilters,
|
|
130
|
+
query,
|
|
131
|
+
listingEntities,
|
|
132
|
+
favorites,
|
|
133
|
+
siteConfig
|
|
134
|
+
) => {
|
|
135
|
+
let results = allListings;
|
|
136
|
+
let invertedSpecialFeaturesMap;
|
|
137
|
+
if (siteConfig.specialFeatures) {
|
|
138
|
+
invertedSpecialFeaturesMap = Object.entries(siteConfig.specialFeatures).reduce((acc, [key, value]) => {
|
|
139
|
+
acc[value] = key;
|
|
140
|
+
return acc;
|
|
141
|
+
}, {});
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
const hasFavorite = !!selectedFilters.specialFeatures && !!selectedFilters.specialFeatures.Favorite;
|
|
145
|
+
|
|
146
|
+
if (hasFavorite && selectedFilters.specialFeatures.Favorite == true) {
|
|
147
|
+
results = results.filter(x => favorites.includes(x.id));
|
|
148
|
+
}
|
|
149
|
+
var favorite;
|
|
150
|
+
if (hasFavorite) {
|
|
151
|
+
favorite = selectedFilters.specialFeatures.Favorite;
|
|
152
|
+
delete selectedFilters.specialFeatures.Favorite;
|
|
153
|
+
}
|
|
154
|
+
for (const [field, filterItems] of Object.entries(selectedFilters)) {
|
|
155
|
+
const formattedField = field;
|
|
156
|
+
if (field === "pointsOfInterest") continue;
|
|
157
|
+
if (field === "specialFeatures" && invertedSpecialFeaturesMap && Object.keys(filterItems).length > 0) {
|
|
158
|
+
results = results.filter(listing => {
|
|
159
|
+
return Object.entries(filterItems).some(([filterName, filterValue]) => {
|
|
160
|
+
const listingFieldName = invertedSpecialFeaturesMap[filterName];
|
|
161
|
+
return filterValue && listing.fields[listingFieldName] == 1;
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
} else if (Object.keys(filterItems).length > 0) {
|
|
165
|
+
results = results.filter(listing =>
|
|
166
|
+
filterItems.hasOwnProperty(listing.fields[formattedField])
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (query) {
|
|
171
|
+
results = searchResults(results, query);
|
|
172
|
+
}
|
|
173
|
+
const distinctItems = getDistinctItemsByProximity(results, listingEntities);
|
|
174
|
+
if (hasFavorite) {
|
|
175
|
+
selectedFilters.specialFeatures.Favorite = favorite;
|
|
176
|
+
}
|
|
177
|
+
return { filteredListings: results, mapItems: distinctItems };
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
function searchResults(results, query) {
|
|
181
|
+
const fields = [
|
|
182
|
+
'id',
|
|
183
|
+
'fields.posted',
|
|
184
|
+
'fields.subtitle',
|
|
185
|
+
'fields.education',
|
|
186
|
+
'fields.position',
|
|
187
|
+
'fields.category',
|
|
188
|
+
'fields.categoryclass',
|
|
189
|
+
'fields.shift',
|
|
190
|
+
'fields.citystate',
|
|
191
|
+
'fields.city',
|
|
192
|
+
'fields.state',
|
|
193
|
+
'fields.schedule',
|
|
194
|
+
'fields.customflag1',
|
|
195
|
+
'fields.bonus',
|
|
196
|
+
'fields.remote',
|
|
197
|
+
'fields.useclientjoburl',
|
|
198
|
+
'fields.datecreated',
|
|
199
|
+
'fields.datelastedited'
|
|
200
|
+
];
|
|
201
|
+
|
|
202
|
+
const options = {
|
|
203
|
+
includeScore: true,
|
|
204
|
+
threshold: 0.3,
|
|
205
|
+
keys: fields
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const fuse = new Fuse(results, options);
|
|
209
|
+
const lowerCaseQuery = query.toLowerCase();
|
|
210
|
+
const queryTerms = lowerCaseQuery.split(' ');
|
|
211
|
+
|
|
212
|
+
const exactIdMatch = results.find(result => result.id.toString() === query);
|
|
213
|
+
if (exactIdMatch) {
|
|
214
|
+
return [exactIdMatch];
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const fuseQuery = queryTerms.map(term => ({
|
|
218
|
+
$or: fields.map(field => ({ [field]: term }))
|
|
219
|
+
}));
|
|
220
|
+
|
|
221
|
+
const fuseResults = fuse.search({ $and: fuseQuery });
|
|
222
|
+
|
|
223
|
+
return fuseResults.map(result => result.item);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export const filterListingsByLocation = (
|
|
227
|
+
allListings,
|
|
228
|
+
selectedLocation,
|
|
229
|
+
listingEntities
|
|
230
|
+
) => {
|
|
231
|
+
let results = allListings;
|
|
232
|
+
if (selectedLocation !== null) {
|
|
233
|
+
results = results.filter(item =>
|
|
234
|
+
selectedLocation.items.hasOwnProperty(item.id)
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
const mapItems = getDistinctItemsByProximity(results, listingEntities);
|
|
238
|
+
return { filteredListings: results, mapItems: mapItems };
|
|
239
|
+
};
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const getStorageObject = <T>(item: string, defaultItem: T | null = null): T | null => {
|
|
2
|
+
if (typeof window === 'undefined') return defaultItem;
|
|
3
|
+
const storageItem = localStorage.getItem(item);
|
|
4
|
+
if (storageItem === null || storageItem === 'undefined') {
|
|
5
|
+
localStorage.removeItem(item);
|
|
6
|
+
return defaultItem;
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(storageItem) ?? defaultItem;
|
|
10
|
+
} catch (error) {
|
|
11
|
+
console.error(`Error parsing JSON for ${item}:`, error);
|
|
12
|
+
return defaultItem;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const getStorageItem = (item: string, defaultItem: string | null = null): string | null => {
|
|
17
|
+
if (typeof window === 'undefined') return defaultItem;
|
|
18
|
+
const storageItem = localStorage.getItem(item);
|
|
19
|
+
if (storageItem === null || storageItem === 'undefined') {
|
|
20
|
+
localStorage.removeItem(item);
|
|
21
|
+
return defaultItem;
|
|
22
|
+
}
|
|
23
|
+
return storageItem ?? defaultItem;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const setStorageObject = (key: string, item: any): void => {
|
|
27
|
+
if (typeof window === 'undefined') return;
|
|
28
|
+
if (item === undefined) return;
|
|
29
|
+
try {
|
|
30
|
+
localStorage.setItem(key, JSON.stringify(item));
|
|
31
|
+
} catch (err) {
|
|
32
|
+
console.error(`Error setting item ${key} in localStorage:`, err);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
import { placeTypes } from '~/constants/placeTypes';
|
|
3
|
+
|
|
4
|
+
const customSVGIcon = (
|
|
5
|
+
type,
|
|
6
|
+
fillColor = "#FFFFFF",
|
|
7
|
+
strokeColor = "#000000",
|
|
8
|
+
backgroundFill = "#000000",
|
|
9
|
+
backgroundStroke = "#000000"
|
|
10
|
+
) => {
|
|
11
|
+
let svg = "";
|
|
12
|
+
switch (type) {
|
|
13
|
+
case placeTypes.FOOD:
|
|
14
|
+
svg = `
|
|
15
|
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
16
|
+
viewBox="0 0 60.8 89.6" preserveAspectRatio="xMidYMid meet" style="enable-background:new 0 0 60.8 89.6;" xml:space="preserve">
|
|
17
|
+
<style type="text/css">
|
|
18
|
+
.st0{fill:${fillColor}; stroke:${strokeColor};}
|
|
19
|
+
.svg-background{fill:${backgroundFill}; stroke:${backgroundStroke};}
|
|
20
|
+
</style>
|
|
21
|
+
<path class="svg-background" d="M30.4,3.9C14.3,3.9,1.3,16.8,1.3,33c0,21,18.6,29.1,29.1,56.6C40.9,62.1,59.5,54.9,59.5,33C60.3,16.8,46.6,3.9,30.4,3.9z"/>
|
|
22
|
+
<path class="st0" d="M25.7,36.6l0.6,15.8c0.1,2.4-2.3,2.4-2.3,2.4s-2.4,0-2.3-2.4l0.6-15.8c0.1-2-4.3-2.9-4-4.9l2.3-13.3h1.1
|
|
23
|
+
l-0.6,9.7l1.7,1.2l0.6-10.9h1.1l0.6,10.9l1.7-1.2l-0.6-9.7h1.1l2.3,13.3C29.7,33.7,25.6,34.6,25.7,36.6z"/>
|
|
24
|
+
<path class="st0" d="M40,52.4c0,2.4-2.3,2.4-2.3,2.4s-2.5,0-2.3-2.4L36.6,39c-0.9,0-3.4-0.4-3.4-2.4v-6.1c0-2.4,0.3-6.4,1.2-8.2
|
|
25
|
+
c1.1-2.4,3.9-4,5.6-4C40,18.3,40,52.4,40,52.4z"/>
|
|
26
|
+
</svg>
|
|
27
|
+
`;
|
|
28
|
+
break;
|
|
29
|
+
case placeTypes.TOURIST_ATTRACTION:
|
|
30
|
+
svg = `<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
31
|
+
viewBox="0 0 60.8 89.6" preserveAspectRatio="xMidYMid meet" style="enable-background:new 0 0 60.8 89.6;" xml:space="preserve">
|
|
32
|
+
<style type="text/css">
|
|
33
|
+
.st0{fill:${fillColor}; stroke:${strokeColor};}
|
|
34
|
+
.svg-background{fill:${backgroundFill}; stroke:${backgroundStroke};}
|
|
35
|
+
</style>
|
|
36
|
+
<path class="svg-background" d="M30.4,3.9C14.3,3.9,1.3,16.8,1.3,33c0,21,18.6,29.1,29.1,56.6C40.9,62.1,59.5,54.9,59.5,33C60.3,16.8,46.6,3.9,30.4,3.9z"/>
|
|
37
|
+
<path class="st0" d="M27,18.5c-1.2,0-1.7,1.1-2.2,2.2L23.7,23h-4.5c-1.9,0-3.4,1.5-3.4,3.4v11.2c0,1.9,1.5,3.4,3.4,3.4h22.5
|
|
38
|
+
c1.9,0,3.4-1.5,3.4-3.4V26.4c0-1.9-1.5-3.4-3.4-3.4h-4.5L36,20.8c-0.6-1.1-1-2.2-2.2-2.2H27z M19.2,25.3c0.6,0,1.1,0.5,1.1,1.1
|
|
39
|
+
c0,0.6-0.5,1.1-1.1,1.1c-0.6,0-1.1-0.5-1.1-1.1C18,25.8,18.5,25.3,19.2,25.3z M30.4,25.3c3.7,0,6.7,3,6.7,6.7s-3,6.7-6.7,6.7
|
|
40
|
+
s-6.7-3-6.7-6.7S26.7,25.3,30.4,25.3z M30.4,28.7c-1.9,0-3.4,1.5-3.4,3.4s1.5,3.4,3.4,3.4c1.9,0,3.4-1.5,3.4-3.4
|
|
41
|
+
S32.3,28.7,30.4,28.7z"/>
|
|
42
|
+
</svg>
|
|
43
|
+
`;
|
|
44
|
+
break;
|
|
45
|
+
case placeTypes.SCHOOL:
|
|
46
|
+
svg = `
|
|
47
|
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
48
|
+
viewBox="0 0 60.8 89.6" preserveAspectRatio="xMidYMid meet" style="enable-background:new 0 0 60.8 89.6;" xml:space="preserve">
|
|
49
|
+
<style type="text/css">
|
|
50
|
+
.st0{fill:${fillColor}; stroke:${strokeColor};}
|
|
51
|
+
.svg-background{fill:${backgroundFill}; stroke:${backgroundStroke};}
|
|
52
|
+
</style>
|
|
53
|
+
<path class="svg-background" d="M30.4,3.9C14.3,3.9,1.3,16.8,1.3,33c0,21,18.6,29.1,29.1,56.6C40.9,62.1,59.5,54.9,59.5,33C60.3,16.8,46.6,3.9,30.4,3.9z"/>
|
|
54
|
+
<path class="st0" d="M39.2,40.6c0,0-4.1,4.6-9.1,4.6S21,40.6,21,40.6v-5.2l9.1,5l9.1-5V40.6z"/>
|
|
55
|
+
<polygon class="st0" points="44.4,40.4 41.8,40.4 41.8,31.4 30.1,37.8 15.8,30 30.1,22.2 44.4,30 "/>
|
|
56
|
+
</svg>
|
|
57
|
+
`;
|
|
58
|
+
break;
|
|
59
|
+
case placeTypes.STORE:
|
|
60
|
+
svg = `<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
61
|
+
viewBox="0 0 60.8 89.6" preserveAspectRatio="xMidYMid meet" style="enable-background:new 0 0 60.8 89.6;" xml:space="preserve">
|
|
62
|
+
<style type="text/css">
|
|
63
|
+
.st0{fill:${fillColor}; stroke:${strokeColor};}
|
|
64
|
+
.svg-background{fill:${backgroundFill}; stroke:${backgroundStroke};}
|
|
65
|
+
</style>
|
|
66
|
+
<g>
|
|
67
|
+
<path class="svg-background" d="M30.4,3.9C14.3,3.9,1.3,16.8,1.3,33c0,21,18.6,29.1,29.1,56.6C40.9,62.1,59.5,54.9,59.5,33C60.3,16.8,46.6,3.9,30.4,3.9z"
|
|
68
|
+
/>
|
|
69
|
+
</g>
|
|
70
|
+
<path class="st0" d="M45.4,27.7L42,41.1c-0.1,0.6-0.7,1-1.3,1c1.8,0,3.3,1.5,3.3,3.3s-1.5,3.3-3.3,3.3s-3.3-1.5-3.3-3.3
|
|
71
|
+
s1.5-3.3,3.3-3.3H23.3c1.8,0,3.3,1.5,3.3,3.3s-1.5,3.3-3.3,3.3S20,47.2,20,45.4s1.5-3.3,3.3-3.3c-0.6,0-1.2-0.4-1.3-1l-4.1-16.4
|
|
72
|
+
h-1.3c-0.7,0-1.3-0.6-1.3-1.3s0.6-1.3,1.3-1.3h2.3c0.6,0,1.2,0.4,1.3,1l0.8,3h23.1c0.4,0,0.8,0.2,1.1,0.5
|
|
73
|
+
C45.4,26.9,45.5,27.3,45.4,27.7z"/>
|
|
74
|
+
<path d="M41.4,45.5c0-0.4-0.3-0.7-0.7-0.7S40,45.1,40,45.5C40.1,46.2,41.4,46.2,41.4,45.5z"/>
|
|
75
|
+
<path d="M24,45.5c0-0.4-0.3-0.7-0.7-0.7s-0.7,0.3-0.7,0.7C22.6,46.2,24,46.2,24,45.5z"/>
|
|
76
|
+
</svg>
|
|
77
|
+
`;
|
|
78
|
+
break;
|
|
79
|
+
case placeTypes.TRANSIT_STATION:
|
|
80
|
+
svg = `<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
81
|
+
viewBox="0 0 60.8 89.6" preserveAspectRatio="xMidYMid meet" style="enable-background:new 0 0 60.8 89.6;" xml:space="preserve">
|
|
82
|
+
<style type="text/css">
|
|
83
|
+
.st0{fill:${fillColor}; stroke:${strokeColor};}
|
|
84
|
+
.svg-background{fill:${backgroundFill}; stroke:${backgroundStroke};}
|
|
85
|
+
</style>
|
|
86
|
+
<g>
|
|
87
|
+
<path class="svg-background" d="M30.4,3.9C14.3,3.9,1.3,16.8,1.3,33c0,21,18.6,29.1,29.1,56.6C40.9,62.1,59.5,54.9,59.5,33C60.3,16.8,46.6,3.9,30.4,3.9z"
|
|
88
|
+
/>
|
|
89
|
+
</g>
|
|
90
|
+
<path class="st0" d="M26.3,41.3h-2.8L20.7,44h-1.4v-1.4l1.4-1.4c-2.3,0-4.2-1.9-4.2-4.2V26c0-2.3,1.9-4.2,4.2-4.2h9.7
|
|
91
|
+
c2.3,0,4.2,1.9,4.2,4.2v1.4h-2.8v-2.8H19.3v9.7h6.9v7H26.3z"/>
|
|
92
|
+
<path class="st0" d="M44.3,43c0,0.5-0.4,1-1,1h-0.8c-0.5,0-1-0.5-1-1.1v-1.7H30.4V43c0,0.5-0.4,1.1-0.9,1.1h-0.9c-0.5,0-1-0.5-1-1
|
|
93
|
+
v-7.6l2-5.7c0.2-0.6,0.7-0.9,1.4-0.9h10c0.6,0,1.1,0.4,1.3,0.9l2,5.7V43z"/>
|
|
94
|
+
<circle cx="20.7" cy="37.1" r="1.4"/>
|
|
95
|
+
<circle cx="41.5" cy="37.1" r="1.4"/>
|
|
96
|
+
<circle cx="30.4" cy="37.1" r="1.4"/>
|
|
97
|
+
<polygon points="31,30.2 29.6,34.4 42.4,34.4 40.9,30.2 "/>
|
|
98
|
+
</svg>
|
|
99
|
+
`;
|
|
100
|
+
break;
|
|
101
|
+
case placeTypes.PLACE_OF_WORSHIP:
|
|
102
|
+
svg = `<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
103
|
+
viewBox="0 0 60.8 89.6" style="enable-background:new 0 0 60.8 89.6;" xml:space="preserve">
|
|
104
|
+
<style type="text/css">
|
|
105
|
+
.st0{fill:${fillColor}; stroke:${strokeColor};}
|
|
106
|
+
.svg-background{fill:${backgroundFill}; stroke:${backgroundStroke};}
|
|
107
|
+
</style>
|
|
108
|
+
<path class="svg-background" d="M30.4,3.9C14.3,3.9,1.3,16.8,1.3,33c0,21,18.6,29.1,29.1,56.6C40.9,62.1,59.5,54.9,59.5,33C60.3,16.8,46.6,3.9,30.4,3.9z"/>
|
|
109
|
+
<path class="st0" d="M21.3,40.8h-3.8c-1.3,0-2.3-1-2.3-2.3v-4.3c0-0.8,0.5-1.6,1.2-2l4.9-2.7V40.8z"/>
|
|
110
|
+
<path class="st0" d="M38,40.8h-4.6v-4.6c0-1.7-1.4-3-3-3c-1.7,0-3,1.4-3,3v4.6h-4.6V30c0-0.8,0.4-1.5,1.1-2l1.9-1.2v-5.1l0,0
|
|
111
|
+
c0-0.4,0.2-0.8,0.4-1.1l3.6-3.6c0.3-0.3,0.8-0.3,1.1,0l3.6,3.6c0.3,0.3,0.4,0.7,0.4,1.1v5.1l1.9,1.2c0.7,0.4,1.1,1.2,1.1,2L38,40.8
|
|
112
|
+
L38,40.8z"/>
|
|
113
|
+
<path class="st0" d="M45.6,38.5c0,1.3-1,2.3-2.3,2.3h-3.8V29.5l4.9,2.7c0.7,0.4,1.2,1.2,1.2,2C45.6,34.2,45.6,38.5,45.6,38.5z"/>
|
|
114
|
+
</svg>
|
|
115
|
+
`;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const iconUrl = `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
|
|
120
|
+
return iconUrl;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const iconPath = "M5.5 0A5.27 5.27 0 0 0 0 5.01v.49c0 1.73 1.38 3.43 2.07 4.12s3.43 4.12 3.43 4.12 2.75-3.43 3.43-4.12 2.06-2.39 2.06-4.12c.14-2.9-2.1-5.36-5-5.5H5.5Zm-.04 5.71c-.32 0-.57-.27-.56-.58 0-.32.27-.57.58-.56.32 0 .57.27.56.58 0 .31-.25.55-.56.56h-.02Z";
|
|
124
|
+
|
|
125
|
+
export const markerIconProps = (placeMarkerConfigs, type) => {
|
|
126
|
+
|
|
127
|
+
const scaledWidth = placeMarkerConfigs.size;
|
|
128
|
+
const scaledHeight = (scaledWidth * 3) / 2;
|
|
129
|
+
const iconUrl = customSVGIcon(
|
|
130
|
+
type,
|
|
131
|
+
placeMarkerConfigs.colors.innerFillColor,
|
|
132
|
+
placeMarkerConfigs.colors.innerStrokeColor,
|
|
133
|
+
placeMarkerConfigs.colors.outerFillColor,
|
|
134
|
+
placeMarkerConfigs.colors.outerStrokeColor
|
|
135
|
+
);
|
|
136
|
+
return {
|
|
137
|
+
url: iconUrl,
|
|
138
|
+
scaledSize: new google.maps.Size(scaledWidth, scaledHeight),
|
|
139
|
+
anchor: new google.maps.Point(scaledWidth / 2, scaledHeight)
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const iconProps = () => {
|
|
144
|
+
return {
|
|
145
|
+
path: iconPath,
|
|
146
|
+
fillOpacity: 1,
|
|
147
|
+
strokeWeight: 1.75,
|
|
148
|
+
scale: 1.6,
|
|
149
|
+
anchor: new google.maps.Point(12, 17)
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export const markerIcon = markerConfigs => {
|
|
154
|
+
return {
|
|
155
|
+
...iconProps(),
|
|
156
|
+
fillColor: markerConfigs.fillColor,
|
|
157
|
+
strokeColor: markerConfigs.strokeColor
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export const markerIconSelected = markerConfigs => {
|
|
162
|
+
return {
|
|
163
|
+
...iconProps(),
|
|
164
|
+
fillColor: markerConfigs.selectedFillColor,
|
|
165
|
+
strokeColor: markerConfigs.selectedStrokeColor
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export const pinIcon = markerConfigs => {
|
|
170
|
+
const { fillColor, strokeColor } = markerConfigs;
|
|
171
|
+
|
|
172
|
+
const svg = `
|
|
173
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="-6 -4 24 24">
|
|
174
|
+
<path d="${iconPath}" fill="${fillColor}" stroke="${strokeColor}" stroke-width="2"/>
|
|
175
|
+
</svg>
|
|
176
|
+
`;
|
|
177
|
+
|
|
178
|
+
return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
|
|
179
|
+
};
|
|
180
|
+
|