diff --git a/frontend/pages/edit/profile.tsx b/frontend/pages/edit/profile.tsx index 4d0288a..447cbd2 100644 --- a/frontend/pages/edit/profile.tsx +++ b/frontend/pages/edit/profile.tsx @@ -26,13 +26,6 @@ export default function Index() { const router = useRouter(); const [state, setState] = useState(cloneDeep(user)); - const onChangeBio = useCallback((value: string, viewUpdate: any) => { - setState((s) => { - s!.bio = value; - return s; - }); - }, []); - const originalOrder = state?.fields ? state.fields.map((f, i) => { const field: EditField = { @@ -76,17 +69,17 @@ export default function Index() { }; useEffect(() => { - if (!user) { + if (!user || !state) { router.push("/"); } }, [user]); - if (!user) { + if (!user || !state) { return ; } const fieldsUpdated = !fieldsEqual(fields, originalOrder); - const isEdited = fieldsUpdated; + const isEdited = fieldsUpdated || state.bio !== user.bio; return (
@@ -97,8 +90,8 @@ export default function Index() { style={ButtonStyle.success} onClick={async () => { const user = await updateUser({ - displayName: state!.display_name, - bio: state!.bio, + displayName: state.display_name, + bio: state.bio, fields, }); @@ -117,14 +110,16 @@ export default function Index() {

Edit

{ + setState({ ...state, bio: val }); + }} extensions={[markdown({ base: markdownLanguage })]} />

Preview

- {state?.bio || ""} + {state.bio || ""}