Fetch related opportunities in useEffect
cgen-4b72f60894e1411fa5a856631a0c77ce
This commit is contained in:
parent
d19f49e92e
commit
01740f29ba
1 changed files with 9 additions and 0 deletions
|
|
@ -51,6 +51,15 @@ export default function OpportunityDetail() {
|
|||
try {
|
||||
const data = await getOpportunityById(id);
|
||||
setOpportunity(data);
|
||||
|
||||
// Fetch related opportunities (same arm, different from current)
|
||||
const relatedResult = await getOpportunities({
|
||||
arm: data.arm_affiliation,
|
||||
limit: 3,
|
||||
});
|
||||
setRelatedOpportunities(
|
||||
relatedResult.data.filter((opp) => opp.id !== id)
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch opportunity:", error);
|
||||
setOpportunity(null);
|
||||
|
|
|
|||
Loading…
Reference in a new issue