Skip to content

Commit

Permalink
Add ability to hide categories and last assured date
Browse files Browse the repository at this point in the history
  • Loading branch information
devcshort committed Aug 28, 2023
1 parent b813754 commit 7dfa38e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 29 deletions.
4 changes: 4 additions & 0 deletions packages/client/app.defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
"description": "211 connects callers, at no cost, to critical health and human services in their community. If you're unable to find a service, please dial 211 for assistance."
},
"showLocationInput": false
},
"resource": {
"hideCategories": false,
"hideLastAssured": false
}
},
"menus": {
Expand Down
68 changes: 39 additions & 29 deletions packages/client/components/organisms/ResourceOverviewSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
USER_PREF_COORDS,
USER_PREF_LOCATION,
} from '../../lib/constants/cookies';
import { useAppConfig } from '../../lib/hooks/useAppConfig';

type Props = {
id: string;
Expand All @@ -45,6 +46,7 @@ export function ResourceOverviewSection(props: Props) {
const theme = useMantineTheme();
const [cookies] = useCookies();
const [coords, setCoords] = useState(null);
const config = useAppConfig();

useEffect(() => {
if (cookies[USER_PREF_COORDS] && cookies[USER_PREF_LOCATION]) {
Expand Down Expand Up @@ -76,36 +78,44 @@ export function ResourceOverviewSection(props: Props) {

<Divider />

<Title size="h4" mt="lg" mb="xs" order={3} color="primary">
{t('categories')}
</Title>
<Group>
{props.categories?.map((el: any) => {
return (
<Badge
key={el.code}
component={Link}
href={`/search?query=${encodeURIComponent(
el.code
)}&query_label=${encodeURIComponent(
el.name
)}&query_type=taxonomy`}
sx={{
textDecoration: 'underline',
cursor: 'pointer',
textTransform: 'initial',
}}
>
{el.name}
</Badge>
);
})}
</Group>
{config?.pages?.resource?.hideCategories ? null : (
<>
<Title size="h4" mt="lg" mb="xs" order={3} color="primary">
{t('categories')}
</Title>
<Group>
{props.categories?.map((el: any) => {
return (
<Badge
key={el.code}
component={Link}
href={`/search?query=${encodeURIComponent(
el.code
)}&query_label=${encodeURIComponent(
el.name
)}&query_type=taxonomy`}
sx={{
textDecoration: 'underline',
cursor: 'pointer',
textTransform: 'initial',
}}
>
{el.name}
</Badge>
);
})}
</Group>
</>
)}

<Title size="h4" mt="lg" order={3} color="primary">
{t('last_assured')}
</Title>
<Text size="xs">{props.lastAssuredOn || t('unknown')}</Text>
{config?.pages?.resource?.hideLastAssured ? null : (
<>
<Title size="h4" mt="lg" order={3} color="primary">
{t('last_assured')}
</Title>
<Text size="xs">{props.lastAssuredOn || t('unknown')}</Text>
</>
)}

<MediaQuery largerThan="md" styles={{ flexDirection: 'row' }}>
<Stack mt="lg">
Expand Down

0 comments on commit 7dfa38e

Please sign in to comment.