title: auto

des: auto
note:auto
This commit is contained in:
2023-10-06 15:44:43 +08:00
parent c5dde10807
commit 669680320f
3 changed files with 27 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
import HomeView from "./view"; import HomeView from "./view";
import HomeLayout from "./layout"; import HomeLayout from "./layout";
import { getToken } from "./fun/api-get-token"; import { getToken } from "./api/api-get-token";
export {HomeView, HomeLayout, getToken} export {HomeView, HomeLayout, getToken}

View File

@@ -15,7 +15,7 @@ import { Logout } from "../auth";
import { useState } from "react"; import { useState } from "react";
import { ApiHipmi } from "@/app/lib/api"; import { ApiHipmi } from "@/app/lib/api";
import { useShallowEffect } from "@mantine/hooks"; import { useShallowEffect } from "@mantine/hooks";
import { getToken } from "./fun/api-get-token"; import { getToken } from "./api/api-get-token";
import { import {
IconAffiliate, IconAffiliate,
@@ -35,11 +35,15 @@ import { useRouter } from "next/navigation";
import { useAtom } from "jotai"; import { useAtom } from "jotai";
import { gs_token } from "./state/global_state"; import { gs_token } from "./state/global_state";
import { loadDataProfile } from "../katalog/profile/fun/fun_get_profile"; 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 { loadListPortofolio } from "../katalog/portofolio/fun/fun_get_all_portofolio";
import { gs_ListPortofolio } from "../katalog/portofolio/state/global_state"; import { gs_ListPortofolio } from "../katalog/portofolio/state/global_state";
import { myConsole } from "@/app/fun/my_console"; import { myConsole } from "@/app/fun/my_console";
import { getFotoProfile } from "../katalog/profile/api/get-foto-profile"; import { getFotoProfile } from "../katalog/profile/api/get-foto-profile";
import getListPortofolio from "../katalog/portofolio/api/get-portofolio";
const listHalaman = [ const listHalaman = [
{ {
@@ -88,7 +92,6 @@ export default function HomeView() {
const router = useRouter(); const router = useRouter();
const [token, setToken] = useAtom(gs_token); const [token, setToken] = useAtom(gs_token);
useShallowEffect(() => { useShallowEffect(() => {
getUserId(); getUserId();
}, []); }, []);
@@ -99,28 +102,31 @@ export default function HomeView() {
const [profile, setProfile] = useAtom(gs_profile); const [profile, setProfile] = useAtom(gs_profile);
useShallowEffect(() => { useShallowEffect(() => {
// loadDataProfile(setProfile); loadProfile();
loadProfile()
}, []); }, []);
async function loadProfile() { async function loadProfile() {
const data = await getProfile() const data = await getProfile();
setProfile(data) setProfile(data);
} }
// const [foto, setFoto] = useAtom(gs_fotoProfile); const [foto, setFoto] = useAtom(gs_fotoProfile);
// useShallowEffect(() => { useShallowEffect(() => {
// if (profile?.imagesId === undefined) { if (profile?.imagesId === undefined) {
// return myConsole("Waiting data"); return myConsole("Waiting data");
// } else { } else {
// getFotoProfile(profile?.imagesId).then((v) => setFoto(v?.url)); getFotoProfile(profile?.imagesId).then((v) => setFoto(v?.url));
// } }
// }, [profile?.imagesId]); }, [profile?.imagesId]);
// const [listPorto, setListPorto] = useAtom(gs_ListPortofolio)
// useShallowEffect(() => { const [listPorto, setListPorto] = useAtom(gs_ListPortofolio);
// loadListPortofolio(profile?.id).then((res) => setListPorto(res)); useShallowEffect(() => {
// }, [profile?.id]); getListPorto(profile?.id);
}, [profile?.id]);
async function getListPorto(id: string) {
const data = await getListPortofolio(id);
setListPorto(data);
}
return ( return (
<> <>