Skip to content

Commit

Permalink
PR review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo-Duke committed Feb 6, 2025
1 parent f00fcf3 commit d2edb1e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
11 changes: 6 additions & 5 deletions src/api/customObservations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export async function getObservationDetails(
): Promise<ObservationDetails | null> {
const schema = await fetchObservation(type);
const detailsList = await fetchObservationDetails(type);
const values = detailsList?.find(detail => detail.id === parseInt(id));
const values = detailsList?.find(detail => detail.id === parseInt(id, 10));

if (!values) return null;

Expand All @@ -98,23 +98,24 @@ export async function getObservationDetails(
label: (schema?.json_schema_form.properties?.[key] as any)?.title,
})),
id,
contributedAt: values?.contributed_at,
contributedAt: values.contributed_at,
label: schema?.label,
description: schema?.description,
attachments: values?.attachments,
attachments: values.attachments,
};

return details;
}

export async function getObservation(id: string) {
const observation = await fetchObservation(id);
if (!observation || !observation.json_schema_form) return null;
return {
...observation,
json_schema_form: {
...observation?.json_schema_form,
...observation.json_schema_form,
properties: {
...observation?.json_schema_form?.properties,
...observation.json_schema_form.properties,
},
},
};
Expand Down
13 changes: 6 additions & 7 deletions src/api/stations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,12 @@ export async function getStations() {

export async function getStation(id: number): Promise<Station | null> {
const station = await fetchStation(id);
const observations = await fetchStationObservations(id);
if (station) {
return {
...station,
observations,
};
} else {
if (!station) {
return null;
}
const observations = await fetchStationObservations(id);
return {
...station,
observations,
};
}
9 changes: 3 additions & 6 deletions src/components/map/geometry-tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ export const GeometryTooltip = ({
) {
return null;
}
if (layer.type === undefined || !layer.url || !properties.id) {
return (
<Tooltip>
{properties.name ?? properties.category ?? properties.label}
</Tooltip>
);
const label = properties?.name || properties?.category || properties?.label;
if (label) {
return <Tooltip>{label}</Tooltip>;
}
return (
<Tooltip
Expand Down
10 changes: 6 additions & 4 deletions src/components/observation-cta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function ObservationCTA({ observations }: OversationsCTAProps) {
}?${params.toString()}`}
title={observation.label}
>
{observation.description ?? ''}
{observation.description}
</ListItem>
))}
{observations?.length === 0 &&
Expand Down Expand Up @@ -84,9 +84,11 @@ const ListItem = React.forwardRef<
>
<span>
<span className="text-sm font-medium leading-none">{title}</span>
<span className="line-clamp-2 block text-sm leading-snug text-muted-foreground">
{children}
</span>
{children && (
<span className="line-clamp-2 block text-sm leading-snug text-muted-foreground">
{children}
</span>
)}
</span>
<Icons.chevronRight className="shrink-0" />
</Link>
Expand Down

0 comments on commit d2edb1e

Please sign in to comment.