fix background update

This commit is contained in:
2025-02-27 11:43:09 +08:00
parent 74792a7636
commit e5a2efebf0
5 changed files with 66 additions and 28 deletions

View File

@@ -1,12 +1,9 @@
import { Profile_getOneById } from "@/app_modules/katalog/profile/fun/get/get_one_profile"
import Profile_UpdateFotoBackground from "@/app_modules/katalog/profile/upload/foto_background" import Profile_UpdateFotoBackground from "@/app_modules/katalog/profile/upload/foto_background"
export default async function Page({params}:{params: {id: string}}) { export default async function Page() {
let profileId = params.id return (
const dataProfile = await Profile_getOneById(profileId) <>
<Profile_UpdateFotoBackground />
return <>
<Profile_UpdateFotoBackground dataProfile={dataProfile as any}/>
</> </>
);
} }

View File

@@ -1,13 +1,9 @@
import { UploadFotoProfile } from "@/app_modules/katalog/profile"; import { UploadFotoProfile } from "@/app_modules/katalog/profile";
import { Profile_getOneById } from "@/app_modules/katalog/profile/fun/get/get_one_profile";
export default async function Page({ params }: { params: { id: string } }) {
let profileId = params.id;
const dataProfile = await Profile_getOneById(profileId);
export default async function Page() {
return ( return (
<> <>
<UploadFotoProfile dataProfile={dataProfile as any} /> <UploadFotoProfile />
</> </>
); );
} }

View File

@@ -9,6 +9,5 @@ export async function Profile_getOneById(profileId: string) {
}, },
}); });
return data; return data;
} }

View File

@@ -9,16 +9,39 @@ import { AspectRatio, Center, Image, Stack } from "@mantine/core";
import { useState } from "react"; import { useState } from "react";
import { Profile_ComponentButtonUpdateBackgroundProfile } from "../../_component"; import { Profile_ComponentButtonUpdateBackgroundProfile } from "../../_component";
import { MODEL_PROFILE } from "../../model/interface"; import { MODEL_PROFILE } from "../../model/interface";
import { useShallowEffect } from "@mantine/hooks";
import { apiGetOneProfileById } from "../../lib/api_fetch_profile";
import { useParams } from "next/navigation";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
export default function Profile_UpdateFotoBackground({ export default function Profile_UpdateFotoBackground() {
dataProfile, const param = useParams<{ id: string }>();
}: { const profileId = param.id;
dataProfile: MODEL_PROFILE; const [profile, setProfile] = useState<MODEL_PROFILE | null>(null);
}) {
const [profile, setProfile] = useState(dataProfile);
const [file, setFile] = useState<File | null>(null); const [file, setFile] = useState<File | null>(null);
const [image, setImage] = useState<any | null>(null); const [image, setImage] = useState<any | null>(null);
useShallowEffect(() => {
handleLoadData();
}, []);
const handleLoadData = async () => {
try {
const response = await apiGetOneProfileById({ id: profileId });
if (response && response.success) {
setProfile(response.data);
} else {
setProfile(null);
}
} catch (error) {
console.log("Error get profile", error);
setProfile(null);
}
};
if (!profile)
return <CustomSkeleton height={300} width={"100%"} radius={"md"} />;
return ( return (
<> <>
<Stack px={"xs"}> <Stack px={"xs"}>

View File

@@ -9,16 +9,39 @@ import { AspectRatio, Center, Image, Stack } from "@mantine/core";
import { useState } from "react"; import { useState } from "react";
import { Profile_ComponentButtonUpdatePhotoProfile } from "../../_component"; import { Profile_ComponentButtonUpdatePhotoProfile } from "../../_component";
import { MODEL_PROFILE } from "../../model/interface"; import { MODEL_PROFILE } from "../../model/interface";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import { useShallowEffect } from "@mantine/hooks";
import { useParams } from "next/navigation";
import { apiGetOneProfileById } from "../../lib/api_fetch_profile";
export default function UploadFotoProfile({ export default function UploadFotoProfile() {
dataProfile, const param = useParams<{ id: string }>();
}: { const profileId = param.id;
dataProfile: MODEL_PROFILE; const [profile, setProfile] = useState<MODEL_PROFILE | null>(null);
}) {
const [profile, setProfile] = useState(dataProfile);
const [file, setFile] = useState<File | null>(null); const [file, setFile] = useState<File | null>(null);
const [image, setImage] = useState<any | null>(null); const [image, setImage] = useState<any | null>(null);
useShallowEffect(() => {
handleLoadData();
}, []);
const handleLoadData = async () => {
try {
const response = await apiGetOneProfileById({ id: profileId });
if (response && response.success) {
setProfile(response.data);
} else {
setProfile(null);
}
} catch (error) {
console.log("Error get profile", error);
setProfile(null);
}
};
if (!profile)
return <CustomSkeleton height={300} width={"100%"} radius={"md"} />;
return ( return (
<> <>
<Stack px={"xs"}> <Stack px={"xs"}>