diff --git a/src/front/Components/DesignSystem/SearchBar/index.tsx b/src/front/Components/DesignSystem/SearchBar/index.tsx index 66f8f693..9d7d8090 100644 --- a/src/front/Components/DesignSystem/SearchBar/index.tsx +++ b/src/front/Components/DesignSystem/SearchBar/index.tsx @@ -1,9 +1,10 @@ -import React from "react"; -import classes from "./classes.module.scss"; import LoopIcon from "@Assets/Icons/loop.svg"; -import Image from "next/image"; -import Typography, { ITypo } from "../Typography"; import { IDashBoardFolder } from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; +import Image from "next/image"; +import React from "react"; + +import Typography, { ITypo } from "../Typography"; +import classes from "./classes.module.scss"; type IProps = { folders: IDashBoardFolder[]; @@ -53,9 +54,20 @@ export default class SearchBar extends React.Component { } private filterFolders(event: React.ChangeEvent) { - const filteredFolders: IDashBoardFolder[] = this.props.folders.filter((folder) => - folder.folder_number.includes(event.target.value), - ); + const filteredFolders: IDashBoardFolder[] = this.props.folders.filter((folder) => { + const name = folder.name.toLowerCase(); + const number = folder.folder_number.toLowerCase(); + const value = event.target.value.toLowerCase(); + + if (folder.office_folder_has_customers) { + const customerNames = folder.office_folder_has_customers.map((customer) => { + return `${customer.customer.contact.first_name.toLowerCase()} ${customer.customer.contact.last_name.toLowerCase()}`; + }).join(", "); + return name.includes(value) || number.includes(value) || customerNames.includes(value); + } + + return name.includes(value) || number.includes(value); + }); return filteredFolders; } }