-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new observation form for custom observations #70
base: main
Are you sure you want to change the base?
Conversation
bc0db61
to
72d19ec
Compare
72d19ec
to
40f9a78
Compare
…l_pages Feat: Add button to redirect user to external page if link on content
feat: add external uri button on Station
): Promise<ObservationDetails | null> { | ||
const schema = await fetchObservation(type); | ||
const detailsList = await fetchObservationDetails(type); | ||
const values = detailsList?.find(detail => detail.id === parseInt(id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const values = detailsList?.find(detail => detail.id === parseInt(id)); | |
const values = detailsList?.find(detail => detail.id === Number(id)); |
or parseInt(id, 10))
label: (schema?.json_schema_form.properties?.[key] as any)?.title, | ||
})), | ||
id, | ||
contributedAt: values?.contributed_at, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional chaining seems useless with the early return line 90
const schema = await fetchObservation(type); | ||
const detailsList = await fetchObservationDetails(type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can use a Promise.all
to parallelize queries?
const observation = await fetchObservation(id); | ||
return { | ||
...observation, | ||
json_schema_form: { | ||
...observation?.json_schema_form, | ||
properties: { | ||
...observation?.json_schema_form?.properties, | ||
}, | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's more readable to remove all optional chaining by using an early return if observation === null
const station = await fetchStation(id); | ||
const observations = await fetchStationObservations(id); | ||
if (station) { | ||
return { | ||
...station, | ||
observations, | ||
}; | ||
} else { | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const station = await fetchStation(id); | |
const observations = await fetchStationObservations(id); | |
if (station) { | |
return { | |
...station, | |
observations, | |
}; | |
} else { | |
return null; | |
} | |
const station = await fetchStation(id); | |
if (!station) { | |
return null; | |
}; | |
const observations = await fetchStationObservations(id); | |
return { | |
...station, | |
observations, | |
}; |
Or Promise.all the queries
@@ -34,10 +35,12 @@ | |||
"next": "^13.5.4", | |||
"next-intl": "2.15.0-beta.5", | |||
"next-themes": "^0.2.1", | |||
"node-fetch": "^3.3.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useful?
if ( | ||
properties === null || | ||
(!properties.name && !properties.category && !properties.label) | ||
) { | ||
return null; | ||
} | ||
if (layer.type === undefined || !layer.url || !properties.id) { | ||
return <Tooltip>{properties.name ?? properties.category}</Tooltip>; | ||
return ( | ||
<Tooltip> | ||
{properties.name ?? properties.category ?? properties.label} | ||
</Tooltip> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const label = properties?.name || properties?.category || properties?.label;
if (!label) {
return null;
}
// [...]
return (<Tooltip>{label}</Tooltip>
src/components/observation-cta.tsx
Outdated
const [observations, setObservations] = useState<Observation[]>([]); | ||
|
||
useEffect(() => { | ||
getObservations().then(res => setObservations(res)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To do this, we need useQuery or its equivalent
}?${params.toString()}`} | ||
title={observation.label} | ||
> | ||
{observation.description ?? ''} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without description, it results an empty link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description should be a prop of ListItem
No description provided.