"use client"; import { ClaimResult } from "@/app/api/claims"; import React, { useCallback, useMemo, useState } from "react"; import SearchBox, { Criterion } from "../SearchBox/index"; import { useTranslation } from "react-i18next"; import SearchResults, { Column } from "../SearchResults/index"; import EditNote from "@mui/icons-material/EditNote"; interface Props { claims: ClaimResult[]; } type SearchQuery = Partial>; type SearchParamNames = keyof SearchQuery; const ClaimSearch: React.FC = ({ claims }) => { const { t } = useTranslation("claims"); // If claim searching is done on the server-side, then no need for this. const [filteredClaims, setFilteredClaims] = useState(claims); const searchCriteria: Criterion[] = useMemo( () => [ { label: t("Creation Date"), paramName: "created", type: "dateRange" }, { label: t("Related Project Name"), paramName: "name", type: "text" }, { label: t("Cost (HKD)"), paramName: "cost", type: "text", }, { label: t("Expense Type"), paramName: "type", type: "select", options: ["Expense", "Petty Cash"], }, { label: t("Status"), paramName: "status", type: "select", options: [ "Not Submitted", "Waiting for Approval", "Approved", "Rejected", ], }, { label: t("Remarks"), paramName: "remarks", type: "text", }, ], [t], ); const onClaimClick = useCallback((claim: ClaimResult) => { console.log(claim); }, []); const columns = useMemo[]>( () => [ // { // name: "action", // label: t("Actions"), // onClick: onClaimClick, // buttonIcon: , // }, { name: "created", label: t("Creation Date") }, { name: "name", label: t("Related Project Name") }, { name: "cost", label: t("Cost (HKD)") }, { name: "type", label: t("Expense Type") }, { name: "status", label: t("Status") }, { name: "remarks", label: t("Remarks") }, ], [t, onClaimClick], ); return ( <> { console.log(query); }} /> items={filteredClaims} columns={columns} /> ); }; export default ClaimSearch;