From 669680320f742e2f1ac4865d4cf825cacb90da70 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Fri, 6 Oct 2023 15:44:43 +0800 Subject: [PATCH] title: auto des: auto note:auto --- .../home/{fun => api}/api-get-token.ts | 0 src/app_modules/home/index.ts | 2 +- src/app_modules/home/view.tsx | 46 +++++++++++-------- 3 files changed, 27 insertions(+), 21 deletions(-) rename src/app_modules/home/{fun => api}/api-get-token.ts (100%) diff --git a/src/app_modules/home/fun/api-get-token.ts b/src/app_modules/home/api/api-get-token.ts similarity index 100% rename from src/app_modules/home/fun/api-get-token.ts rename to src/app_modules/home/api/api-get-token.ts diff --git a/src/app_modules/home/index.ts b/src/app_modules/home/index.ts index fb448aff..dfb2e4ad 100644 --- a/src/app_modules/home/index.ts +++ b/src/app_modules/home/index.ts @@ -1,4 +1,4 @@ import HomeView from "./view"; import HomeLayout from "./layout"; -import { getToken } from "./fun/api-get-token"; +import { getToken } from "./api/api-get-token"; export {HomeView, HomeLayout, getToken} \ No newline at end of file diff --git a/src/app_modules/home/view.tsx b/src/app_modules/home/view.tsx index b1fa2093..93465994 100644 --- a/src/app_modules/home/view.tsx +++ b/src/app_modules/home/view.tsx @@ -15,7 +15,7 @@ import { Logout } from "../auth"; import { useState } from "react"; import { ApiHipmi } from "@/app/lib/api"; import { useShallowEffect } from "@mantine/hooks"; -import { getToken } from "./fun/api-get-token"; +import { getToken } from "./api/api-get-token"; import { IconAffiliate, @@ -35,11 +35,15 @@ import { useRouter } from "next/navigation"; import { useAtom } from "jotai"; import { gs_token } from "./state/global_state"; import { loadDataProfile } from "../katalog/profile/fun/fun_get_profile"; -import { gs_fotoProfile, gs_profile } from "../katalog/profile/state/global_state"; +import { + gs_fotoProfile, + gs_profile, +} from "../katalog/profile/state/global_state"; import { loadListPortofolio } from "../katalog/portofolio/fun/fun_get_all_portofolio"; import { gs_ListPortofolio } from "../katalog/portofolio/state/global_state"; import { myConsole } from "@/app/fun/my_console"; import { getFotoProfile } from "../katalog/profile/api/get-foto-profile"; +import getListPortofolio from "../katalog/portofolio/api/get-portofolio"; const listHalaman = [ { @@ -88,7 +92,6 @@ export default function HomeView() { const router = useRouter(); const [token, setToken] = useAtom(gs_token); - useShallowEffect(() => { getUserId(); }, []); @@ -99,28 +102,31 @@ export default function HomeView() { const [profile, setProfile] = useAtom(gs_profile); useShallowEffect(() => { - // loadDataProfile(setProfile); - loadProfile() + loadProfile(); }, []); async function loadProfile() { - const data = await getProfile() - setProfile(data) - + const data = await getProfile(); + setProfile(data); } - // const [foto, setFoto] = useAtom(gs_fotoProfile); - // useShallowEffect(() => { - // if (profile?.imagesId === undefined) { - // return myConsole("Waiting data"); - // } else { - // getFotoProfile(profile?.imagesId).then((v) => setFoto(v?.url)); - // } - // }, [profile?.imagesId]); + const [foto, setFoto] = useAtom(gs_fotoProfile); + useShallowEffect(() => { + if (profile?.imagesId === undefined) { + return myConsole("Waiting data"); + } else { + getFotoProfile(profile?.imagesId).then((v) => setFoto(v?.url)); + } + }, [profile?.imagesId]); - // const [listPorto, setListPorto] = useAtom(gs_ListPortofolio) - // useShallowEffect(() => { - // loadListPortofolio(profile?.id).then((res) => setListPorto(res)); - // }, [profile?.id]); + + const [listPorto, setListPorto] = useAtom(gs_ListPortofolio); + useShallowEffect(() => { + getListPorto(profile?.id); + }, [profile?.id]); + async function getListPorto(id: string) { + const data = await getListPortofolio(id); + setListPorto(data); + } return ( <>