|
| 1 | +import type { ChangeEvent, JSX } from 'react'; |
| 2 | +import { useCallback } from 'react'; |
| 3 | + |
| 4 | +import { useIntl } from 'react-intl'; |
| 5 | + |
| 6 | +import { useNavigate, useSearch, Link } from '@tanstack/react-router'; |
| 7 | + |
| 8 | +import HardwareListingPage from '@/pages/HardwareNew/HardwareListingPage'; |
| 9 | + |
| 10 | +import DebounceInput from '@/components/DebounceInput/DebounceInput'; |
| 11 | +import { MemoizedListingOGTags } from '@/components/OpenGraphTags/ListingOGTags'; |
| 12 | + |
| 13 | +const Hardware = (): JSX.Element => { |
| 14 | + const { hardwareSearch } = useSearch({ |
| 15 | + from: '/_main/hardware-new', |
| 16 | + }); |
| 17 | + |
| 18 | + const navigate = useNavigate({ from: '/hardware-new' }); |
| 19 | + |
| 20 | + const onInputSearchTextChange = useCallback( |
| 21 | + (e: ChangeEvent<HTMLInputElement>) => { |
| 22 | + navigate({ |
| 23 | + from: '/hardware-new', |
| 24 | + search: previousSearch => ({ |
| 25 | + ...previousSearch, |
| 26 | + hardwareSearch: e.target.value, |
| 27 | + }), |
| 28 | + state: s => s, |
| 29 | + }); |
| 30 | + }, |
| 31 | + [navigate], |
| 32 | + ); |
| 33 | + |
| 34 | + const { formatMessage } = useIntl(); |
| 35 | + |
| 36 | + return ( |
| 37 | + <> |
| 38 | + <MemoizedListingOGTags monitor="/hardware-new" search={hardwareSearch} /> |
| 39 | + <div className="fixed top-0 z-10 mx-[380px] flex w-full pt-5 pr-12 pl-6"> |
| 40 | + <div className="flex w-2/3 items-center px-6"> |
| 41 | + <DebounceInput |
| 42 | + debouncedSideEffect={onInputSearchTextChange} |
| 43 | + className="w-2/3" |
| 44 | + type="text" |
| 45 | + startingValue={hardwareSearch} |
| 46 | + placeholder={formatMessage({ |
| 47 | + id: 'hardware.searchPlaceholder', |
| 48 | + })} |
| 49 | + /> |
| 50 | + </div> |
| 51 | + </div> |
| 52 | + <div className="rounded-md bg-green-100 p-3 text-sm text-green-800 dark:bg-green-900 dark:text-green-300"> |
| 53 | + This is the new, optimized version of the hardware listing. If you find |
| 54 | + any bugs, please report to{' '} |
| 55 | + <a |
| 56 | + href="https://github.com/kernelci/dashboard/issues" |
| 57 | + target="_blank" |
| 58 | + rel="noreferrer" |
| 59 | + className="underline" |
| 60 | + > |
| 61 | + GitHub Issues |
| 62 | + </a>{' '} |
| 63 | + and you can still access the old version{' '} |
| 64 | + <Link to="/hardware" className="underline"> |
| 65 | + here |
| 66 | + </Link> |
| 67 | + . Please note that some historical data might be missing, but it should |
| 68 | + be updated with recent data. |
| 69 | + </div> |
| 70 | + <div className="bg-light-gray w-full py-10"> |
| 71 | + <HardwareListingPage inputFilter={hardwareSearch ?? ''} /> |
| 72 | + </div> |
| 73 | + </> |
| 74 | + ); |
| 75 | +}; |
| 76 | + |
| 77 | +export default Hardware; |
0 commit comments