This commit is contained in:
@@ -64,7 +64,7 @@ export default function AccountDetails({ data }: { data: UserMetaCardProps }) {
|
||||
new_password: formValues.new_password,
|
||||
};
|
||||
|
||||
await apiChangePassword(userId, payload as any);
|
||||
await apiChangePassword(payload as any);
|
||||
closeModal();
|
||||
toast.success("Cập nhật thành công!");
|
||||
router.refresh();
|
||||
|
||||
@@ -7,7 +7,7 @@ import Button from "../ui/button/Button";
|
||||
import Input from "../form/input/InputField";
|
||||
import Label from "../form/Label";
|
||||
import { Profile, UserMetaCardProps } from "@/interface/user";
|
||||
import { apiUpdateUser, apiUpdateUserCurrent } from "@/service/userService";
|
||||
import { apiUpdateUser } from "@/service/userService";
|
||||
import { toast } from "sonner";
|
||||
import Link from "next/link";
|
||||
|
||||
@@ -51,7 +51,7 @@ export default function UserInfoCard({ data }: { data: UserMetaCardProps }) {
|
||||
if (!userId) return;
|
||||
|
||||
try {
|
||||
const response = await apiUpdateUserCurrent(formData);
|
||||
const response = await apiUpdateUser(formData);
|
||||
|
||||
if (response && response.status === false) {
|
||||
toast.error(response.message || "Cập nhật thất bại.");
|
||||
|
||||
@@ -5,7 +5,7 @@ import Image from "next/image";
|
||||
import { UserMetaCardProps } from "@/interface/user";
|
||||
import { uploadMedia } from "@/service/mediaService";
|
||||
import { toast } from "sonner";
|
||||
import { apiUpdateUser, apiUpdateUserCurrent } from "@/service/userService";
|
||||
import { apiUpdateUser } from "@/service/userService";
|
||||
import { URL_MEDIA } from "../../../api";
|
||||
|
||||
export default function UserMetaCard({ data }: { data: UserMetaCardProps }) {
|
||||
@@ -48,7 +48,7 @@ export default function UserMetaCard({ data }: { data: UserMetaCardProps }) {
|
||||
setPreviewImage(url);
|
||||
if (data.data) {
|
||||
try {
|
||||
await apiUpdateUserCurrent({ avatar_url: url });
|
||||
await apiUpdateUser({ avatar_url: url });
|
||||
toast.success("Cập nhật avatar thành công!");
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
|
||||
@@ -41,7 +41,7 @@ export const apiGetCurrentUser = async () => {
|
||||
return response?.data;
|
||||
};
|
||||
|
||||
export const apiChangePassword = async (id:string,payload: any) => {
|
||||
const response = await api.patch(API.User.CHANGE_PASSWORD(id), payload);
|
||||
export const apiChangePassword = async (payload: any) => {
|
||||
const response = await api.patch(API.User.CHANGE_PASSWORD, payload);
|
||||
return response?.data;
|
||||
};
|
||||
|
||||
@@ -12,12 +12,7 @@ export const apiGetCurrentUserApplications = async () => {
|
||||
return response?.data;
|
||||
};
|
||||
|
||||
export const apiUpdateUser = async (id:string, payload: Profile) => {
|
||||
const response = await api.put(API.User.Update(id), payload);
|
||||
export const apiUpdateUser = async (payload: Profile) => {
|
||||
const response = await api.put(API.User.Update, payload);
|
||||
return response?.data;
|
||||
};
|
||||
|
||||
export const apiUpdateUserCurrent = async (payload: Profile) => {
|
||||
const response = await api.put(API.User.CURRENT, payload);
|
||||
return response?.data;
|
||||
};
|
||||
Reference in New Issue
Block a user