-
Notifications
You must be signed in to change notification settings - Fork 1
Fetch Mock Json data to client end #36
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
Conversation
Co-authored-by: Jay Gee <JMG3000@users.noreply.github.com>
…gration with NextLink
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.
Pull request overview
This PR implements search functionality with mock JSON data on the client side, along with various code cleanup improvements across multiple files.
- Adds a Combobox-based search feature that filters mock data from a JSON file
- Updates icon exports to include MinusIcon and PlusIcon
- Refactors code quality improvements (const vs let, removing unused imports)
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
src/components/ui/icons/index.ts |
Adds MinusIcon and PlusIcon exports from react-icons/fa |
src/app/stop-the-stigma/page.tsx |
Refactors variable declarations from let to const and removes unused MdMoon import |
src/app/search/page.tsx |
Implements main search functionality with Combobox component and mock data integration |
src/app/search/mock.json |
Adds new mock data file with searchable items containing title, link, and dataValue fields |
src/app/page.tsx |
Removes unused useBreakpointValue import |
src/app/contact/page.tsx |
Removes unused BodyTemplate and SectionTemplate imports |
src/app/about-us/page.tsx |
Adds asChild prop to ChakraImage components for proper composition with NextImage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import { | ||
| Container, Box, Text, CloseButton, Input, InputGroup, Button, AbsoluteCenter, VStack, HStack, Heading, | ||
| Link as ChakraLink, Center, SimpleGrid, GridItem, Stack, Card, Image as ChakraImage | ||
| Container, Box, Text, CloseButton, Input, InputGroup, AbsoluteCenter, VStack, HStack, Heading, | ||
| SimpleGrid | ||
| } from '@chakra-ui/react'; | ||
| import { useRef, useState } from "react" | ||
| import { poppins } from '../../components/ui/fonts'; | ||
| import checkDeviceSize from '../../components/ui/breakpoints'; | ||
| import { poppins } from '@/components/ui/fonts'; | ||
| import checkDeviceSize from '@/components/ui/breakpoints'; | ||
| import mockData from '@/app/search/mock.json' | ||
|
|
||
|
|
||
| import { | ||
| Combobox, | ||
| Portal, | ||
| useFilter, | ||
| useListCollection, | ||
| } from "@chakra-ui/react" |
Copilot
AI
Dec 29, 2025
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.
The Chakra UI imports are split across two separate import statements (lines 4-7 and lines 14-19), both importing from "@chakra-ui/react". These should be consolidated into a single import statement for better code organization and readability.
|
|
||
| <InputGroup endElement={endElement} _light={{ color: "white" }}> | ||
| <Input | ||
| list={searchlist.toString()} |
Copilot
AI
Dec 29, 2025
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.
The 'list' prop is being set to 'searchlist.toString()' which will convert the array to a string representation like "[object Object],[object Object],...". This is not a valid use of the HTML 'list' attribute. If you're trying to create a datalist, you need to provide the ID of a datalist element. Otherwise, this prop should be removed as the Combobox component above already handles the search suggestions.
| <Input | ||
| list={searchlist.toString()} | ||
| ref={inputRef} | ||
| placeholder="Email" |
Copilot
AI
Dec 29, 2025
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.
The placeholder text is "Email" but this appears to be a general search input, not an email field. The placeholder should be updated to reflect the actual purpose of this input field (e.g., "Search..." or similar).
| <InputGroup endElement={endElement}> | ||
| <InputGroup endElement={endElement} > | ||
| <Input | ||
| list={searchlist.toString()} |
Copilot
AI
Dec 29, 2025
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.
The 'list' prop is being set to 'searchlist.toString()' which will convert the array to a string representation like "[object Object],[object Object],...". This is not a valid use of the HTML 'list' attribute. If you're trying to create a datalist, you need to provide the ID of a datalist element. Otherwise, this prop should be removed.
| <Input | ||
| list={searchlist.toString()} | ||
| ref={inputRef} | ||
| placeholder="Email" |
Copilot
AI
Dec 29, 2025
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.
The placeholder text is "Email" but this appears to be a general search input, not an email field. The placeholder should be updated to reflect the actual purpose of this input field (e.g., "Search..." or similar).
|
|
||
| export default function Search() { | ||
| //Retrieve mock data from json file | ||
| const [searchlist, setSearchlist] = useState(mockData) |
Copilot
AI
Dec 29, 2025
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.
The state variable 'searchlist' is initialized but the setter 'setSearchlist' is never used in the component. Since the mock data is static, this should be a regular constant rather than state. If you need it to be state for future updates, consider removing the unused setter or using it appropriately.
| const [searchlist, setSearchlist] = useState(mockData) | |
| const searchlist = mockData |
| {collection.items.map((item) => ( | ||
| <Combobox.Item key={item.title} item={item}> |
Copilot
AI
Dec 29, 2025
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.
Using 'item.title' as the key for list items can cause issues if there are duplicate titles in the mock data. The key should be unique for each item. Consider adding a unique 'id' field to each item in the mock data and using that as the key instead.
| {collection.items.map((item) => ( | |
| <Combobox.Item key={item.title} item={item}> | |
| {collection.items.map((item, index) => ( | |
| <Combobox.Item key={`${item.title}-${index}`} item={item}> |
|
|
||
| <InputGroup endElement={endElement} _light={{ color: "white" }}> | ||
| <Input | ||
| list={searchlist.toString()} | ||
| ref={inputRef} | ||
| placeholder="Email" | ||
| value={value} | ||
| onChange={(e) => { | ||
| setValue(e.currentTarget.value) | ||
| }} | ||
| /> | ||
| </InputGroup> |
Copilot
AI
Dec 29, 2025
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.
There are two separate search input implementations in this component (Combobox on lines 85-110 and InputGroup on lines 112-122). They appear to serve the same purpose but are not synchronized, which can confuse users. Consider removing the redundant InputGroup or clarifying the distinct purposes of these two inputs.
| <InputGroup endElement={endElement} _light={{ color: "white" }}> | |
| <Input | |
| list={searchlist.toString()} | |
| ref={inputRef} | |
| placeholder="Email" | |
| value={value} | |
| onChange={(e) => { | |
| setValue(e.currentTarget.value) | |
| }} | |
| /> | |
| </InputGroup> |
|
|
||
|
|
||
| export default function Search() { | ||
| //Retrieve mock data from json file |
Copilot
AI
Dec 29, 2025
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.
The comment delimiter lacks proper spacing. It should be formatted as '// Retrieve mock data from json file' with a space after the double slashes for better readability.
| //Retrieve mock data from json file | |
| // Retrieve mock data from json file |
|
|
||
| import { FaRegObjectGroup as FaObjectGroup, FaRegListAlt as FaListAlt, FaRegNewspaper as FaNewspaper, FaRegKeyboard as FaKeyboard } from "react-icons/fa"; | ||
| import { MdBrightness4 as MdMoon, MdBrightness5 as MdSun } from 'react-icons/md'; | ||
| import { MdBrightness5 as MdSun } from 'react-icons/md'; |
Copilot
AI
Dec 29, 2025
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.
Unused import MdSun.
| import { MdBrightness5 as MdSun } from 'react-icons/md'; |
BorDevTech
left a comment
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.
Great work no bugs! 👍
No description provided.