diff --git a/api.ts b/api.ts
index 14c6028..275793d 100644
--- a/api.ts
+++ b/api.ts
@@ -2,7 +2,9 @@ export const API_URL_ROOT = process.env.NEXT_PUBLIC_API_URL_ROOT || "";
export const API = {
User : {
- CURRENT: `${API_URL_ROOT}/users/current`
+ CURRENT: `${API_URL_ROOT}/users/current`,
+ MEDIA: `${API_URL_ROOT}/users/current/media`,
+ Update: (Id: number | string) => `${API_URL_ROOT}/users/${Id}`,
},
Auth : {
SIGNUP: `${API_URL_ROOT}/auth/signup`,
diff --git a/src/app/(admin)/(others-pages)/profile/page.tsx b/src/app/(admin)/(others-pages)/profile/page.tsx
index aae12bb..cbcc5bd 100644
--- a/src/app/(admin)/(others-pages)/profile/page.tsx
+++ b/src/app/(admin)/(others-pages)/profile/page.tsx
@@ -2,8 +2,10 @@
import UserAddressCard from "@/components/user-profile/UserAddressCard";
import UserInfoCard from "@/components/user-profile/UserInfoCard";
-import UserMetaCard, { UserMetaCardProps } from "@/components/user-profile/UserMetaCard";
+import UserMetaCard from "@/components/user-profile/UserMetaCard";
+import { UserMetaCardProps } from "@/interface/user";
import { apiGetCurrentUser } from "@/service/auth";
+import { apiGetCurrentUserMedia } from "@/service/userService";
import { RootState } from "@/store/store";
import { useEffect, useState } from "react";
import { useSelector } from "react-redux";
@@ -16,7 +18,9 @@ export default function Profile() {
const fetchUser = async () => {
try {
const result = await apiGetCurrentUser();
+ const mediaResult = await apiGetCurrentUserMedia();
console.log("Current User:", result);
+ console.log("User Media:", mediaResult);
setUser(result);
} catch (err) {
console.error("Lỗi:", err);
@@ -35,7 +39,7 @@ export default function Profile() {
-
+
diff --git a/src/components/ui/button/Button.tsx b/src/components/ui/button/Button.tsx
index fa9c7f1..ec608d5 100644
--- a/src/components/ui/button/Button.tsx
+++ b/src/components/ui/button/Button.tsx
@@ -9,6 +9,7 @@ interface ButtonProps {
onClick?: () => void; // Click handler
disabled?: boolean; // Disabled state
className?: string; // Disabled state
+ type?: "button" | "submit" | "reset";
}
const Button: React.FC = ({
@@ -20,6 +21,7 @@ const Button: React.FC = ({
onClick,
className = "",
disabled = false,
+ type = "button",
}) => {
// Size Classes
const sizeClasses = {
diff --git a/src/components/user-profile/UserAddressCard.tsx b/src/components/user-profile/UserAddressCard.tsx
index e7430e3..0719083 100644
--- a/src/components/user-profile/UserAddressCard.tsx
+++ b/src/components/user-profile/UserAddressCard.tsx
@@ -1,31 +1,55 @@
"use client";
-import React from "react";
+import React, { useState } from "react";
import { useModal } from "../../hooks/useModal";
import { Modal } from "../ui/modal";
import Button from "../ui/button/Button";
import Input from "../form/input/InputField";
import Label from "../form/Label";
+import { Profile } from "@/interface/user";
export default function UserAddressCard() {
const { isOpen, openModal, closeModal } = useModal();
- const handleSave = () => {
- // Handle save logic here
- console.log("Saving changes...");
- closeModal();
- };
+ const [formData, setFormData] = useState({
+ display_name: "",
+ phone: "",
+ bio: "",
+ location: "",
+ website: "",
+ // Thêm các field khác nếu cần
+ });
+
+ useEffect(() => {
+ if (data?.data?.profile) {
+ setFormData({
+ display_name: data.data.profile.display_name || "",
+ phone: data.data.profile.phone || "",
+ bio: data.data.profile.bio || "",
+ location: data.data.profile.location || "",
+ website: data.data.profile.website || "",
+ });
+ }
+ }, [data, isOpen]);
+
+ const handleChange = (e: React.ChangeEvent) => {
+ const { name, value } = e.target;
+ setFormData((prev) => ({
+ ...prev,
+ [name]: value,
+ }));
+ };
return (
<>
-
- Address
+
+ Account details
- Country
+ Username
United States
@@ -40,30 +64,12 @@ export default function UserAddressCard() {
Phoenix, Arizona, United States.
-
-
-
- Postal Code
-
-
- ERT 2489
-
-
-
-
-
- TAX ID
-
-
- AS4568384
-
-
@@ -73,13 +128,12 @@ export default function UserInfoCard() {
onClick={openModal}
className="flex w-full items-center justify-center gap-2 rounded-full border border-gray-300 bg-white px-4 py-3 text-sm font-medium text-gray-700 shadow-theme-xs hover:bg-gray-50 hover:text-gray-800 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-white/[0.03] dark:hover:text-gray-200 lg:inline-flex lg:w-auto"
>
+ {/* SVG giữ nguyên */}