From 32d7d335998370537cbc9d25f52b8dfd3bd59fe1 Mon Sep 17 00:00:00 2001 From: cjeongmin Date: Thu, 30 May 2024 23:10:16 +0900 Subject: [PATCH] fix: Fix the error where feature were not applied to the user card --- src/app/pages/setting-page.tsx | 28 +++++++++++++++++++++++++++ src/components/card/OptionSection.tsx | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/app/pages/setting-page.tsx b/src/app/pages/setting-page.tsx index 3725d83..ece93a2 100644 --- a/src/app/pages/setting-page.tsx +++ b/src/app/pages/setting-page.tsx @@ -320,6 +320,34 @@ export function SettingPage({ cardId }: { cardId: number }) { history.back(); }; + useEffect(() => { + if (card.data == null) return; + + const { smoking, mateAge, roomSharingOption, options } = + card.data.data.myFeatures; + + const temp = JSON.parse(options) as string[]; + + setFeatures({ + smoking, + mateAge, + roomSharingOption, + options: + temp == null + ? new Set() + : temp.reduce>((prev, curr) => { + try { + if (Array.isArray(JSON.parse(curr))) { + setBudget(curr.slice(1, -1)); + } + } catch { + prev.add(curr); + } + return prev; + }, new Set()), + }); + }, [card.data]); + useEffect(() => { const originalPush = router.push.bind(router); const newPush = ( diff --git a/src/components/card/OptionSection.tsx b/src/components/card/OptionSection.tsx index ad0c2f7..136a929 100644 --- a/src/components/card/OptionSection.tsx +++ b/src/components/card/OptionSection.tsx @@ -125,7 +125,7 @@ const styles = { `, value: styled.div` display: flex; - width: 6.8rem; + width: 7rem; padding: 0.5rem 1.5rem; justify-content: center; align-items: center;