Skip to content

Commit

Permalink
fix(api): agents params
Browse files Browse the repository at this point in the history
  • Loading branch information
chainsona committed Mar 2, 2024
1 parent b81a39a commit 17a8c6c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/app/api/agents/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ const agents: any[] = [
image:
"https://pbs.twimg.com/profile_images/1640718191558291456/IHqdwitj_400x400.jpg",
interests: [
"coding",
"non-fungible-token",
"real-world-asset",
"decentralized-physical-infrastructure-networks",
Expand Down Expand Up @@ -349,6 +350,6 @@ export async function GET(request: Request) {
}

return Response.json({
data: [...featuredAgents, ...filteredAgents],
data: [...featuredAgents, ...agents],
});
}
18 changes: 15 additions & 3 deletions src/components/OnboardingAgents.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { Oswald } from "next/font/google";
import { use, useCallback, useEffect, useMemo, useState } from "react";
import { useCallback, useEffect, useMemo, useState } from "react";
import { toast } from "react-toastify";
import { useWallet } from "@solana/wallet-adapter-react";

Expand Down Expand Up @@ -101,7 +101,14 @@ export default function OnboardingAgents({

const data = await res.json();

setAgents(data.data);
const filteredAgents = (data.data || []).filter((a: any) => {
for (const i of a.interests) {
if ((userInterests || []).includes(i)) return true;
}
return false;
});

setAgents(filteredAgents);
}, []);

useEffect(() => {
Expand All @@ -122,7 +129,12 @@ export default function OnboardingAgents({
</div>
</div>
<SelectList
items={agents || []}
items={(agents || []).filter((a) => {
for (const i of userInterests) {
if ((userInterests || []).includes(i)) return true;
}
return false;
})}
selectedItems={selectedAgents}
setSelectedItems={setSelectedAgents}
showImage={true}
Expand Down

0 comments on commit 17a8c6c

Please sign in to comment.