fix
Desc: - Tampilan sudah fix - State list porto sudah ada
This commit is contained in:
@@ -4,13 +4,12 @@ import { myConsole } from "@/app/fun/my_console";
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param id - profileId
|
||||
* @returns list portofolio by Id
|
||||
*/
|
||||
export default async function getListPortofolio(id: string) {
|
||||
myConsole(id);
|
||||
|
||||
// myConsole(id);
|
||||
|
||||
const data = await prisma.katalog.findMany({
|
||||
where: {
|
||||
@@ -26,9 +25,9 @@ export default async function getListPortofolio(id: string) {
|
||||
masterBidangBisnisId: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
if (!data) {
|
||||
throw new Error('Failed to fetch data')
|
||||
throw new Error("Failed to fetch data");
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
@@ -9,6 +9,7 @@ import { loadDataProfile } from "../../profile/fun/fun_get_profile";
|
||||
import { useAtom } from "jotai";
|
||||
import { gs_profile } from "../../profile/state/global_state";
|
||||
import getListPortofolio from "../api/get-portofolio";
|
||||
import { gs_ListPortofolio } from "../state/global_state";
|
||||
|
||||
export default function PortofolioView({
|
||||
profileId,
|
||||
@@ -22,7 +23,7 @@ export default function PortofolioView({
|
||||
loadDataProfile(setProfile);
|
||||
}, []);
|
||||
|
||||
const [listPorto, setListPorto] = useState<any | null>(porto);
|
||||
const [listPorto, setListPorto] = useAtom(gs_ListPortofolio)
|
||||
useShallowEffect(() => {
|
||||
loadListPortofolio(profile?.id).then((res) => setListPorto(res));
|
||||
}, [profile?.id]);
|
||||
|
||||
3
src/app_modules/katalog/portofolio/state/global_state.ts
Normal file
3
src/app_modules/katalog/portofolio/state/global_state.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { atomWithStorage } from "jotai/utils";
|
||||
|
||||
export const gs_ListPortofolio = atomWithStorage<any | null>("gs_ListPortofolio", null)
|
||||
Reference in New Issue
Block a user