Skip to content

Commit

Permalink
Dont show default observation types when custom ones exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo-Duke committed Apr 29, 2024
1 parent f6fe2f1 commit fe4a4fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/app/[locale]/map/observation/[path]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ export default async function ObservationPage({ params: { path } }: Props) {
const isDefaultObservation = DEFAULT_OBSERVATION_TYPES.includes(path);

if (isDefaultObservation) {
observation = {};
jsonSchema = (await getObservationJsonSchema(path)) as JSONSchema;
} else {
observation = await getObservation(path);
jsonSchema = observation?.json_schema_form as JSONSchema;
}

if (!observation) {
if (!isDefaultObservation && !observation) {
return null;
}

Expand Down
17 changes: 9 additions & 8 deletions src/components/observation-cta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ export function ObservationCTA() {
{observation.description ?? ''}
</ListItem>
))}
{DEFAULT_OBSERVATION_TYPES.map(observation => (
<ListItem
href={`/map/observation/${observation}?${params.toString()}`}
title={t(`${observation}.label`)}
>
{t(`${observation}.shortDescription`)}
</ListItem>
))}
{observations?.length === 0 &&
DEFAULT_OBSERVATION_TYPES.map(observation => (
<ListItem
href={`/map/observation/${observation}?${params.toString()}`}
title={t(`${observation}.label`)}
>
{t(`${observation}.shortDescription`)}
</ListItem>
))}
</ul>
</NavigationMenuContent>
</NavigationMenuItem>
Expand Down

0 comments on commit fe4a4fe

Please sign in to comment.