diff --git a/src/app/fun/my_console.ts b/src/app/fun/my_console.ts index c6dd9398..2c626bd5 100644 --- a/src/app/fun/my_console.ts +++ b/src/app/fun/my_console.ts @@ -1,5 +1,5 @@ export function myConsole(value: any) { - const onData = false + const onData = true if (onData) { console.log(value); } diff --git a/src/app_modules/home/view.tsx b/src/app_modules/home/view.tsx index b5ebb6de..c44594b9 100644 --- a/src/app_modules/home/view.tsx +++ b/src/app_modules/home/view.tsx @@ -3,6 +3,7 @@ import { ActionIcon, Box, + Center, Flex, Image, Loader, @@ -90,14 +91,15 @@ const listHalaman = [ export default function HomeView() { const router = useRouter(); - const [token, setToken] = useAtom(gs_token); + const [token, setToken] = useAtom(gs_token); useShallowEffect(() => { getUserId(); }, []); async function getUserId() { - const data = await getToken(); - setToken(data); + const get = await getToken(); + if(!get) return myConsole("Data Kosong") + setToken(get); } const [profile, setProfile] = useAtom(gs_profile); @@ -105,43 +107,38 @@ export default function HomeView() { loadProfile(); }, []); async function loadProfile() { - const data = await getProfile(); - - setProfile(data); + const get = await getProfile(); + if(!get) return myConsole("Data Kosong") + setProfile(get); } - // const [foto, setFoto] = useAtom(gs_fotoProfile); - // useShallowEffect(() => { - // getFoto(profile?.imagesId); - // // if (profile?.imagesId === undefined) { - // // return myConsole("Waiting data"); - // // } else { - // // getFoto(profile?.imagesId); - // // } - // }, [profile?.imagesId]); - - // async function getFoto(id: string) { - // if(id === undefined){ - // return myConsole("Waiting data") - // } else { - // const data = await getFotoProfile(id); - // setFoto(data); - // } - - // } - - const [listPorto, setListPorto] = useAtom(gs_ListPortofolio); + const [foto, setFoto] = useAtom(gs_fotoProfile); useShallowEffect(() => { - getListPorto(profile?.id); - }, [profile?.id]); - async function getListPorto(id: string) { - const data = await getListPortofolio(id); - setListPorto(data); + getFoto(profile?.imagesId); + }, [profile?.imagesId]); + + async function getFoto(id: string) { + if(id === undefined){ + return myConsole("Waiting data") + } else { + const data = await getFotoProfile(id); + setFoto(data?.url); + } } + // 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 ( <> - {/*
{JSON.stringify(profile, null, 2)} */}
+ {/* {JSON.stringify(foto, null, 2)} */}
+