From 43cc39fd62e0da65b6da7a870e1bc6c136eee58d Mon Sep 17 00:00:00 2001 From: vkuchenik Date: Tue, 1 Sep 2026 09:47:54 -0700 Subject: [PATCH] =?UTF-8?q?add=20=E2=80=94=20settings=20page=20has=20basic?= =?UTF-8?q?=20ui,=20changes=20to=20preferences=20currently=20do=20not=20ta?= =?UTF-8?q?ke=20effect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/App.jsx | 3 + client/src/pages/auth/Settings.jsx | 126 +++++++++++++++++++++++++++++ client/src/store/authStore.js | 17 +++- 3 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 client/src/pages/auth/Settings.jsx diff --git a/client/src/App.jsx b/client/src/App.jsx index 95e89c7..e5d2afd 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -18,6 +18,7 @@ import Volcano from "@/pages/volcano/Volcano.jsx"; import GlobalMap from "./pages/maps/GlobalMap.jsx"; import Admin from "./pages/admin/Admin.jsx"; import MyDashboard from "./pages/home/tabs/MyDashboard.jsx"; +import Settings from "./pages/auth/Settings.jsx"; function AppFoundation() { const recipe = useRecipe({ key: "dashboard" }); @@ -81,6 +82,8 @@ function App() { } /> + } /> + } /> } /> } /> diff --git a/client/src/pages/auth/Settings.jsx b/client/src/pages/auth/Settings.jsx new file mode 100644 index 0000000..bd28e4c --- /dev/null +++ b/client/src/pages/auth/Settings.jsx @@ -0,0 +1,126 @@ +import { Flex, Text, Input, Field, Button, Separator, NativeSelect, Image } from '@chakra-ui/react'; +import useAuthStore from "../../store/authStore.js"; +import { useForm } from "react-hook-form"; +import { useState } from "react"; + +export default function Settings() { + const { user } = useAuthStore(); + const { register, handleSubmit, errors } = useForm(); + const [value, setValue] = useState(undefined); + const updateProfile = useAuthStore((state) => state.updateProfile); + + const onSubmit = (data, event) => { + // TODO: check for identical usernames + event.preventDefault(); + console.log(data); + if (data.username && data.username.length !== "") updateProfile(data); + } + + const ivansRequest = () => { + console.log(user.username, "requested ivans permissions"); + // TODO: log users request in database here which will then display request in web-admin page + } + + return ( +
+ + + {/* CONTENT */} + + Personal Information + + {/* avatar */} + + + + + Name + {user.firstName || "first name"}, {user.lastName || "last name"} + + + + + + {/* personal info */} + + + Username + + + + + Email + + + + + + + Descipline + + + + + + + + + + + + {/* filler so that discipline dropdown sizes correctly */} + + + + + + {/* permissions */} + + Permissions + + Request access to IVANS + + + + Request access to Remote Sensing + + + + + + + {/* themes */} + + Theme + + Appearance + + setValue(e.currentTarget.value)} + > + + + + + + + + + + {/* SAVE-ALL BUTTON */} + {/* TODO: grey out button until changes are detected */} + + +
+ ); +} diff --git a/client/src/store/authStore.js b/client/src/store/authStore.js index abafe24..9c8ebde 100644 --- a/client/src/store/authStore.js +++ b/client/src/store/authStore.js @@ -86,7 +86,22 @@ const useAuthStore = create((set) => ({ } catch (error) { console.error("Failed to save layout to database", error); } - } + }, + + // updateProfile: async (newProfile) => { + // try { + // set((state) => ({ + // user: { + // ...state.user, + // username: newProfile.username, + // } + // })); + // + // await api.post('profile/update/', { profile: newProfile }); + // } catch (error) { + // console.error("Failed to update profile", error); + // } + // } })); export default useAuthStore; \ No newline at end of file