@abcagency/hc-ui-components 1.8.8 → 1.8.9
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.
|
@@ -15,10 +15,16 @@ const ItemsListContainer = ({ fieldNames, showMap, fieldsShown, specialFeatures
|
|
|
15
15
|
const { selectedListItem } = useMap();
|
|
16
16
|
const { trackEvent, eventTypes } = useTrackEvent();
|
|
17
17
|
const itemExpandedContent = (item, recruiter) => item ? (ExpandListComponent ? React.createElement(ExpandListComponent, { listing: item }) : React.createElement(ListingDetailsContainer, { item: item, recruiter: recruiter })) : null;
|
|
18
|
+
// Track if component has mounted to avoid hydration mismatch with localStorage
|
|
19
|
+
const [hasMounted, setHasMounted] = React.useState(false);
|
|
20
|
+
React.useEffect(() => {
|
|
21
|
+
setHasMounted(true);
|
|
22
|
+
}, []);
|
|
18
23
|
// Use useMemo to avoid hydration mismatch - create new array instead of mutating prop
|
|
24
|
+
// Don't add travelTime until after mount to avoid SSR/client mismatch from localStorage
|
|
19
25
|
const effectiveFieldsShown = useMemo(() => {
|
|
20
26
|
const fields = [...fieldsShown];
|
|
21
|
-
if (!fields.includes('travelTime') && commuteLocation != null && Object.entries(commuteLocation).length > 0 && !noEntities) {
|
|
27
|
+
if (hasMounted && !fields.includes('travelTime') && commuteLocation != null && Object.entries(commuteLocation).length > 0 && !noEntities) {
|
|
22
28
|
fields.push('travelTime');
|
|
23
29
|
fieldNames['travelTime'] = 'Commute';
|
|
24
30
|
}
|
|
@@ -26,7 +32,7 @@ const ItemsListContainer = ({ fieldNames, showMap, fieldsShown, specialFeatures
|
|
|
26
32
|
return fields.filter(x => x !== 'travelTime');
|
|
27
33
|
}
|
|
28
34
|
return fields;
|
|
29
|
-
}, [fieldsShown, commuteLocation, noEntities, fieldNames]);
|
|
35
|
+
}, [fieldsShown, commuteLocation, noEntities, fieldNames, hasMounted]);
|
|
30
36
|
const setTrackedSortSetting = (sortSetting) => {
|
|
31
37
|
trackEvent(eventTypes.LIST_SORTED, sortSetting);
|
|
32
38
|
setSortSetting(sortSetting);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item-list-container.js","sources":["../../../../src/components/containers/list/item-list-container.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport useListLogic from '~/hooks/useList';\nimport { useMap } from '~/contexts/mapContext';\nimport { useMapList } from '~/contexts/mapListContext';\nimport { useTrackEvent } from '~/contexts/trackEventContext';\nimport ItemsList from '~/components/modules/list/item-list';\nimport Accordion from '~/components/modules/accordions/default';\nimport MapAccordionItemContainer from '~/components/containers/accordions/map-accordion-item-container';\nimport { dynamicSort } from '~/util/sortUtil';\nimport { Listing } from '~/types/Listings';\nimport ListingDetailsContainer from '../jobListing/listing-details-container';\n\ninterface ItemsListContainerProps {\n fieldNames: Record<string, string>;\n showMap: boolean;\n fieldsShown: string[];\n specialFeatures: any;\n}\n\nconst ItemsListContainer: React.FC<ItemsListContainerProps> = ({\n\tfieldNames,\n\tshowMap,\n\tfieldsShown,\n\tspecialFeatures\n}) => {\n\tconst { filteredListings, loading, commuteLocation, sortSetting, setSortSetting, ExpandListComponent, favorites, noEntities } = useMapList();\n\tconst { itemLimit, loader, scrollContainerRef, itemRefs } = useListLogic(filteredListings as any);\n\tconst { selectedListItem } = useMap();\n\tconst { trackEvent, eventTypes } = useTrackEvent() as any;\n\tconst itemExpandedContent = (item: any, recruiter: any) =>\n\t\titem ? (ExpandListComponent ? <ExpandListComponent listing={item} /> : <ListingDetailsContainer item={item} recruiter={recruiter} />) : null;\n\n\t// Use useMemo to avoid hydration mismatch - create new array instead of mutating prop\n\tconst effectiveFieldsShown = useMemo(() => {\n\t\tconst fields = [...fieldsShown];\n\t\tif (!fields.includes('travelTime') && commuteLocation != null && Object.entries(commuteLocation).length > 0 && !noEntities) {\n\t\t\tfields.push('travelTime');\n\t\t\tfieldNames['travelTime'] = 'Commute';\n\t\t} else if (fields.includes('travelTime') && (!commuteLocation || noEntities)) {\n\t\t\treturn fields.filter(x => x !== 'travelTime');\n\t\t}\n\t\treturn fields;\n\t}, [fieldsShown, commuteLocation, noEntities, fieldNames]);\n\n\tconst setTrackedSortSetting = (sortSetting: { field: string; type: string }) => {\n\t\ttrackEvent(eventTypes.LIST_SORTED, sortSetting);\n\t\tsetSortSetting(sortSetting);\n\t};\n\t\t//fieldsShown.push('favorite');\n\n\treturn (\n\t\t<ItemsList\n\t\t\tfieldNames={fieldNames}\n\t\t\tshowMap={showMap}\n\t\t\tfieldsShown={effectiveFieldsShown}\n\t\t\tfilteredListings={filteredListings}\n\t\t\tloading={loading}\n\t\t\tsortSetting={sortSetting}\n\t\t\tsetSortSetting={setTrackedSortSetting}\n\t\t\titemLimit={itemLimit}\n\t\t\tloader={loader}\n\t\t\tscrollContainerRef={scrollContainerRef}\n\t\t\titemRefs={itemRefs}\n\t\t\tselectedListItem={selectedListItem}\n\t\t\tincludeFavorite={true}\n\t\t>\n\t\t\t<Accordion className=\"hc-divide-y hc-divide-uiAccent/10\" defaultValue={selectedListItem?.id}>\n\t\t\t\t{(sortSetting ? dynamicSort(filteredListings, sortSetting.field, sortSetting.type, favorites as any) : filteredListings)\n\t\t\t\t\t.slice(0, itemLimit)\n\t\t\t\t\t.map((item: Listing, index: number) => (\n\t\t\t\t\t\t<MapAccordionItemContainer\n\t\t\t\t\t\t\tkey={item.id}\n\t\t\t\t\t\t\tshowMap={showMap}\n\t\t\t\t\t\t\titem={item}\n\t\t\t\t\t\t\titemRefs={itemRefs}\n\t\t\t\t\t\t\tfieldsShown={effectiveFieldsShown}\n\t\t\t\t\t\t\titemExpandedContent={itemExpandedContent}\n\t\t\t\t\t\t\tspecialFeatures={specialFeatures}\n\t\t\t\t\t\t\tisActive={selectedListItem?.id === item.id}\n\t\t\t\t\t\t\tindex={index}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t</Accordion>\n\t\t</ItemsList>\n\t);\n};\n\nexport default ItemsListContainer;\n"],"names":[],"mappings":";;;;;;;;;;;AAmBA,MAAM,kBAAkB,GAAsC,CAAC,EAC9D,UAAU,EACV,OAAO,EACP,WAAW,EACX,eAAe,EACf,KAAI;IACJ,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,mBAAmB,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAAC;AAC7I,IAAA,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,GAAG,YAAY,CAAC,gBAAuB,CAAC,CAAC;AAClG,IAAA,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,EAAE,CAAC;IACtC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,aAAa,EAAS,CAAC;IAC1D,MAAM,mBAAmB,GAAG,CAAC,IAAS,EAAE,SAAc,KACrD,IAAI,IAAI,mBAAmB,GAAI,KAAA,CAAA,aAAA,CAAC,mBAAmB,EAAC,EAAA,OAAO,EAAE,IAAI,EAAA,CAAI,GAAG,oBAAC,uBAAuB,EAAA,EAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAI,CAAA,IAAI,IAAI,CAAC;;AAG/I,IAAA,MAAM,oBAAoB,GAAG,OAAO,CAAC,MAAK;AACzC,QAAA,MAAM,MAAM,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,eAAe,IAAI,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"item-list-container.js","sources":["../../../../src/components/containers/list/item-list-container.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport useListLogic from '~/hooks/useList';\nimport { useMap } from '~/contexts/mapContext';\nimport { useMapList } from '~/contexts/mapListContext';\nimport { useTrackEvent } from '~/contexts/trackEventContext';\nimport ItemsList from '~/components/modules/list/item-list';\nimport Accordion from '~/components/modules/accordions/default';\nimport MapAccordionItemContainer from '~/components/containers/accordions/map-accordion-item-container';\nimport { dynamicSort } from '~/util/sortUtil';\nimport { Listing } from '~/types/Listings';\nimport ListingDetailsContainer from '../jobListing/listing-details-container';\n\ninterface ItemsListContainerProps {\n fieldNames: Record<string, string>;\n showMap: boolean;\n fieldsShown: string[];\n specialFeatures: any;\n}\n\nconst ItemsListContainer: React.FC<ItemsListContainerProps> = ({\n\tfieldNames,\n\tshowMap,\n\tfieldsShown,\n\tspecialFeatures\n}) => {\n\tconst { filteredListings, loading, commuteLocation, sortSetting, setSortSetting, ExpandListComponent, favorites, noEntities } = useMapList();\n\tconst { itemLimit, loader, scrollContainerRef, itemRefs } = useListLogic(filteredListings as any);\n\tconst { selectedListItem } = useMap();\n\tconst { trackEvent, eventTypes } = useTrackEvent() as any;\n\tconst itemExpandedContent = (item: any, recruiter: any) =>\n\t\titem ? (ExpandListComponent ? <ExpandListComponent listing={item} /> : <ListingDetailsContainer item={item} recruiter={recruiter} />) : null;\n\n\t// Track if component has mounted to avoid hydration mismatch with localStorage\n\tconst [hasMounted, setHasMounted] = React.useState(false);\n\tReact.useEffect(() => {\n\t\tsetHasMounted(true);\n\t}, []);\n\n\t// Use useMemo to avoid hydration mismatch - create new array instead of mutating prop\n\t// Don't add travelTime until after mount to avoid SSR/client mismatch from localStorage\n\tconst effectiveFieldsShown = useMemo(() => {\n\t\tconst fields = [...fieldsShown];\n\t\tif (hasMounted && !fields.includes('travelTime') && commuteLocation != null && Object.entries(commuteLocation).length > 0 && !noEntities) {\n\t\t\tfields.push('travelTime');\n\t\t\tfieldNames['travelTime'] = 'Commute';\n\t\t} else if (fields.includes('travelTime') && (!commuteLocation || noEntities)) {\n\t\t\treturn fields.filter(x => x !== 'travelTime');\n\t\t}\n\t\treturn fields;\n\t}, [fieldsShown, commuteLocation, noEntities, fieldNames, hasMounted]);\n\n\tconst setTrackedSortSetting = (sortSetting: { field: string; type: string }) => {\n\t\ttrackEvent(eventTypes.LIST_SORTED, sortSetting);\n\t\tsetSortSetting(sortSetting);\n\t};\n\t\t//fieldsShown.push('favorite');\n\n\treturn (\n\t\t<ItemsList\n\t\t\tfieldNames={fieldNames}\n\t\t\tshowMap={showMap}\n\t\t\tfieldsShown={effectiveFieldsShown}\n\t\t\tfilteredListings={filteredListings}\n\t\t\tloading={loading}\n\t\t\tsortSetting={sortSetting}\n\t\t\tsetSortSetting={setTrackedSortSetting}\n\t\t\titemLimit={itemLimit}\n\t\t\tloader={loader}\n\t\t\tscrollContainerRef={scrollContainerRef}\n\t\t\titemRefs={itemRefs}\n\t\t\tselectedListItem={selectedListItem}\n\t\t\tincludeFavorite={true}\n\t\t>\n\t\t\t<Accordion className=\"hc-divide-y hc-divide-uiAccent/10\" defaultValue={selectedListItem?.id}>\n\t\t\t\t{(sortSetting ? dynamicSort(filteredListings, sortSetting.field, sortSetting.type, favorites as any) : filteredListings)\n\t\t\t\t\t.slice(0, itemLimit)\n\t\t\t\t\t.map((item: Listing, index: number) => (\n\t\t\t\t\t\t<MapAccordionItemContainer\n\t\t\t\t\t\t\tkey={item.id}\n\t\t\t\t\t\t\tshowMap={showMap}\n\t\t\t\t\t\t\titem={item}\n\t\t\t\t\t\t\titemRefs={itemRefs}\n\t\t\t\t\t\t\tfieldsShown={effectiveFieldsShown}\n\t\t\t\t\t\t\titemExpandedContent={itemExpandedContent}\n\t\t\t\t\t\t\tspecialFeatures={specialFeatures}\n\t\t\t\t\t\t\tisActive={selectedListItem?.id === item.id}\n\t\t\t\t\t\t\tindex={index}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t</Accordion>\n\t\t</ItemsList>\n\t);\n};\n\nexport default ItemsListContainer;\n"],"names":[],"mappings":";;;;;;;;;;;AAmBA,MAAM,kBAAkB,GAAsC,CAAC,EAC9D,UAAU,EACV,OAAO,EACP,WAAW,EACX,eAAe,EACf,KAAI;IACJ,MAA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AC,CAAC,IAAa,EAAE,KAAa,MACjC,KAAA,CAAA,aAAA,CAAC,yBAAyB,EAAA,EACzB,GAAG,EAAE,IAAI,CAAC,EAAE,EACZ,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,oBAAoB,EACjC,mBAAmB,EAAE,mBAAmB,EACxC,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,gBAAgB,EAAE,EAAE,KAAK,IAAI,CAAC,EAAE,EAC1C,KAAK,EAAE,KAAK,EAAA,CACX,CACF,CAAC,CACQ,CACD,EACX;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -30,17 +30,24 @@ const ItemsListContainer: React.FC<ItemsListContainerProps> = ({
|
|
|
30
30
|
const itemExpandedContent = (item: any, recruiter: any) =>
|
|
31
31
|
item ? (ExpandListComponent ? <ExpandListComponent listing={item} /> : <ListingDetailsContainer item={item} recruiter={recruiter} />) : null;
|
|
32
32
|
|
|
33
|
+
// Track if component has mounted to avoid hydration mismatch with localStorage
|
|
34
|
+
const [hasMounted, setHasMounted] = React.useState(false);
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
setHasMounted(true);
|
|
37
|
+
}, []);
|
|
38
|
+
|
|
33
39
|
// Use useMemo to avoid hydration mismatch - create new array instead of mutating prop
|
|
40
|
+
// Don't add travelTime until after mount to avoid SSR/client mismatch from localStorage
|
|
34
41
|
const effectiveFieldsShown = useMemo(() => {
|
|
35
42
|
const fields = [...fieldsShown];
|
|
36
|
-
if (!fields.includes('travelTime') && commuteLocation != null && Object.entries(commuteLocation).length > 0 && !noEntities) {
|
|
43
|
+
if (hasMounted && !fields.includes('travelTime') && commuteLocation != null && Object.entries(commuteLocation).length > 0 && !noEntities) {
|
|
37
44
|
fields.push('travelTime');
|
|
38
45
|
fieldNames['travelTime'] = 'Commute';
|
|
39
46
|
} else if (fields.includes('travelTime') && (!commuteLocation || noEntities)) {
|
|
40
47
|
return fields.filter(x => x !== 'travelTime');
|
|
41
48
|
}
|
|
42
49
|
return fields;
|
|
43
|
-
}, [fieldsShown, commuteLocation, noEntities, fieldNames]);
|
|
50
|
+
}, [fieldsShown, commuteLocation, noEntities, fieldNames, hasMounted]);
|
|
44
51
|
|
|
45
52
|
const setTrackedSortSetting = (sortSetting: { field: string; type: string }) => {
|
|
46
53
|
trackEvent(eventTypes.LIST_SORTED, sortSetting);
|