From 6dd85db35d6bae5033cb0cf9ecfc7307440667ce Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Fri, 7 Jun 2024 15:04:29 -0300 Subject: [PATCH] Fixed Gradient name to Profile Picture --- src/frontend/src/constants/constants.ts | 2 +- .../src/pages/ProfileSettingsPage/index.tsx | 6 ++-- .../profilePictureChooserComponent}/index.tsx | 4 +-- .../index.tsx | 32 +++++++++---------- .../SettingsPage/pages/GeneralPage/index.tsx | 14 ++++---- ...ient.tsx => use-patch-profile-picture.tsx} | 16 ++++++---- src/frontend/src/types/components/index.ts | 2 +- 7 files changed, 39 insertions(+), 37 deletions(-) rename src/frontend/src/{components/gradientChooserComponent => pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent}/index.tsx (76%) rename src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/{ProfileGradientForm => ProfilePictureForm}/index.tsx (63%) rename src/frontend/src/pages/SettingsPage/pages/hooks/{use-patch-gradient.tsx => use-patch-profile-picture.tsx} (63%) diff --git a/src/frontend/src/constants/constants.ts b/src/frontend/src/constants/constants.ts index d84989994..46e31ee55 100644 --- a/src/frontend/src/constants/constants.ts +++ b/src/frontend/src/constants/constants.ts @@ -589,7 +589,7 @@ export const CONTROL_INPUT_STATE = { export const CONTROL_PATCH_USER_STATE = { password: "", cnfPassword: "", - gradient: "", + profilePicture: "", apikey: "", }; diff --git a/src/frontend/src/pages/ProfileSettingsPage/index.tsx b/src/frontend/src/pages/ProfileSettingsPage/index.tsx index a7af7c86a..78e328623 100644 --- a/src/frontend/src/pages/ProfileSettingsPage/index.tsx +++ b/src/frontend/src/pages/ProfileSettingsPage/index.tsx @@ -2,7 +2,7 @@ import * as Form from "@radix-ui/react-form"; import { cloneDeep } from "lodash"; import { useContext, useEffect, useState } from "react"; import IconComponent from "../../components/genericIconComponent"; -import GradientChooserComponent from "../../components/gradientChooserComponent"; +import GradientChooserComponent from "../SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent"; import Header from "../../components/headerComponent"; import InputComponent from "../../components/inputComponent"; import { Button } from "../../components/ui/button"; @@ -24,11 +24,11 @@ import { import { gradients } from "../../utils/styleUtils"; export default function ProfileSettingsPage(): JSX.Element { const setCurrentFlowId = useFlowsManagerStore( - (state) => state.setCurrentFlowId + (state) => state.setCurrentFlowId, ); const [inputState, setInputState] = useState( - CONTROL_PATCH_USER_STATE + CONTROL_PATCH_USER_STATE, ); // set null id diff --git a/src/frontend/src/components/gradientChooserComponent/index.tsx b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent/index.tsx similarity index 76% rename from src/frontend/src/components/gradientChooserComponent/index.tsx rename to src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent/index.tsx index 3467aedb8..36db9d84c 100644 --- a/src/frontend/src/components/gradientChooserComponent/index.tsx +++ b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent/index.tsx @@ -1,6 +1,6 @@ -import { gradients } from "../../utils/styleUtils"; +import { gradients } from "../../../../../../../../utils/styleUtils"; -export default function GradientChooserComponent({ value, onChange }) { +export default function ProfilePictureChooserComponent({ value, onChange }) { return (
{gradients.map((gradient, idx) => ( diff --git a/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfileGradientForm/index.tsx b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/index.tsx similarity index 63% rename from src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfileGradientForm/index.tsx rename to src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/index.tsx index a92a00103..bdf0db328 100644 --- a/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfileGradientForm/index.tsx +++ b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/index.tsx @@ -1,5 +1,4 @@ import * as Form from "@radix-ui/react-form"; -import GradientChooserComponent from "../../../../../../components/gradientChooserComponent"; import { Button } from "../../../../../../components/ui/button"; import { Card, @@ -10,47 +9,48 @@ import { CardTitle, } from "../../../../../../components/ui/card"; import { gradients } from "../../../../../../utils/styleUtils"; +import ProfilePictureChooserComponent from "./components/profilePictureChooserComponent"; -type ProfileGradientFormComponentProps = { - gradient: string; +type ProfilePictureFormComponentProps = { + profilePicture: string; handleInput: (event: any) => void; - handlePatchGradient: (gradient: string) => void; + handlePatchProfilePicture: (gradient: string) => void; userData: any; }; -const ProfileGradientFormComponent = ({ - gradient, +const ProfilePictureFormComponent = ({ + profilePicture, handleInput, - handlePatchGradient, + handlePatchProfilePicture, userData, -}: ProfileGradientFormComponentProps) => { +}: ProfilePictureFormComponentProps) => { return ( <> { - handlePatchGradient(gradient); + handlePatchProfilePicture(profilePicture); event.preventDefault(); }} > - Profile Gradient + Profile Picture - Choose the gradient that appears as your profile picture. + Choose the image that appears as your profile picture.
- { - handleInput({ target: { name: "gradient", value } }); + handleInput({ target: { name: "profilePicture", value } }); }} />
@@ -65,4 +65,4 @@ const ProfileGradientFormComponent = ({ ); }; -export default ProfileGradientFormComponent; +export default ProfilePictureFormComponent; diff --git a/src/frontend/src/pages/SettingsPage/pages/GeneralPage/index.tsx b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/index.tsx index 718097152..a3958f605 100644 --- a/src/frontend/src/pages/SettingsPage/pages/GeneralPage/index.tsx +++ b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/index.tsx @@ -9,13 +9,13 @@ import { inputHandlerEventType, patchUserInputStateType, } from "../../../../types/components"; -import usePatchGradient from "../hooks/use-patch-gradient"; +import usePatchProfilePicture from "../hooks/use-patch-profile-picture"; import usePatchPassword from "../hooks/use-patch-password"; import useSaveKey from "../hooks/use-save-key"; import useScrollToElement from "../hooks/use-scroll-to-element"; import GeneralPageHeaderComponent from "./components/GeneralPageHeader"; import PasswordFormComponent from "./components/PasswordForm"; -import ProfileGradientFormComponent from "./components/ProfileGradientForm"; +import ProfilePictureFormComponent from "./components/ProfilePictureForm"; import StoreApiKeyFormComponent from "./components/StoreApiKeyForm"; export default function GeneralPage() { @@ -42,7 +42,7 @@ export default function GeneralPage() { const loadingApiKey = useStoreStore((state) => state.loadingApiKey); const setValidApiKey = useStoreStore((state) => state.updateValidApiKey); const setLoadingApiKey = useStoreStore((state) => state.updateLoadingApiKey); - const { password, cnfPassword, gradient, apikey } = inputState; + const { password, cnfPassword, profilePicture, apikey } = inputState; const { handlePatchPassword } = usePatchPassword( userData, @@ -50,7 +50,7 @@ export default function GeneralPage() { setErrorData, ); - const { handlePatchGradient } = usePatchGradient( + const { handlePatchProfilePicture } = usePatchProfilePicture( setSuccessData, setErrorData, userData, @@ -78,10 +78,10 @@ export default function GeneralPage() {
- diff --git a/src/frontend/src/pages/SettingsPage/pages/hooks/use-patch-gradient.tsx b/src/frontend/src/pages/SettingsPage/pages/hooks/use-patch-profile-picture.tsx similarity index 63% rename from src/frontend/src/pages/SettingsPage/pages/hooks/use-patch-gradient.tsx rename to src/frontend/src/pages/SettingsPage/pages/hooks/use-patch-profile-picture.tsx index ea61d4722..584300fdf 100644 --- a/src/frontend/src/pages/SettingsPage/pages/hooks/use-patch-gradient.tsx +++ b/src/frontend/src/pages/SettingsPage/pages/hooks/use-patch-profile-picture.tsx @@ -5,18 +5,20 @@ import { } from "../../../../constants/alerts_constants"; import { updateUser } from "../../../../controllers/API"; -const usePatchGradient = ( +const usePatchProfilePicture = ( setSuccessData, setErrorData, currentUserData, setUserData, ) => { - const handlePatchGradient = async (gradient) => { + const handlePatchProfilePicture = async (profile_picture) => { try { - if (gradient !== "") { - await updateUser(currentUserData.id, { profile_image: gradient }); + if (profile_picture !== "") { + await updateUser(currentUserData.id, { + profile_image: profile_picture, + }); let newUserData = cloneDeep(currentUserData); - newUserData.profile_image = gradient; + newUserData.profile_image = profile_picture; setUserData(newUserData); } setSuccessData({ title: SAVE_SUCCESS_ALERT }); @@ -30,8 +32,8 @@ const usePatchGradient = ( return { currentUserData, - handlePatchGradient, + handlePatchProfilePicture, }; }; -export default usePatchGradient; +export default usePatchProfilePicture; diff --git a/src/frontend/src/types/components/index.ts b/src/frontend/src/types/components/index.ts index ade4f7c13..32fd3e0bc 100644 --- a/src/frontend/src/types/components/index.ts +++ b/src/frontend/src/types/components/index.ts @@ -396,7 +396,7 @@ export type loginInputStateType = { export type patchUserInputStateType = { password: string; cnfPassword: string; - gradient: string; + profilePicture: string; apikey: string; };