From bf5eccb4ba9d468e8625a7f5e3a30c9f4b124fad Mon Sep 17 00:00:00 2001 From: Dalai Jotisalikorn Surenjargal Date: Thu, 13 Jul 2023 12:25:43 +0700 Subject: [PATCH] fix: remove selected baan --- src/pages/baan-choosing.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pages/baan-choosing.tsx b/src/pages/baan-choosing.tsx index 0024e3b..066d0f9 100644 --- a/src/pages/baan-choosing.tsx +++ b/src/pages/baan-choosing.tsx @@ -295,8 +295,15 @@ const BaanChoosing = () => { ); }); + const isAdded = (other: IBaan) => { + //Check if the baan is selected and will not visualize in Baan list + for (let i: number = 0; i < 3; i++) { + if (selectedBaan[i].id === other.id) return false; + } + return true; + }; const listBaan: ReactNode = baan //convert list of all Baans in RPKM to TSX - .filter((e) => e.name.includes(input)) //Filter when typing the search bar + .filter((e) => e.name.includes(input) && isAdded(e)) //Filter when typing the search bar .map((e: IBaan) => { return (