1- //in this we show lost and found items, with a toggle to switch between lost and found items, and a floating button to add new items.
2- // only implement lost not found items temperoilaily
31'use client' ;
42import { useState } from "react" ;
53import Link from "next/link" ;
6- import { ArrowLeftIcon , Filter } from "lucide-react" ;
4+ import { ArrowLeftIcon , Filter } from "lucide-react" ;
75import WaveDesign from "./wave/wave_design" ;
86import { Add , Trash , Edit } from "iconsax-react" ;
97
10- // Define the type for an item
8+ // Define Item type
119type Item = {
1210 id : number ;
1311 name : string ;
1412 description : string ;
1513 lastSeenPlace : string ;
1614 contactInfo : string ;
17- status : "lost" | "found" ;
15+ status : "lost" | "found" ; // kept for potential future use
1816} ;
1917
2018export default function LostFound ( ) {
21- const [ status , setStatus ] = useState < "lost" | "found" > ( "lost" ) ;
19+ // Only show lost items, no need for status state
2220 const [ items , setItems ] = useState < Item [ ] > ( [
23- {
24- id : 1 ,
25- name : "Watch" ,
26- description : "Lorem ipsum dolor sit amet, consectetur adipiscing elit." ,
27- lastSeenPlace : "College Ground" ,
28- contactInfo : "contact@example.com" ,
29- status : "lost" ,
30- } ,
31- {
32- id : 2 ,
33- name : "Water Bottle" ,
34- description : "Lorem ipsum dolor sit amet, consectetur adipiscing elit." ,
35- lastSeenPlace : "Library" ,
36- contactInfo : "contact@example.com" ,
37- status : "lost" ,
38- } ,
21+ { id : 1 , name : "Watch" , description : "Lorem ipsum…" , lastSeenPlace : "College Ground" , contactInfo : "contact@example.com" , status : "lost" } ,
22+ { id : 2 , name : "Water Bottle" , description : "Lorem ipsum…" , lastSeenPlace : "Library" , contactInfo : "contact@example.com" , status : "lost" } ,
3923 ] ) ;
4024
41- // Toggle item status between "lost" and "found"
42- const toggleItemStatus = ( id : number ) => {
43- setItems ( ( prevItems ) =>
44- prevItems . map ( ( item ) =>
45- item . id === id
46- ? { ...item , status : item . status === "lost" ? "found" : "lost" }
47- : item
48- )
49- ) ;
50- } ;
51-
52- // Filter items based on the selected status
53- const filteredItems = items . filter ( ( item ) => item . status === status ) ;
25+ // Functionality for editing, deleting, etc.
26+ const deleteItem = ( id : number ) =>
27+ setItems ( prev => prev . filter ( item => item . id !== id ) ) ;
5428
5529 return (
5630 < div className = "p-4 max-w mx-auto relative" >
31+ { /* Header */ }
5732 < div className = "flex relative justify-between h-[100px] items-center mb-2" >
5833 < button className = "absolute top-0 left-0 border border-gray-400 rounded-full p-2" >
5934 < ArrowLeftIcon className = "w-5 h-5" />
@@ -65,34 +40,30 @@ export default function LostFound() {
6540 </ button >
6641 </ div >
6742
68- { /* List of Items */ }
43+ { /* Lost Items Grid */ }
6944 < div className = "grid grid-cols-1 md:grid-cols-3 md:space-x-[20px]" >
70- { filteredItems . map ( ( item ) => (
71- < div key = { item . id } className = "mb-4 border border-[1px] border-black rounded-xl overflow-hidden shadow-sm" >
72- < div className = "w-full h-32 bg-gray-300" > </ div >
45+ { items . map ( item => (
46+ < div key = { item . id } className = "mb-4 border rounded-xl overflow-hidden shadow-sm" >
47+ < div className = "w-full h-32 bg-gray-300" />
7348 < div className = "p-3" >
7449 < h2 className = "text-2xl font-bold" > { item . name } </ h2 >
75- < p className = "text-sm text-gray-400" >
76- Last Seen Place: { item . lastSeenPlace }
77- </ p >
50+ < p className = "text-sm text-gray-400" > Last Seen: { item . lastSeenPlace } </ p >
7851 < p className = "text-sm text-black/[0.7] mt-1" > { item . description } </ p >
79- < p className = "text-sm text-black/[0.7] mt-1" >
80- Contact: { item . contactInfo }
81- </ p >
52+ < p className = "text-sm text-black/[0.7] mt-1" > Contact: { item . contactInfo } </ p >
8253 < div className = "relative flex gap-2 mt-3" >
83- < button className = "text-black underline font-semibold" > Report</ button >
84- < button className = "absolute right-10 text-gray-600" > < Edit size = { 25 } color = "#000000" /> </ button >
85- < button className = "absolute right-0 text-gray-600" > < Trash size = { 25 } color = "#000000" /> </ button >
54+ < button onClick = { ( ) => { /* Report logic */ } } className = "text-black underline font-semibold" > Report</ button >
55+ < button onClick = { ( ) => { /* Edit logic */ } } className = "absolute right-10 text-gray-600" > < Edit size = { 25 } /> </ button >
56+ < button onClick = { ( ) => deleteItem ( item . id ) } className = "absolute right-0 text-gray-600" > < Trash size = { 25 } /> </ button >
8657 </ div >
8758 </ div >
8859 </ div >
8960 ) ) }
9061 </ div >
9162
92- { /* Floating "+" Button */ }
93- < Link href = "/lost/add" className = "bg-red-600" >
94- < button className = "fixed bottom-6 z-10 right-7 bottom-14 mb-[45px] bg-blue-200 border-[1px] border-black text-black w-12 h-12 rounded-[12px] flex items-center justify-center shadow-lg hover:bg-blue-400 transition-colors" >
95- < Add size = { 40 } color = "#000000" />
63+ { /* Floating Add Button */ }
64+ < Link href = "/lost/add" >
65+ < button className = "fixed bottom-6 right-7 bg-blue-200 border border-black text-black w-12 h-12 rounded-[12px] flex items-center justify-center shadow-lg hover:bg-blue-400 transition-colors" >
66+ < Add size = { 40 } />
9667 </ button >
9768 </ Link >
9869 </ div >
0 commit comments