Skip to content

feature: replace hardcoded search with real API calls#32

Open
0zzy4 wants to merge 2 commits into
mainfrom
API
Open

feature: replace hardcoded search with real API calls#32
0zzy4 wants to merge 2 commits into
mainfrom
API

Conversation

@0zzy4

@0zzy4 0zzy4 commented May 31, 2026

Copy link
Copy Markdown
Collaborator

Description

Replaced the hardcoded search results with the real API call results so that it dynamically pulls from DynamoDB

  • Note: not sure why git shows that I deleted and rewrote the entire file, but that is not the case

Related issue(s)

Link the issue(s) that this PR addresses.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

How did you test this?

  1. Select "Spanish"
  2. Search "venir" (we only have 2 words in the database currently)
  3. The results with the definition and other data should populate and be accurate
  4. Repeat these steps by selecting "Chinese" and searching "电脑“

Checklist

  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • New and existing unit tests pass locally with my changes.

GenAI usage

  • What model(s) did you use?
  • Percent of AI-written code?
  • Any drawbacks?
  • (Optional) Paste your main prompts here for feedback on better prompting techniques for efficiency.

@netlify

netlify Bot commented May 31, 2026

Copy link
Copy Markdown

Deploy Preview for teal-figolla-ef4831 ready!

Name Link
🔨 Latest commit 8e047cd
🔍 Latest deploy log https://app.netlify.com/projects/teal-figolla-ef4831/deploys/6a1c9f671a729e0009cad1e4
😎 Deploy Preview https://deploy-preview-32--teal-figolla-ef4831.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented May 31, 2026

Copy link
Copy Markdown

Deploy Preview for unique-figolla-0d1392 failed.

Name Link
🔨 Latest commit 566302b
🔍 Latest deploy log https://app.netlify.com/projects/unique-figolla-0d1392/deploys/6a41ac06218fe40008ff7314

@netlify

netlify Bot commented May 31, 2026

Copy link
Copy Markdown

Deploy Preview for spontaneous-ganache-9d995f failed.

Name Link
🔨 Latest commit 8e047cd
🔍 Latest deploy log https://app.netlify.com/projects/spontaneous-ganache-9d995f/deploys/6a1c9f67c7e3970008053129

@netlify

netlify Bot commented May 31, 2026

Copy link
Copy Markdown

Deploy Preview for calm-shortbread-db1ac1 failed.

Name Link
🔨 Latest commit 566302b
🔍 Latest deploy log https://app.netlify.com/projects/calm-shortbread-db1ac1/deploys/6a41ac085142dd0008888b37

@netlify

netlify Bot commented May 31, 2026

Copy link
Copy Markdown

Deploy Preview for gleaming-mermaid-1c37de failed.

Name Link
🔨 Latest commit 8e047cd
🔍 Latest deploy log https://app.netlify.com/projects/gleaming-mermaid-1c37de/deploys/6a1c9f672f9fe50008ac4a44

@cboiteux2765 cboiteux2765 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code functionality mostly looks good, just some small code good practice comments and have some different mock api unit tests that don't result in the same constant output for related words & definitions.

Comment thread frontend/lib/api.ts Outdated
lemma: string
}

export interface CreateCardParams {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're already using lang & lemma interface combo for Lookup Params you can just use a LookupParams attribute in here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good callout, I'll update CreateCardParams to extend LookupParams

Comment thread frontend/lib/api.ts
}

class ApiClient {
private baseUrl: string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious, why did you decide to make these global vars private, as well as the request function?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't write this file. This is from the mockup that Eswar worked on. But if I were to guess, it's because no other files need these vars.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind the token should be private for sure, as long as it's encrypted or stored behind .env so this is fine I think

Comment thread frontend/lib/api.ts
Comment thread frontend/lib/api.ts
export const apiClient = new ApiClient(API_BASE_URL)

// Mock data for development
export const mockLookup = async (word: string, language: string) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a mock lookup that supports all words & languages but has constant definitions, examples, and related words (I know it's just a mock), can you create different "unit tests" with different mock examples across several popular languages and words? Because it might be confusing to see the same output from all different (word, language combos) in the mock and keeping it 1:1 helps us determine if it works for the different inputs

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is just a placeholder; It's no longer used, as we're actually making API calls now.

word: string
language: string
definitions: string[]
examples: { src: string; tgt: string }[]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you define what you mean by src and tgt examples here with a small comment?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src and tgt stand for source and target, representing the example sentence in the target language (src) and the translated version (tgt). I've added them to the JSON schema in DynamoDB:

Image

Comment thread frontend/app/page.tsx Outdated

export default function LookupPage() {
const [searchQuery, setSearchQuery] = useState('')
const [selectedLanguage, setSelectedLanguage] = useState('Spanish')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you don't want this to be hard coded you just set it to Spanish to be able to see the examples right? For the future it could be coded to the user's default language in their region but this is fine for now, just making sure you're aware

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, yes I meant to change this. I like your idea about setting it to the user's default language

@cboiteux2765

Copy link
Copy Markdown
Contributor

Out for 2 weeks so the Netlify deployment fix will be delayed but you can opt to ignore whitespace changes so that git diff doesn't show those: git merge -Xignore-space-at-eol to remove them in the merge and git diff -w command to show the non-whitespaced file diffs.

@cboiteux2765 cboiteux2765 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still some nit comments but I don't see major issues with code functionality so should be good to merge

className="w-full flex items-center justify-between p-4 bg-gradient-to-r from-terracotta/5 to-ochre/5 rounded-xl border-2 border-dashed border-terracotta/30 hover:border-terracotta/50 transition-all duration-300"
>
<span className="font-serif font-bold text-xl text-ink flex items-center gap-2">
<span>✍️</span>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nit change (can be a future addition) but just not sure if the emoji will render on all platforms

Comment thread frontend/lib/api.ts
Comment thread frontend/lib/api.ts
}

class ApiClient {
private baseUrl: string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind the token should be private for sure, as long as it's encrypted or stored behind .env so this is fine I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants