|
| 1 | +import { Suspense } from 'react'; |
| 2 | + |
| 3 | +import Loading from '~/components/loading'; |
| 4 | +import ImageHeader from '~/components/image-header'; |
| 5 | +import { |
| 6 | + Table, |
| 7 | + TableBody, |
| 8 | + TableCell, |
| 9 | + TableHead, |
| 10 | + TableHeader, |
| 11 | + TableRow, |
| 12 | +} from '~/components/ui'; |
| 13 | +import { PaginationWithLogic } from '~/components/pagination/pagination'; |
| 14 | +import { getTranslations } from '~/i18n/translations'; |
| 15 | + |
| 16 | +export default async function PatentsAndTechnology({ |
| 17 | + params: { locale }, |
| 18 | + searchParams, |
| 19 | +}: { |
| 20 | + params: { locale: string }; |
| 21 | + searchParams?: { page?: string }; |
| 22 | +}) { |
| 23 | + const currentPage = Number(searchParams?.page ?? 1); |
| 24 | + |
| 25 | + const text = (await getTranslations(locale)).PatentsAndTechnologies; |
| 26 | + |
| 27 | + // Static patent data |
| 28 | + const staticPatents = [ |
| 29 | + { |
| 30 | + applicationNumber: '2269/DEL/2012', |
| 31 | + patentNumber: '320045', |
| 32 | + title: 'Intelligent induction hardening device and method thereof', |
| 33 | + inventors: [ |
| 34 | + { |
| 35 | + facultyId: 'jitender_kumar_chhabra_1', |
| 36 | + name: 'Jitender Kumar Chhabra', |
| 37 | + }, |
| 38 | + ], |
| 39 | + }, |
| 40 | + { |
| 41 | + applicationNumber: '2269/DEL/2012', |
| 42 | + patentNumber: '320045', |
| 43 | + title: |
| 44 | + 'Method of preventing radioactive gas to diffuse indoor environment by forming concrete with shielding effect', |
| 45 | + inventors: [ |
| 46 | + { |
| 47 | + facultyId: 'jitender_kumar_chhabra_2', |
| 48 | + name: 'Jitender Kumar Chhabra', |
| 49 | + }, |
| 50 | + ], |
| 51 | + }, |
| 52 | + { |
| 53 | + applicationNumber: '2269/DEL/2012', |
| 54 | + patentNumber: '320045', |
| 55 | + title: 'System for extracting water from atmospheric air', |
| 56 | + inventors: [ |
| 57 | + { |
| 58 | + facultyId: 'jitender_kumar_chhabra_3', |
| 59 | + name: 'Jitender Kumar Chhabra', |
| 60 | + }, |
| 61 | + ], |
| 62 | + }, |
| 63 | + { |
| 64 | + applicationNumber: '2269/DEL/2012', |
| 65 | + patentNumber: '320045', |
| 66 | + title: 'System for extracting water from atmospheric air', |
| 67 | + inventors: [ |
| 68 | + { |
| 69 | + facultyId: 'jitender_kumar_chhabra_4', |
| 70 | + name: 'Jitender Kumar Chhabra', |
| 71 | + }, |
| 72 | + ], |
| 73 | + }, |
| 74 | + { |
| 75 | + applicationNumber: '3001/DEL/2013', |
| 76 | + patentNumber: '320046', |
| 77 | + title: 'Advanced solar energy harvesting system', |
| 78 | + inventors: [ |
| 79 | + { |
| 80 | + facultyId: 'jitender_kumar_chhabra_5', |
| 81 | + name: 'Jitender Kumar Chhabra', |
| 82 | + }, |
| 83 | + ], |
| 84 | + }, |
| 85 | + { |
| 86 | + applicationNumber: '3002/DEL/2013', |
| 87 | + patentNumber: '320047', |
| 88 | + title: 'Automated waste management and recycling apparatus', |
| 89 | + inventors: [ |
| 90 | + { |
| 91 | + facultyId: 'jitender_kumar_chhabra_6', |
| 92 | + name: 'Jitender Kumar Chhabra', |
| 93 | + }, |
| 94 | + ], |
| 95 | + }, |
| 96 | + ]; |
| 97 | + |
| 98 | + // Get the total count for pagination |
| 99 | + const getPatentCount = async () => { |
| 100 | + const count = staticPatents.length; // Replace with your actual DB call |
| 101 | + return [{ count }]; |
| 102 | + }; |
| 103 | + |
| 104 | + return ( |
| 105 | + <> |
| 106 | + <ImageHeader |
| 107 | + title={text.title} |
| 108 | + src="research/patents-and-technologies/banner.jpg" |
| 109 | + /> |
| 110 | + <section className="container p-8"> |
| 111 | + <div className="max-h-96 w-full overflow-x-auto"> |
| 112 | + <Table scrollAreaClassName="h-[23rem] min-w-[500px]"> |
| 113 | + <TableHeader> |
| 114 | + <TableRow> |
| 115 | + {[ |
| 116 | + text.number, |
| 117 | + text.applicationNumber, |
| 118 | + text.patentNumber, |
| 119 | + text.techTitle, |
| 120 | + text.inventor, |
| 121 | + ].map((headerText, index) => ( |
| 122 | + <TableHead key={index}>{headerText}</TableHead> |
| 123 | + ))} |
| 124 | + </TableRow> |
| 125 | + </TableHeader> |
| 126 | + <TableBody> |
| 127 | + <Suspense |
| 128 | + fallback={ |
| 129 | + <TableRow> |
| 130 | + <TableCell colSpan={5}> |
| 131 | + <Loading /> |
| 132 | + </TableCell> |
| 133 | + </TableRow> |
| 134 | + } |
| 135 | + > |
| 136 | + <PatentTable |
| 137 | + tableData={staticPatents} |
| 138 | + currentPage={currentPage} |
| 139 | + itemsPerPage={10} |
| 140 | + /> |
| 141 | + </Suspense> |
| 142 | + </TableBody> |
| 143 | + </Table> |
| 144 | + </div> |
| 145 | + |
| 146 | + <div className="mt-6"> |
| 147 | + <PaginationWithLogic |
| 148 | + currentPage={currentPage} |
| 149 | + query={getPatentCount()} |
| 150 | + /> |
| 151 | + </div> |
| 152 | + </section> |
| 153 | + </> |
| 154 | + ); |
| 155 | +} |
| 156 | + |
| 157 | +const PatentTable = ({ |
| 158 | + tableData, |
| 159 | + currentPage, |
| 160 | + itemsPerPage = 10, |
| 161 | +}: { |
| 162 | + tableData: { |
| 163 | + applicationNumber: string; |
| 164 | + patentNumber: string; |
| 165 | + title: string; |
| 166 | + inventors: { |
| 167 | + facultyId: string; |
| 168 | + name: string; |
| 169 | + }[]; |
| 170 | + }[]; |
| 171 | + currentPage: number; |
| 172 | + itemsPerPage?: number; |
| 173 | +}) => { |
| 174 | + const startIndex = (currentPage - 1) * itemsPerPage; |
| 175 | + const visibleData = tableData.slice(startIndex, startIndex + itemsPerPage); |
| 176 | + |
| 177 | + return ( |
| 178 | + <> |
| 179 | + {visibleData.map((item, index) => { |
| 180 | + const cellData = [ |
| 181 | + startIndex + index + 1, |
| 182 | + item.applicationNumber, |
| 183 | + item.patentNumber, |
| 184 | + item.title, |
| 185 | + item.inventors.map((inventor) => inventor.name).join(', '), |
| 186 | + ]; |
| 187 | + |
| 188 | + return ( |
| 189 | + <TableRow |
| 190 | + key={index} |
| 191 | + className="text-neutral-700 hover:bg-neutral-50" |
| 192 | + > |
| 193 | + {cellData.map((cellContent, cellIndex) => ( |
| 194 | + <TableCell key={cellIndex}>{cellContent}</TableCell> |
| 195 | + ))} |
| 196 | + </TableRow> |
| 197 | + ); |
| 198 | + })} |
| 199 | + </> |
| 200 | + ); |
| 201 | +}; |
0 commit comments