"use client"; import { ActionIcon, Box, Flex, Image, Loader, Paper, SimpleGrid, Text, Title, } from "@mantine/core"; import { Logout } from "../auth"; import { useState } from "react"; import { ApiHipmi } from "@/app/lib/api"; import { useShallowEffect } from "@mantine/hooks"; import { getToken } from "./api/api-get-token"; import { IconAffiliate, IconBriefcase, IconHeartHandshake, IconMap2, IconMessages, IconPackageImport, IconPresentation, IconShoppingBag, IconUserCircle, } from "@tabler/icons-react"; import toast from "react-simple-toasts"; import { getProfile } from "../katalog/profile"; 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 { 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 = [ { id: 1, name: "Forums", icon: , }, { id: 2, name: "Project Collaboration", icon: , }, { id: 3, name: "Voting", icon: , }, { id: 4, name: "Event", icon: , }, { id: 5, name: "Crowd Funding", icon: , }, { id: 6, name: "Marketplace", icon: , }, { id: 7, name: "Job Vacancy", icon: , }, { id: 8, name: "Business Maps", icon: , }, ]; export default function HomeView() { const router = useRouter(); const [token, setToken] = useAtom(gs_token); useShallowEffect(() => { getUserId(); }, []); async function getUserId() { const data = await getToken(); setToken(data); } const [profile, setProfile] = useAtom(gs_profile); useShallowEffect(() => { loadProfile(); }, []); async function loadProfile() { 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 [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)}
*/} { if (profile === null) { return router.push("/dev/katalog/profile/create"); } else { return router.push("/dev/katalog/view"); } }} > Welcome to,{" "} {token?.username ? token?.username : } logo {listHalaman.map((e, i) => ( toast(e.name)} > {e.icon} {e.name} ))} ); }