fix
Deskripsi: - Upload foto profil ke storage - Upload background profile ke storge ## No Issue
This commit is contained in:
63
src/app_modules/home/component/comp_avatar_profile.tsx
Normal file
63
src/app_modules/home/component/comp_avatar_profile.tsx
Normal file
@@ -0,0 +1,63 @@
|
||||
"use client";
|
||||
|
||||
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
|
||||
import { Avatar, Center } from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { useState } from "react";
|
||||
|
||||
export function Home_ComponentAvatarProfile({ url }: { url: string }) {
|
||||
const [isImage, setIsImage] = useState<boolean | null>(null);
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadImage();
|
||||
}, []);
|
||||
|
||||
async function onLoadImage() {
|
||||
try {
|
||||
const res = await fetch(url);
|
||||
if (res.ok) {
|
||||
return setIsImage(true);
|
||||
}
|
||||
setIsImage(false);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
if (isImage === null) {
|
||||
<Center>
|
||||
<ComponentGlobal_Loader />
|
||||
</Center>;
|
||||
}
|
||||
|
||||
if (!isImage) {
|
||||
return (
|
||||
<>
|
||||
<Avatar
|
||||
radius={"xl"}
|
||||
size={25}
|
||||
sx={{
|
||||
borderStyle: "solid",
|
||||
borderWidth: "0.5px",
|
||||
borderColor: "white",
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Avatar
|
||||
radius={"xl"}
|
||||
size={25}
|
||||
sx={{
|
||||
borderStyle: "solid",
|
||||
borderWidth: "0.5px",
|
||||
borderColor: "white",
|
||||
}}
|
||||
src={url}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
3
src/app_modules/home/component/index.ts
Normal file
3
src/app_modules/home/component/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Home_ComponentAvatarProfile } from "./comp_avatar_profile";
|
||||
|
||||
export { Home_ComponentAvatarProfile };
|
||||
@@ -43,6 +43,8 @@ import { MODEL_JOB } from "@/app_modules/job/model/interface";
|
||||
import { RouterForum } from "@/app/lib/router_hipmi/router_forum";
|
||||
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
|
||||
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
||||
import { Home_ComponentAvatarProfile } from "./comp_avatar_profile";
|
||||
import { APIs } from "@/app/lib";
|
||||
|
||||
export function Home_UiView({
|
||||
dataUser,
|
||||
@@ -341,18 +343,11 @@ export function Home_UiFooter({ dataUser }: { dataUser: MODEL_USER }) {
|
||||
) : isLoadingProfil ? (
|
||||
<Loader color={AccentColor.yellow} size={20} />
|
||||
) : (
|
||||
<Avatar
|
||||
radius={"xl"}
|
||||
size={25}
|
||||
sx={{
|
||||
borderStyle: "solid",
|
||||
borderWidth: "0.5px",
|
||||
borderColor: "white",
|
||||
}}
|
||||
src={
|
||||
RouterProfile.api_foto_profile +
|
||||
`${dataUser?.Profile.imagesId}`
|
||||
}
|
||||
<Home_ComponentAvatarProfile
|
||||
url={APIs.GET({
|
||||
fileId: dataUser?.Profile?.imageId as string,
|
||||
size: "50"
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
</ActionIcon>
|
||||
|
||||
Reference in New Issue
Block a user