@abcagency/hc-ui-components 1.3.23 → 1.3.25

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 (102) hide show
  1. package/package.json +4 -5
  2. package/src/.editorconfig +12 -0
  3. package/src/apis/hcApi.ts +109 -0
  4. package/src/bundleIndex.js +14 -0
  5. package/src/clientToken.js +9 -0
  6. package/src/components/HireControlMap.js +135 -0
  7. package/src/components/containers/accordions/filter-container.js +48 -0
  8. package/src/components/containers/accordions/filter-item-container.js +66 -0
  9. package/src/components/containers/accordions/map-accordion-item-container.js +70 -0
  10. package/src/components/containers/filter/commute-container.js +89 -0
  11. package/src/components/containers/filter/filter-container.js +76 -0
  12. package/src/components/containers/filter/filter-item-container.js +71 -0
  13. package/src/components/containers/filter/location-container.js +45 -0
  14. package/src/components/containers/filter/points-of-interest-container.js +33 -0
  15. package/src/components/containers/filter/points-of-interest-radio-item-container.js +35 -0
  16. package/src/components/containers/filter/search-container.js +50 -0
  17. package/src/components/containers/jobListing/listing-details-container.js +40 -0
  18. package/src/components/containers/list/item-list-container.tsx +81 -0
  19. package/src/components/containers/list/list-item/list-item-container.js +43 -0
  20. package/src/components/containers/maps/info-window-content-container.js +51 -0
  21. package/src/components/containers/maps/map-container.js +204 -0
  22. package/src/components/containers/maps/map-list-container.js +48 -0
  23. package/src/components/containers/maps/map-marker-container.js +78 -0
  24. package/src/components/modules/accordions/MapAccordionItem.js +30 -0
  25. package/src/components/modules/accordions/default.js +171 -0
  26. package/src/components/modules/accordions/filterItem.js +27 -0
  27. package/src/components/modules/accordions/filters.js +32 -0
  28. package/src/components/modules/buttons/button-group-apply.js +123 -0
  29. package/src/components/modules/buttons/commute-pill.js +22 -0
  30. package/src/components/modules/buttons/default.js +194 -0
  31. package/src/components/modules/buttons/items-pill.js +35 -0
  32. package/src/components/modules/buttons/pill-wrapper.js +27 -0
  33. package/src/components/modules/buttons/show-all-button.js +20 -0
  34. package/src/components/modules/cards/default.js +167 -0
  35. package/src/components/modules/cards/filter.js +56 -0
  36. package/src/components/modules/dialogs/apply-dialog.js +48 -0
  37. package/src/components/modules/filter/commute.js +108 -0
  38. package/src/components/modules/filter/index.js +55 -0
  39. package/src/components/modules/filter/item.js +48 -0
  40. package/src/components/modules/filter/location.js +48 -0
  41. package/src/components/modules/filter/radio-item.js +42 -0
  42. package/src/components/modules/filter/search.js +65 -0
  43. package/src/components/modules/filter/sort.js +83 -0
  44. package/src/components/modules/grid.js +54 -0
  45. package/src/components/modules/icon.js +33 -0
  46. package/src/components/modules/jobListing/listing-details.js +109 -0
  47. package/src/components/modules/list/field-mapper.js +114 -0
  48. package/src/components/modules/list/header-item.js +91 -0
  49. package/src/components/modules/list/header.js +49 -0
  50. package/src/components/modules/list/item-expand-card/index.js +22 -0
  51. package/src/components/modules/list/item-expand-card/recruiter-contact-nav.js +50 -0
  52. package/src/components/modules/list/item-expand-card/recruiter-details.js +68 -0
  53. package/src/components/modules/list/item-expand-card/recruiter-headshot.js +22 -0
  54. package/src/components/modules/list/item-list.tsx +84 -0
  55. package/src/components/modules/list/list-item/list-item.js +130 -0
  56. package/src/components/modules/maps/info-window-card.js +17 -0
  57. package/src/components/modules/maps/info-window-content.js +35 -0
  58. package/src/components/modules/maps/map-list.js +28 -0
  59. package/src/components/modules/maps/map-marker.js +29 -0
  60. package/src/components/modules/maps/map.js +76 -0
  61. package/src/components/modules/maps/place-marker.js +41 -0
  62. package/src/components/modules/maps/tabs.js +81 -0
  63. package/src/constants/eventTypes.js +13 -0
  64. package/src/constants/placeTypes.js +8 -0
  65. package/src/contexts/mapContext.tsx +129 -0
  66. package/src/contexts/mapListContext.tsx +311 -0
  67. package/src/contexts/placesContext.js +102 -0
  68. package/src/contexts/trackEventContext.js +14 -0
  69. package/src/enums/SectionType.ts +9 -0
  70. package/src/hooks/useList.js +89 -0
  71. package/src/index.js +3 -0
  72. package/src/services/configService.ts +16 -0
  73. package/src/services/googlePlacesNearbyService.ts +42 -0
  74. package/src/services/listingAggregatorService.ts +76 -0
  75. package/src/services/listingEntityService.ts +16 -0
  76. package/src/services/listingService.ts +40 -0
  77. package/src/services/recruiterService.ts +18 -0
  78. package/src/styles/bundle.css +268 -0
  79. package/src/styles/index.css +24 -0
  80. package/src/types/Address.ts +7 -0
  81. package/src/types/ContentSection.ts +9 -0
  82. package/src/types/GetListingParams.ts +8 -0
  83. package/src/types/LatLng.ts +4 -0
  84. package/src/types/ListingEntity.ts +11 -0
  85. package/src/types/ListingFields.ts +25 -0
  86. package/src/types/Listings.ts +32 -0
  87. package/src/types/Recruiter.ts +9 -0
  88. package/src/types/SimilarListing.ts +24 -0
  89. package/src/types/config/Colors.ts +8 -0
  90. package/src/types/config/MapConfig.ts +31 -0
  91. package/src/types/config/PointsOfInterestConfig.ts +13 -0
  92. package/src/types/config/SearchConfig.ts +4 -0
  93. package/src/util/arrayUtil.js +3 -0
  94. package/src/util/fieldMapper.js +22 -0
  95. package/src/util/filterUtil.js +239 -0
  96. package/src/util/loading.js +17 -0
  97. package/src/util/localStorageUtil.ts +34 -0
  98. package/src/util/mapIconUtil.js +180 -0
  99. package/src/util/mapUtil.js +91 -0
  100. package/src/util/sortUtil.js +33 -0
  101. package/src/util/stringUtils.js +6 -0
  102. package/src/util/urlFilterUtil.js +85 -0
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+
3
+ const FilterItem = ({
4
+ className,
5
+ item,
6
+ type,
7
+ itemKey,
8
+ hasCount,
9
+ field,
10
+ activeItem,
11
+ setActiveItem,
12
+ changeHandler,
13
+ ...rest
14
+ }) => {
15
+ const itemName = item.name ? item.name : item;
16
+
17
+ return (
18
+ <label
19
+ className={`
20
+ hc-flex hc-items-start hc-gap-2 hc-px-2 hc-py-1.5 hc-rounded-sm hc-text-sm hc-cursor-pointer hc-transition hover:hc-bg-uiAccent/5
21
+ ${className ?? ""}
22
+ `}
23
+ {...rest}
24
+ >
25
+ <input
26
+ id={itemKey}
27
+ name={field}
28
+ disabled={item.count === 0}
29
+ value={itemName}
30
+ type={type}
31
+ className="hc-size-4 hc-mt-px hc-text-primary hc-border-uiAccent/30 hc-transition-colors hc-rounded-sm"
32
+ checked={activeItem}
33
+ onChange={() => {
34
+ setActiveItem(!activeItem);
35
+ changeHandler();
36
+ }}
37
+ />
38
+ <span className="font-medium">{itemName}</span>
39
+ {hasCount && (
40
+ <span className="hc-inline-block hc-mt-1 hc-ml-auto hc-text-xs hc-leading-none hc-text-primary">
41
+ ({item.count})
42
+ </span>
43
+ )}
44
+ </label>
45
+ );
46
+ };
47
+
48
+ export default FilterItem;
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import Accordion from '~/components/modules/accordions/default';
3
+ import FilterCard from '~/components/modules/cards/filter';
4
+ import AccordionFilterItem from '~/components/containers/accordions/filter-item-container';
5
+ import Loading from '~/util/loading';
6
+
7
+ const FilterLocation = ({
8
+ className,
9
+ defaultValue,
10
+ setDefaultValue,
11
+ setLocation,
12
+ setSelectedListItem,
13
+ locations,
14
+ setSelectedFilters,
15
+ selectedFilters,
16
+ children
17
+ }) => {
18
+ return (
19
+ <FilterCard className={className ?? ""}>
20
+ <FilterCard.Title icon="fluent:location-16-filled">
21
+ <span>
22
+ <span className="hc-hidden lg:hc-inline">Job</span> location
23
+ </span>
24
+ </FilterCard.Title>
25
+ {!locations && <Loading />}
26
+ {locations && (
27
+ <Accordion defaultValue={defaultValue} className="hc-space-y-4">
28
+ {locations?.map(filter => (
29
+ <AccordionFilterItem
30
+ key={filter.id}
31
+ filter={filter}
32
+ setDefaultValue={setDefaultValue}
33
+ selectedFilters={selectedFilters}
34
+ setSelectedFilters={prevFilters => {
35
+ setSelectedFilters(prevFilters);
36
+ setLocation(null);
37
+ setSelectedListItem(null);
38
+ }}
39
+ />
40
+ ))}
41
+ {children}
42
+ </Accordion>
43
+ )}
44
+ </FilterCard>
45
+ );
46
+ };
47
+
48
+ export default FilterLocation;
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import Icon from '~/components/modules/icon';
3
+
4
+ const RadioItem = ({
5
+ className,
6
+ item,
7
+ field,
8
+ isActive,
9
+ changeHandler,
10
+ ...rest
11
+ }) => {
12
+ return (
13
+ <label
14
+ key={item.key}
15
+ className={`
16
+ hc-flex hc-items-start hc-gap-2 hc-px-2 hc-py-1.5 hc-rounded-sm hc-text-sm hc-cursor-pointer hc-transition hover:hc-bg-uiAccent/5
17
+ ${item.count === 0 ? 'hc-text-uiDisabled hc-cursor-not-allowed' : 'hover:hc-bg-uiAccent/5'}
18
+ ${className ?? ""}
19
+ `}
20
+ {...rest}
21
+ >
22
+ <input
23
+ key={item.key}
24
+ id={item.key}
25
+ name={field}
26
+ value={item.key}
27
+ type="radio"
28
+ className="hc-size-4 hc-mt-px hc-text-primary hc-border-uiAccent/30 hc-transition-colors hc-rounded-full"
29
+ checked={isActive}
30
+ onClick={changeHandler}
31
+ />
32
+ <span className="hc-font-medium">{item.key}</span>
33
+ {isActive &&
34
+ <div className="hc-w-full hc-unselect-div">
35
+ <Icon className="hc-float-right" icon="mdi:times"></Icon>
36
+ </div>
37
+ }
38
+ </label>
39
+ );
40
+ };
41
+
42
+ export default RadioItem;
@@ -0,0 +1,65 @@
1
+ import React from 'react';
2
+ import Button from '~/components/modules/buttons/default';
3
+ import Icon from '~/components/modules/icon';
4
+ import FilterCard from '~/components/modules/cards/filter';
5
+
6
+ const Search = ({
7
+ inputPlaceholder,
8
+ showSearchIcon,
9
+ className,
10
+ labelClassName,
11
+ inputValue,
12
+ handleInputChange,
13
+ handleReset,
14
+ label
15
+ }) => {
16
+ return (
17
+ <FilterCard as="form" className={className ?? ""}>
18
+ <FilterCard.Title
19
+ as="label"
20
+ icon="fluent:search-12-filled"
21
+ className={labelClassName ?? ""}
22
+ >
23
+ <span>
24
+ {label}
25
+ </span>
26
+ </FilterCard.Title>
27
+
28
+ <div className="hc-relative hc-flex hc-items-center hc-px-2 hc-rounded hc-bg-white hc-border hc-border-uiAccent/20 focus-within:hc-ring-1 focus-within:hc-ring-uiAccent">
29
+ {showSearchIcon && (
30
+ <Icon
31
+ icon="fluent:search-12-filled"
32
+ size="hc-size-4"
33
+ className="hc-mr-2 hc-text-uiAccent/50"
34
+ />
35
+ )}
36
+ <input
37
+ type="text"
38
+ name="search"
39
+ onKeyDown={e => {
40
+ if (e.key === 'Enter') {
41
+ e.preventDefault();
42
+ }
43
+ }}
44
+ placeholder={inputPlaceholder}
45
+ value={inputValue}
46
+ className="hc-w-full hc-px-0 hc-py-2 hc-text-sm hc-border-0 hc-transition-colors placeholder:hc-text-uiText/50 focus:hc-ring-0 focus:hc-outline-none"
47
+ onChange={handleInputChange}
48
+ />
49
+
50
+ <Button.Btn
51
+ type="reset"
52
+ variant="icon"
53
+ size="sqsm"
54
+ className={`transition-opacity ${inputValue ? "hc-opacity-100" : "hc-opacity-0 hc-pointer-events-none"}`}
55
+ onClick={handleReset}
56
+ >
57
+ <span className="hc-sr-only">Clear</span>
58
+ <Button.Icon icon="uil:times" className="hc-text-uiAccent" />
59
+ </Button.Btn>
60
+ </div>
61
+ </FilterCard>
62
+ );
63
+ };
64
+
65
+ export default Search;
@@ -0,0 +1,83 @@
1
+ import React, { forwardRef } from 'react';
2
+ import * as Select from '@radix-ui/react-select';
3
+ import { twMerge } from 'tailwind-merge';
4
+
5
+ import Icon from '~/components/modules/icon';
6
+ import Button from '~/components/modules/buttons/default';
7
+
8
+ const FilterSort = ({ className, fields, setSortSetting, fieldNames }) => {
9
+ const handleSortChange = value => {
10
+ const [field, direction] = value.split("-");
11
+ setSortSetting({ field, type: direction });
12
+ };
13
+
14
+ return (
15
+ <div className={className ?? ""}>
16
+ <Select.Root onValueChange={handleSortChange}>
17
+ <Select.Trigger asChild aria-label="Sort">
18
+ <Button.Btn variant="outline" size="sm" className="hc-normal-case">
19
+ <Button.Body className="hc-justify-center">
20
+ <Select.Value placeholder={
21
+ <span className="hc-flex hc-items-center hc-gap-2">
22
+ Sort
23
+ <Icon icon="mdi:sort" />
24
+ </span>
25
+ } />
26
+ <Select.Icon>
27
+ <Button.Icon icon="mdi:chevron-down" />
28
+ </Select.Icon>
29
+ </Button.Body>
30
+ </Button.Btn>
31
+ </Select.Trigger>
32
+ <Select.Portal>
33
+ <Select.Content className={`hc-relative hc-z-[200] hc-overflow-hidden hc-bg-white hc-rounded-md `}>
34
+ <Select.ScrollUpButton className="hc-flex hc-items-center hc-justify-center hc-h-5 hc-bg-white hc-text-primary hc-cursor-default">
35
+ <Icon icon="mdi:chevron-up" />
36
+ </Select.ScrollUpButton>
37
+ <Select.Viewport className="hc-p-1">
38
+ {fields.map(field => (
39
+ <Select.Group key={field}>
40
+ <SelectItem value={`${field}-asc`}>
41
+ <span className="hc-flex hc-items-center hc-justify-between hc-gap-2 hc-w-full">
42
+ {fieldNames[field] ?? field}
43
+ <Icon icon="mdi:sort-ascending" />
44
+ </span>
45
+ </SelectItem>
46
+ <SelectItem value={`${field}-desc`}>
47
+ <span className="hc-flex hc-items-center hc-justify-between hc-gap-2 w-full">
48
+ {fieldNames[field] ?? field}
49
+ <Icon icon="mdi:sort-descending" />
50
+ </span>
51
+ </SelectItem>
52
+ </Select.Group>
53
+ ))}
54
+ </Select.Viewport>
55
+ <Select.ScrollDownButton className="hc-flex hc-items-center hc-justify-center hc-h-5 hc-bg-white hc-text-primary hc-cursor-default">
56
+ <Icon icon="mdi:chevron-down" />
57
+ </Select.ScrollDownButton>
58
+ </Select.Content>
59
+ </Select.Portal>
60
+ </Select.Root>
61
+ </div>
62
+ );
63
+ };
64
+
65
+ const SelectItem = forwardRef(({ children, className, ...props }, forwardedRef) => (
66
+ <Select.Item
67
+ className={twMerge(
68
+ "hc-text-sm hc-leading-none hc-rounded-sm hc-flex hc-items-center hc-w-full hc-py-1.5 hc-pr-4 hc-pl-7 hc-relative hc-select-none hc-cursor-pointer data-[disabled]:hc-text-gray-500 data-[disabled]:hc-pointer-events-none data-[highlighted]:hc-outline-none data-[highlighted]:hc-bg-primary data-[highlighted]:hc-text-white",
69
+ className
70
+ )}
71
+ {...props}
72
+ ref={forwardedRef}
73
+ >
74
+ <Select.ItemText>{children}</Select.ItemText>
75
+ <Select.ItemIndicator className="hc-absolute hc-left-0 hc-w-8 hc-inline-flex hc-items-center hc-justify-center">
76
+ <Icon icon="mdi:check" />
77
+ </Select.ItemIndicator>
78
+ </Select.Item>
79
+ ));
80
+
81
+ SelectItem.displayName = "SelectItem";
82
+
83
+ export default FilterSort;
@@ -0,0 +1,54 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { twMerge } from 'tailwind-merge';
3
+
4
+ const Grid = forwardRef((props, ref) => {
5
+ const {
6
+ as = 'div',
7
+ children,
8
+ className,
9
+ autoRows = true,
10
+ columns = 'md:hc-grid-cols-2',
11
+ gap = 'hc-gap-12 lg:hc-gap-16',
12
+ ...rest
13
+ } = props;
14
+
15
+ const Container = as;
16
+
17
+ return (
18
+ <Container
19
+ ref={ref}
20
+ className={twMerge(
21
+ 'hc-grid',
22
+ gap,
23
+ autoRows ? 'hc-auto-rows-min' : '',
24
+ 'hc-grid-cols-1',
25
+ columns,
26
+ className ?? ''
27
+ )}
28
+ {...rest}
29
+ >
30
+ {children}
31
+ </Container>
32
+ );
33
+ });
34
+
35
+ export const GridItem = ({
36
+ as = 'div',
37
+ children,
38
+ className
39
+ }) => {
40
+ const Container = as;
41
+
42
+ return (
43
+ <Container
44
+ className={className ?? ''}
45
+ >
46
+ {children}
47
+ </Container>
48
+ );
49
+ };
50
+
51
+ Grid.Item = GridItem;
52
+
53
+ Grid.displayName = 'Grid';
54
+ export default Grid;
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { Icon } from '@iconify/react';
3
+
4
+ const IconContained = ({
5
+ className,
6
+ size,
7
+ icon,
8
+ iconClasses,
9
+ title,
10
+ ...iconProps
11
+ }) => {
12
+ return (
13
+ <span
14
+ title={title}
15
+ className={`
16
+ hc-inline-block hc-align-middle
17
+ ${className ?? ''}
18
+ ${size ?? ''}
19
+ `}
20
+ >
21
+ <Icon
22
+ icon={icon}
23
+ className={`
24
+ ${iconClasses ?? ''}
25
+ ${size ?? ''}
26
+ `}
27
+ {...iconProps}
28
+ />
29
+ </span>
30
+ );
31
+ };
32
+
33
+ export default IconContained;
@@ -0,0 +1,109 @@
1
+ import React from 'react';
2
+ import RecruiterHeadshot from '~/components/modules/list/item-expand-card/recruiter-headshot';
3
+ import RecruiterDetails from '~/components/modules/list/item-expand-card/recruiter-details';
4
+ import RecruiterContactNav from '~/components/modules/list/item-expand-card/recruiter-contact-nav';
5
+ import ApplyButtonGroup from '~/components/modules/buttons/button-group-apply';
6
+ import CommutePill from '~/components/modules/buttons/commute-pill';
7
+
8
+ const ListingDetails = ({
9
+ item,
10
+ recruiter,
11
+ travelTime,
12
+ useDetailsPostMessage,
13
+ navigateToDetails,
14
+ navigateToEasyApply,
15
+ Link,
16
+ linkFormat,
17
+ useApplyDialog,
18
+ internalApplyLink,
19
+ companyName,
20
+ jobsDomain,
21
+ trackEvent,
22
+ eventTypes
23
+ }) => {
24
+ if (!item) {
25
+ return null;
26
+ }
27
+
28
+ let matchingRecruiter = recruiter;
29
+ console.log(matchingRecruiter);
30
+ return (
31
+ <div className="hc-w-full">
32
+ <div className="hc-grow hc-flex hc-flex-wrap hc-items-center hc-gap-4">
33
+ {matchingRecruiter?.headshot && (
34
+ <RecruiterHeadshot
35
+ image={`${matchingRecruiter.headshot.includes("http") ? '' :'https:'}${matchingRecruiter.headshot}`}
36
+ alt={matchingRecruiter?.firstName}
37
+ className="hc-bg-gray-300"
38
+ />
39
+ )}
40
+ {matchingRecruiter && (
41
+ <RecruiterDetails
42
+ contactNav={
43
+ <RecruiterContactNav>
44
+ {matchingRecruiter?.mobilePhone && (
45
+ <RecruiterContactNav.Button
46
+ href={`tel:${matchingRecruiter.mobilePhone}`}
47
+ title={`Call ${matchingRecruiter.mobilePhone}`}
48
+ icon="fluent:phone-32-regular"
49
+ />
50
+ )}
51
+ {matchingRecruiter?.email && (
52
+ <RecruiterContactNav.Button
53
+ href={`mailto:${matchingRecruiter.email}`}
54
+ title={`email ${matchingRecruiter.email}`}
55
+ icon="bi:envelope-at"
56
+ />
57
+ )}
58
+ {matchingRecruiter?.linkedIn && (
59
+ <RecruiterContactNav.Button
60
+ href={matchingRecruiter.linkedIn}
61
+ title="LinkedIn"
62
+ icon="ant-design:linkedin-outlined"
63
+ />
64
+ )}
65
+ </RecruiterContactNav>
66
+ }
67
+ >
68
+ {matchingRecruiter?.firstName || matchingRecruiter?.lastName && (
69
+ <RecruiterDetails.Title>
70
+ {`${matchingRecruiter?.firstName} ${matchingRecruiter?.lastName}`}
71
+ </RecruiterDetails.Title>
72
+ )}
73
+ {item.details?.recruiter?.title && (
74
+ <RecruiterDetails.Text>
75
+ {item.details.recruiter.title}
76
+ </RecruiterDetails.Text>
77
+ )}
78
+ </RecruiterDetails>
79
+ )}
80
+ <ApplyButtonGroup
81
+ useDetailsPostMessage={useDetailsPostMessage}
82
+ navigateToDetails={navigateToDetails}
83
+ navigateToEasyApply={navigateToEasyApply}
84
+ Link={Link}
85
+ linkFormat={linkFormat}
86
+ includeDialog={useApplyDialog}
87
+ internalApplyLink={internalApplyLink}
88
+ companyName={companyName}
89
+ applyUrl={item?.applyUrl}
90
+ itemId={item.id}
91
+ item={item}
92
+ trackEvent={trackEvent}
93
+ eventTypes={eventTypes}
94
+ detailsUrl={item.useClientJobUrl ? item?.detailsUrl : `${jobsDomain}${item.id}`}
95
+ className={`
96
+ lg:hc-w-auto hc-order-first lg:hc-order-last md:hc-self-center hc-py-2 lg:hc-p-0 lg:hc-mb-0 hc-border-b lg:hc-border-none hc-border-uiAccent/20
97
+ ${matchingRecruiter ? "lg:hc-flex-col lg:hc-w-auto" : "lg:hc-flex-row"}
98
+ `}
99
+ />
100
+ </div>
101
+ <div className="hc-w-full">
102
+ <CommutePill travelTime={travelTime} className="hc-ml-0" />
103
+ </div>
104
+ </div>
105
+ );
106
+ };
107
+
108
+ export default ListingDetails;
109
+
@@ -0,0 +1,114 @@
1
+ import React from 'react';
2
+
3
+ import Grid from '~/components/modules/grid';
4
+ import Icon from '~/components/modules/icon';
5
+ import PillWrapper from '~/components/modules/buttons/pill-wrapper';
6
+
7
+ import { capitalize } from '~/util/stringUtils';
8
+
9
+ const FieldMapper = ({
10
+ item,
11
+ fieldsShown,
12
+ specialFeatures,
13
+ handleFavouriteClick,
14
+ isFavorite,
15
+ includeFavorite = true
16
+ }) => {
17
+ const orderedFields = fieldsShown.filter(field => field in item.fields);
18
+
19
+ const specialFeaturePills = field => {
20
+ return field === 'position' && specialFeatures &&
21
+ Object.entries(specialFeatures).map(([featureKey, featureLabel]) => {
22
+ return item.fields[featureKey] == 1 && (
23
+ <PillWrapper key={featureKey}>{featureLabel}</PillWrapper>
24
+ );
25
+ });
26
+ };
27
+
28
+ return (
29
+ <>
30
+ {orderedFields.map(field => {
31
+ let value = item.fields[field];
32
+ return (
33
+ <Grid.Item
34
+ key={field}
35
+ className={`
36
+ hc-hidden md:hc-block
37
+ ${field.toLowerCase() === "position" ? "hc-col-span-2 hc-text-balance hc-pr-2 hc-font-semibold" : "hc-col-span-1"}
38
+ `}
39
+ >
40
+ <span className="hc-sr-only">{capitalize(field)}</span>
41
+ {value}
42
+ <br />
43
+ {specialFeaturePills(field)}
44
+ </Grid.Item>
45
+ );
46
+ })}
47
+ <Grid.Item className="md:hc-hidden">
48
+ {fieldsShown.includes("position") &&
49
+ <>
50
+ <div className="hc-flex hc-items-start">
51
+ <div className="hc-flex hc-justify-between hc-items-center hc-min-w-[100%]"> {}
52
+ <h3 className="hc-font-bold hc-mb-3 hc-flex-1">{item.fields.position}</h3>
53
+ {includeFavorite && <div className="hc-flex hc-justify-end hc-pb-2">
54
+ <Icon
55
+ icon={isFavorite ? "mdi:heart" : "mdi:heart-outline"}
56
+ size="hc-size-3.5"
57
+ iconClasses={isFavorite ? "hc-text-primary" : ""}
58
+ className={`hc-transition-opacity hc-duration-300 hc-cursor-pointer
59
+ ${isFavorite ? "hc-opacity-100" : "hc-text-uiText/60 group-hover:hc-opacity-100"}
60
+ `}
61
+ onClick={e => handleFavouriteClick(e, item)}
62
+ />
63
+ </div>
64
+ }
65
+ </div>
66
+ </div>
67
+ {specialFeatures && <div className='hc-pb-4'>{specialFeaturePills("position", true)} </div>}
68
+ </>
69
+ }
70
+
71
+ <ul className="hc-space-y-2 hc-text-xs">
72
+ {[
73
+ {
74
+ field: "category",
75
+ name: "Category",
76
+ icon: "icon-park-solid:tree-list"
77
+ },
78
+ {
79
+ field: "schedule",
80
+ name: "Schedule",
81
+ icon: "gravity-ui:clock-fill"
82
+ },
83
+ {
84
+ field: "cityState",
85
+ name: "Location",
86
+ icon: "fluent:location-16-filled"
87
+ },
88
+ {
89
+ field: "travelTime",
90
+ name: "Commute",
91
+ icon: "ri:pin-distance-fill"
92
+ }
93
+ ].map(listItem => (
94
+ (fieldsShown.includes(listItem.field) && item.fields[listItem.field]) &&
95
+ <li
96
+ key={listItem.field}
97
+ className="hc-flex hc-gap-2"
98
+ >
99
+ <Icon
100
+ icon={listItem.icon}
101
+ size="hc-size-3.5"
102
+ className="hc-text-uiAccent/30"
103
+ />
104
+ <span className="hc-sr-only">{listItem.name}</span>
105
+ {item.fields[listItem.field]}
106
+ </li>
107
+ ))}
108
+ </ul>
109
+ </Grid.Item>
110
+ </>
111
+ );
112
+ };
113
+
114
+ export default FieldMapper;
@@ -0,0 +1,91 @@
1
+ import React, { useState, useEffect } from 'react';
2
+
3
+ import Button from '~/components/modules/buttons/default';
4
+
5
+ const SORT_STATE = {
6
+ notSorted: "not-sorted",
7
+ sortedAsc: "sorted-asc",
8
+ sortedDesc: "sorted-desc"
9
+ };
10
+
11
+ const HeaderItem = ({
12
+ className,
13
+ children,
14
+ field,
15
+ setSortSetting,
16
+ sortSetting,
17
+ isSortable,
18
+ ...rest
19
+ }) => {
20
+ const [isSorted, setIsSorted] = useState(SORT_STATE.notSorted);
21
+
22
+ const handleChange = field => {
23
+ if (isSortable === false)
24
+ return;
25
+ let setting = {
26
+ field: field,
27
+ type: isSorted === SORT_STATE.sortedAsc ? "desc" : "asc"
28
+ };
29
+ setSortSetting(setting);
30
+ isSorted === SORT_STATE.notSorted
31
+ ? setIsSorted(SORT_STATE.sortedAsc)
32
+ : isSorted === SORT_STATE.sortedAsc
33
+ ? setIsSorted(SORT_STATE.sortedDesc)
34
+ : setIsSorted(SORT_STATE.sortedAsc);
35
+ };
36
+
37
+ useEffect(() => {
38
+ if (sortSetting?.field != null && sortSetting.field != field) {
39
+ setIsSorted(SORT_STATE.notSorted);
40
+ } else if (
41
+ sortSetting?.field != null &&
42
+ isSorted == SORT_STATE.notSorted &&
43
+ sortSetting.field == field
44
+ ) {
45
+ setIsSorted(
46
+ sortSetting.type == "asc"
47
+ ? SORT_STATE.sortedAsc
48
+ : SORT_STATE.sortedDesc
49
+ );
50
+ }
51
+ }, [sortSetting, isSorted, field]);
52
+
53
+ return (
54
+ <Button.Btn
55
+ onClick={() => handleChange(field)}
56
+ variant="none"
57
+ className={`
58
+ hc-p-2 hc-rounded-none hc-text-left hc-normal-case hover:hc-bg-uiAccent/5 focus:hc-bg-uiAccent/5
59
+ ${field.toLowerCase() === "position" ? "hc-col-span-2" : "hc-col-span-1"}
60
+ ${className ?? ""}
61
+ `}
62
+ {...rest}
63
+ >
64
+ <Button.Body>
65
+ <span className="hc-font-semibold">{children}</span>
66
+ {isSortable && (
67
+ <div className="hc-flex hc-flex-col hc-pr-2">
68
+ <Button.Icon
69
+ icon="bi:caret-up-fill"
70
+ size="hc-size-2.5"
71
+ className={`
72
+ hc-transition-opacity
73
+ ${isSorted === "sorted-asc" ? "hc-opacity-100 hc-text-primary" : "hc-opacity-30"}
74
+ `}
75
+ />
76
+ <Button.Icon
77
+ icon="bi:caret-down-fill"
78
+ size="hc-size-2.5"
79
+ className={`
80
+ transition-opacity
81
+ ${isSorted === "sorted-desc" ? "hc-opacity-100" : "hc-opacity-30"}
82
+ `}
83
+ />
84
+ </div>
85
+ )}
86
+ </Button.Body>
87
+ </Button.Btn>
88
+ );
89
+ };
90
+
91
+ export default HeaderItem;