From d2d7aaaf79613ad362363a4dcad271d6d22933d2 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Fri, 7 Jun 2024 15:08:16 -0300 Subject: [PATCH] Added Get Profile Pictures hook --- src/frontend/src/constants/alerts_constants.tsx | 2 ++ .../hooks/use-get-profile-pictures.ts | 17 +++++++++++++++++ .../profilePictureChooserComponent/index.tsx | 5 +++++ 3 files changed, 24 insertions(+) create mode 100644 src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent/hooks/use-get-profile-pictures.ts diff --git a/src/frontend/src/constants/alerts_constants.tsx b/src/frontend/src/constants/alerts_constants.tsx index ebc7543d5..c6dfa035b 100644 --- a/src/frontend/src/constants/alerts_constants.tsx +++ b/src/frontend/src/constants/alerts_constants.tsx @@ -31,6 +31,8 @@ export const INVALID_SELECTION_ERROR_ALERT = "Invalid selection"; export const EDIT_PASSWORD_ERROR_ALERT = "Error changing password"; export const EDIT_PASSWORD_ALERT_LIST = "Passwords do not match"; export const SAVE_ERROR_ALERT = "Error saving changes"; +export const PROFILE_PICTURES_GET_ERROR_ALERT = + "Error retrieving profile pictures"; export const SIGNUP_ERROR_ALERT = "Error signing up"; export const APIKEY_ERROR_ALERT = "API Key Error"; export const NOAPI_ERROR_ALERT = diff --git a/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent/hooks/use-get-profile-pictures.ts b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent/hooks/use-get-profile-pictures.ts new file mode 100644 index 000000000..fad78c4e1 --- /dev/null +++ b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent/hooks/use-get-profile-pictures.ts @@ -0,0 +1,17 @@ +import { PROFILE_PICTURES_GET_ERROR_ALERT } from "../../../../../../../../../constants/alerts_constants"; + +const useGetProfilePictures = (setErrorData) => { + const handleGetProfilePictures = async () => { + try { + } catch (error) { + setErrorData({ + title: PROFILE_PICTURES_GET_ERROR_ALERT, + list: [(error as any)?.response?.data?.detail], + }); + } + }; + + return handleGetProfilePictures; +}; + +export default useGetProfilePictures; diff --git a/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent/index.tsx b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent/index.tsx index 36db9d84c..562829265 100644 --- a/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent/index.tsx +++ b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent/index.tsx @@ -1,6 +1,11 @@ +import useAlertStore from "../../../../../../../../stores/alertStore"; import { gradients } from "../../../../../../../../utils/styleUtils"; +import useGetProfilePictures from "./hooks/use-get-profile-pictures"; export default function ProfilePictureChooserComponent({ value, onChange }) { + const setErrorData = useAlertStore((state) => state.setErrorData); + const getProfilePictures = useGetProfilePictures({ setErrorData }); + return (
{gradients.map((gradient, idx) => (