submit
This commit is contained in:
1 parent
4f4203dbb3
commit
b26d135a4f
2 files changed
+7
-13
No files matched your search
@@ -19,3 +19,4 @@ export * from "./Gauge";
|
|||||||
export * from "./Tabs";
|
export * from "./Tabs";
|
||||||
export * from "./SplitBox";
|
export * from "./SplitBox";
|
||||||
export * from "./TextLink";
|
export * from "./TextLink";
|
||||||
|
export * from "./ConfirmDialog";
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
import { useState } from "react";
|
|
||||||
import { Stack, Box } from "@mui/material";
|
import { Stack, Box } from "@mui/material";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from "react-hook-form";
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import { useNavigate } from "react-router-dom";
|
|
||||||
import { ConfigBox } from "@/Components/v2/design-elements";
|
import { ConfigBox } from "@/Components/v2/design-elements";
|
||||||
import { TextField, Button } from "@/Components/v2/inputs";
|
import { TextField, Button } from "@/Components/v2/inputs";
|
||||||
import { ImageUpload } from "@/Components/v2/inputs";
|
import { ImageUpload } from "@/Components/v2/inputs";
|
||||||
import { useProfileForm } from "@/Hooks/useProfileForm";
|
import { useProfileForm } from "@/Hooks/useProfileForm";
|
||||||
import { usePatch, useDelete } from "@/Hooks/UseApi";
|
import { usePatch } from "@/Hooks/UseApi";
|
||||||
import { setUser, clearAuthState } from "@/Features/Auth/authSlice";
|
import { setUser } from "@/Features/Auth/authSlice";
|
||||||
import type { ProfileFormData } from "@/Validation/profile";
|
import type { ProfileFormData } from "@/Validation/profile";
|
||||||
import type { RootState } from "@/Types/state";
|
import type { RootState } from "@/Types/state";
|
||||||
import type { User } from "@/Types/User";
|
import type { User } from "@/Types/User";
|
||||||
@@ -17,12 +15,9 @@ import type { User } from "@/Types/User";
|
|||||||
export const TabProfile = () => {
|
export const TabProfile = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
|
||||||
const user = useSelector((state: RootState) => state.auth?.user);
|
const user = useSelector((state: RootState) => state.auth?.user);
|
||||||
const { resolver, defaults } = useProfileForm();
|
const { resolver, defaults } = useProfileForm();
|
||||||
const { patch, loading: patchLoading } = usePatch<FormData, User>();
|
const { patch, loading: patchLoading } = usePatch<FormData, User>();
|
||||||
const { deleteFn, loading: deleteLoading } = useDelete();
|
|
||||||
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
|
||||||
|
|
||||||
const { control, handleSubmit, setValue, watch } = useForm<ProfileFormData>({
|
const { control, handleSubmit, setValue, watch } = useForm<ProfileFormData>({
|
||||||
resolver,
|
resolver,
|
||||||
@@ -69,12 +64,10 @@ export const TabProfile = () => {
|
|||||||
fd.append("deleteProfileImage", "true");
|
fd.append("deleteProfileImage", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(fd);
|
const result = await patch("/auth/user", fd);
|
||||||
|
if (result?.success && result.data) {
|
||||||
// const result = await patch("/auth/user", fd);
|
dispatch(setUser(result.data));
|
||||||
// if (result?.success && result.data) {
|
}
|
||||||
// dispatch(setUser(result.data));
|
|
||||||
// }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in new issue
Block a user