Fixed Gradient name to Profile Picture
This commit is contained in:
parent
c5302d75db
commit
6dd85db35d
7 changed files with 39 additions and 37 deletions
|
|
@ -589,7 +589,7 @@ export const CONTROL_INPUT_STATE = {
|
||||||
export const CONTROL_PATCH_USER_STATE = {
|
export const CONTROL_PATCH_USER_STATE = {
|
||||||
password: "",
|
password: "",
|
||||||
cnfPassword: "",
|
cnfPassword: "",
|
||||||
gradient: "",
|
profilePicture: "",
|
||||||
apikey: "",
|
apikey: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import * as Form from "@radix-ui/react-form";
|
||||||
import { cloneDeep } from "lodash";
|
import { cloneDeep } from "lodash";
|
||||||
import { useContext, useEffect, useState } from "react";
|
import { useContext, useEffect, useState } from "react";
|
||||||
import IconComponent from "../../components/genericIconComponent";
|
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 Header from "../../components/headerComponent";
|
||||||
import InputComponent from "../../components/inputComponent";
|
import InputComponent from "../../components/inputComponent";
|
||||||
import { Button } from "../../components/ui/button";
|
import { Button } from "../../components/ui/button";
|
||||||
|
|
@ -24,11 +24,11 @@ import {
|
||||||
import { gradients } from "../../utils/styleUtils";
|
import { gradients } from "../../utils/styleUtils";
|
||||||
export default function ProfileSettingsPage(): JSX.Element {
|
export default function ProfileSettingsPage(): JSX.Element {
|
||||||
const setCurrentFlowId = useFlowsManagerStore(
|
const setCurrentFlowId = useFlowsManagerStore(
|
||||||
(state) => state.setCurrentFlowId
|
(state) => state.setCurrentFlowId,
|
||||||
);
|
);
|
||||||
|
|
||||||
const [inputState, setInputState] = useState<patchUserInputStateType>(
|
const [inputState, setInputState] = useState<patchUserInputStateType>(
|
||||||
CONTROL_PATCH_USER_STATE
|
CONTROL_PATCH_USER_STATE,
|
||||||
);
|
);
|
||||||
|
|
||||||
// set null id
|
// set null id
|
||||||
|
|
|
||||||
|
|
@ -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 (
|
return (
|
||||||
<div className="flex flex-wrap items-center justify-start gap-2">
|
<div className="flex flex-wrap items-center justify-start gap-2">
|
||||||
{gradients.map((gradient, idx) => (
|
{gradients.map((gradient, idx) => (
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import * as Form from "@radix-ui/react-form";
|
import * as Form from "@radix-ui/react-form";
|
||||||
import GradientChooserComponent from "../../../../../../components/gradientChooserComponent";
|
|
||||||
import { Button } from "../../../../../../components/ui/button";
|
import { Button } from "../../../../../../components/ui/button";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
|
|
@ -10,47 +9,48 @@ import {
|
||||||
CardTitle,
|
CardTitle,
|
||||||
} from "../../../../../../components/ui/card";
|
} from "../../../../../../components/ui/card";
|
||||||
import { gradients } from "../../../../../../utils/styleUtils";
|
import { gradients } from "../../../../../../utils/styleUtils";
|
||||||
|
import ProfilePictureChooserComponent from "./components/profilePictureChooserComponent";
|
||||||
|
|
||||||
type ProfileGradientFormComponentProps = {
|
type ProfilePictureFormComponentProps = {
|
||||||
gradient: string;
|
profilePicture: string;
|
||||||
handleInput: (event: any) => void;
|
handleInput: (event: any) => void;
|
||||||
handlePatchGradient: (gradient: string) => void;
|
handlePatchProfilePicture: (gradient: string) => void;
|
||||||
userData: any;
|
userData: any;
|
||||||
};
|
};
|
||||||
const ProfileGradientFormComponent = ({
|
const ProfilePictureFormComponent = ({
|
||||||
gradient,
|
profilePicture,
|
||||||
handleInput,
|
handleInput,
|
||||||
handlePatchGradient,
|
handlePatchProfilePicture,
|
||||||
userData,
|
userData,
|
||||||
}: ProfileGradientFormComponentProps) => {
|
}: ProfilePictureFormComponentProps) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Form.Root
|
<Form.Root
|
||||||
onSubmit={(event) => {
|
onSubmit={(event) => {
|
||||||
handlePatchGradient(gradient);
|
handlePatchProfilePicture(profilePicture);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Card x-chunk="dashboard-04-chunk-1">
|
<Card x-chunk="dashboard-04-chunk-1">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle>Profile Gradient</CardTitle>
|
<CardTitle>Profile Picture</CardTitle>
|
||||||
<CardDescription>
|
<CardDescription>
|
||||||
Choose the gradient that appears as your profile picture.
|
Choose the image that appears as your profile picture.
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="py-2">
|
<div className="py-2">
|
||||||
<GradientChooserComponent
|
<ProfilePictureChooserComponent
|
||||||
value={
|
value={
|
||||||
gradient == ""
|
profilePicture == ""
|
||||||
? userData?.profile_image ??
|
? userData?.profile_image ??
|
||||||
gradients[
|
gradients[
|
||||||
parseInt(userData?.id ?? "", 30) % gradients.length
|
parseInt(userData?.id ?? "", 30) % gradients.length
|
||||||
]
|
]
|
||||||
: gradient
|
: profilePicture
|
||||||
}
|
}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
handleInput({ target: { name: "gradient", value } });
|
handleInput({ target: { name: "profilePicture", value } });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -65,4 +65,4 @@ const ProfileGradientFormComponent = ({
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default ProfileGradientFormComponent;
|
export default ProfilePictureFormComponent;
|
||||||
|
|
@ -9,13 +9,13 @@ import {
|
||||||
inputHandlerEventType,
|
inputHandlerEventType,
|
||||||
patchUserInputStateType,
|
patchUserInputStateType,
|
||||||
} from "../../../../types/components";
|
} 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 usePatchPassword from "../hooks/use-patch-password";
|
||||||
import useSaveKey from "../hooks/use-save-key";
|
import useSaveKey from "../hooks/use-save-key";
|
||||||
import useScrollToElement from "../hooks/use-scroll-to-element";
|
import useScrollToElement from "../hooks/use-scroll-to-element";
|
||||||
import GeneralPageHeaderComponent from "./components/GeneralPageHeader";
|
import GeneralPageHeaderComponent from "./components/GeneralPageHeader";
|
||||||
import PasswordFormComponent from "./components/PasswordForm";
|
import PasswordFormComponent from "./components/PasswordForm";
|
||||||
import ProfileGradientFormComponent from "./components/ProfileGradientForm";
|
import ProfilePictureFormComponent from "./components/ProfilePictureForm";
|
||||||
import StoreApiKeyFormComponent from "./components/StoreApiKeyForm";
|
import StoreApiKeyFormComponent from "./components/StoreApiKeyForm";
|
||||||
|
|
||||||
export default function GeneralPage() {
|
export default function GeneralPage() {
|
||||||
|
|
@ -42,7 +42,7 @@ export default function GeneralPage() {
|
||||||
const loadingApiKey = useStoreStore((state) => state.loadingApiKey);
|
const loadingApiKey = useStoreStore((state) => state.loadingApiKey);
|
||||||
const setValidApiKey = useStoreStore((state) => state.updateValidApiKey);
|
const setValidApiKey = useStoreStore((state) => state.updateValidApiKey);
|
||||||
const setLoadingApiKey = useStoreStore((state) => state.updateLoadingApiKey);
|
const setLoadingApiKey = useStoreStore((state) => state.updateLoadingApiKey);
|
||||||
const { password, cnfPassword, gradient, apikey } = inputState;
|
const { password, cnfPassword, profilePicture, apikey } = inputState;
|
||||||
|
|
||||||
const { handlePatchPassword } = usePatchPassword(
|
const { handlePatchPassword } = usePatchPassword(
|
||||||
userData,
|
userData,
|
||||||
|
|
@ -50,7 +50,7 @@ export default function GeneralPage() {
|
||||||
setErrorData,
|
setErrorData,
|
||||||
);
|
);
|
||||||
|
|
||||||
const { handlePatchGradient } = usePatchGradient(
|
const { handlePatchProfilePicture } = usePatchProfilePicture(
|
||||||
setSuccessData,
|
setSuccessData,
|
||||||
setErrorData,
|
setErrorData,
|
||||||
userData,
|
userData,
|
||||||
|
|
@ -78,10 +78,10 @@ export default function GeneralPage() {
|
||||||
<GeneralPageHeaderComponent />
|
<GeneralPageHeaderComponent />
|
||||||
|
|
||||||
<div className="grid gap-6">
|
<div className="grid gap-6">
|
||||||
<ProfileGradientFormComponent
|
<ProfilePictureFormComponent
|
||||||
gradient={gradient}
|
profilePicture={profilePicture}
|
||||||
handleInput={handleInput}
|
handleInput={handleInput}
|
||||||
handlePatchGradient={handlePatchGradient}
|
handlePatchProfilePicture={handlePatchProfilePicture}
|
||||||
userData={userData}
|
userData={userData}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,20 @@ import {
|
||||||
} from "../../../../constants/alerts_constants";
|
} from "../../../../constants/alerts_constants";
|
||||||
import { updateUser } from "../../../../controllers/API";
|
import { updateUser } from "../../../../controllers/API";
|
||||||
|
|
||||||
const usePatchGradient = (
|
const usePatchProfilePicture = (
|
||||||
setSuccessData,
|
setSuccessData,
|
||||||
setErrorData,
|
setErrorData,
|
||||||
currentUserData,
|
currentUserData,
|
||||||
setUserData,
|
setUserData,
|
||||||
) => {
|
) => {
|
||||||
const handlePatchGradient = async (gradient) => {
|
const handlePatchProfilePicture = async (profile_picture) => {
|
||||||
try {
|
try {
|
||||||
if (gradient !== "") {
|
if (profile_picture !== "") {
|
||||||
await updateUser(currentUserData.id, { profile_image: gradient });
|
await updateUser(currentUserData.id, {
|
||||||
|
profile_image: profile_picture,
|
||||||
|
});
|
||||||
let newUserData = cloneDeep(currentUserData);
|
let newUserData = cloneDeep(currentUserData);
|
||||||
newUserData.profile_image = gradient;
|
newUserData.profile_image = profile_picture;
|
||||||
setUserData(newUserData);
|
setUserData(newUserData);
|
||||||
}
|
}
|
||||||
setSuccessData({ title: SAVE_SUCCESS_ALERT });
|
setSuccessData({ title: SAVE_SUCCESS_ALERT });
|
||||||
|
|
@ -30,8 +32,8 @@ const usePatchGradient = (
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentUserData,
|
currentUserData,
|
||||||
handlePatchGradient,
|
handlePatchProfilePicture,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default usePatchGradient;
|
export default usePatchProfilePicture;
|
||||||
|
|
@ -396,7 +396,7 @@ export type loginInputStateType = {
|
||||||
export type patchUserInputStateType = {
|
export type patchUserInputStateType = {
|
||||||
password: string;
|
password: string;
|
||||||
cnfPassword: string;
|
cnfPassword: string;
|
||||||
gradient: string;
|
profilePicture: string;
|
||||||
apikey: string;
|
apikey: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue