Skip to content

Commit 6038b76

Browse files
committed
Enhance quote listing with search functionality and improve layout
- Added a search input to filter quotes in the ListQuote component. - Adjusted layout by adding margin to the main quote listing section. - Cleaned up code for better readability and consistency.
1 parent 695d299 commit 6038b76

3 files changed

Lines changed: 25 additions & 14 deletions

File tree

β€Žfrontend/src/App.tsxβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function App() {
7676

7777
return (
7878
<main>
79-
<div className="flex gap-4">
79+
<div className="flex gap-4 mb-4">
8080
<h3>List Quote</h3>
8181
<Button onClick={openAddDialog} > <PlusIcon /> Add Quote </Button>
8282
</div>

β€Žfrontend/src/feature/quote/list.quote.tsxβ€Ž

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,51 @@
1-
import { PenIcon, Trash } from "lucide-react"
1+
import { useState } from "react";
2+
import { PenIcon, SearchIcon, Trash } from "lucide-react"
3+
import { Input } from "@/components/ui/input";
24
import { Button } from "@/components/ui/button"
35
import type { Quote } from "@/model/quote.model"
6+
import { InputGroup, InputGroupInput, InputGroupAddon } from "@/components/ui/input-group";
47

58
interface Props {
69
loading: boolean
710
quotes: Quote[];
8-
onEdit:(quote: Quote) => void
9-
onDelete:(quote: Quote) => void
11+
onEdit: (quote: Quote) => void
12+
onDelete: (quote: Quote) => void
1013
}
1114

1215
export function ListQuote(props: Props) {
13-
let { loading, quotes, onEdit, onDelete } = props
16+
const { loading, quotes, onEdit, onDelete } = props
17+
const [inputValue, setInputValue] = useState("")
1418

1519
return (
1620
<div>
21+
22+
<InputGroup className="mb-4">
23+
<InputGroupInput placeholder="Search..." />
24+
<InputGroupAddon>
25+
<SearchIcon />
26+
</InputGroupAddon>
27+
</InputGroup>
1728
{
1829
loading && <p>Loading quotes...</p>
1930
}
2031
{
21-
( !loading &&quotes?.length <= 0 ) && (
22-
<p className="text-center text-gray-500">No quotes available.</p>
32+
(!loading && quotes?.length <= 0) && (
33+
<p className="text-center text-gray-500">No quotes available.</p>
2334
)
2435
}
2536
{
2637
(quotes && quotes?.length > 0) && (
2738
<div className="flex flex-col gap-4">
2839
{quotes.map((q) => {
2940
return (
30-
<div key={q.id + q.text.slice(0, 5)}
31-
className=" px-4 py-2 flex items-center justify-between border border-grey-200">
41+
<div key={q.id + q.text.slice(0, 5)}
42+
className=" px-4 py-2 flex items-center justify-between border border-grey-200">
3243
<p>{q.text}</p>
33-
<Button onClick={()=>onEdit(q)}>
34-
<PenIcon/>
44+
<Button onClick={() => onEdit(q)}>
45+
<PenIcon />
3546
</Button>
36-
<Button onClick={()=>onDelete(q)}>
37-
<Trash/>
47+
<Button onClick={() => onDelete(q)}>
48+
<Trash />
3849
</Button>
3950
</div>
4051
)

β€Žfrontend/vite.config.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import tailwindcss from '@tailwindcss/vite'
55

66
// https://vite.dev/config/
77
export default defineConfig({
8-
base: "/Quotes-Keeper-3/", // πŸ‘ˆ EXACT repo name
8+
base: "/Quotes-Keeper-3/", // πŸ‘ˆ EXACT repo name (for github pages)
99
plugins: [
1010
react(
1111
{

0 commit comments

Comments
Β (0)