Skip to content

Commit

Permalink
fix: Fix the error where feature were not applied to the user card
Browse files Browse the repository at this point in the history
  • Loading branch information
cjeongmin committed May 30, 2024
1 parent 3475e03 commit 32d7d33
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/app/pages/setting-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Set<string>>((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 = (
Expand Down
2 changes: 1 addition & 1 deletion src/components/card/OptionSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 32d7d33

Please sign in to comment.