fix : user id
deskrispi: - menghapus async pada page atau layout dan menggunakan metode API dalam pemanggilan user id
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { NextResponse } from 'next/server';
|
import { NextResponse } from "next/server";
|
||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
import { decrypt } from "@/app/(auth)/_lib/decrypt";
|
import { decrypt } from "@/app/(auth)/_lib/decrypt";
|
||||||
|
|
||||||
@@ -7,7 +7,11 @@ export async function GET() {
|
|||||||
|
|
||||||
if (!SESSION_KEY) {
|
if (!SESSION_KEY) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, error: "Session key not configured" },
|
{
|
||||||
|
success: false,
|
||||||
|
error: "Session key not configured",
|
||||||
|
message: "Session key not configured",
|
||||||
|
},
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -17,7 +21,7 @@ export async function GET() {
|
|||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, error: "No token found" },
|
{ success: false, error: "No token found", message: "No token found" },
|
||||||
{ status: 401 }
|
{ status: 401 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -30,19 +34,24 @@ export async function GET() {
|
|||||||
|
|
||||||
if (!decoded) {
|
if (!decoded) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, error: "Invalid token" },
|
{ success: false, error: "Invalid token", message: "Invalid token" },
|
||||||
{ status: 401 }
|
{ status: 401 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
success: true,
|
success: true,
|
||||||
|
message: "Berhasil mendapatkan data",
|
||||||
userId: decoded.id,
|
userId: decoded.id,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error decoding token:", error);
|
console.error("Error decoding token:", error);
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, error: "Failed to decode token" },
|
{
|
||||||
|
success: false,
|
||||||
|
error: "Failed to decode token",
|
||||||
|
message: "Failed to decode token",
|
||||||
|
},
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,10 @@
|
|||||||
import { CreatePortofolioLayout } from "@/app_modules/katalog/portofolio";
|
import { CreatePortofolioLayout } from "@/app_modules/katalog/portofolio";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default function Layout({ children }: { children: React.ReactNode }) {
|
||||||
children,
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
children: React.ReactNode;
|
|
||||||
params: { id: string };
|
|
||||||
}) {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CreatePortofolioLayout profileId={params.id}>
|
<CreatePortofolioLayout>{children}</CreatePortofolioLayout>
|
||||||
{children}
|
|
||||||
</CreatePortofolioLayout>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { CreatePortofolio } from "@/app_modules/katalog/portofolio";
|
|
||||||
import Portofolio_V3_Create from "@/app_modules/katalog/portofolio/create/new_create";
|
import Portofolio_V3_Create from "@/app_modules/katalog/portofolio/create/new_create";
|
||||||
|
|
||||||
export default async function Page() {
|
export default function Page() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <CreatePortofolio /> */}
|
{/* <CreatePortofolio /> */}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ListDetailPortofolioNew } from "@/app_modules/katalog/portofolio";
|
import { ListDetailPortofolioNew } from "@/app_modules/katalog/portofolio";
|
||||||
|
|
||||||
export default async function Page() {
|
export default function Page() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ListDetailPortofolioNew />
|
<ListDetailPortofolioNew />
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { LayoutPortofolio_EditDataBisnis } from "@/app_modules/katalog/portofolio";
|
import { LayoutPortofolio_EditDataBisnis } from "@/app_modules/katalog/portofolio";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default function Layout({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { Portofolio_EditDataBisnis } from "@/app_modules/katalog/portofolio";
|
|
||||||
import Portofolio_V3_EditDataBisnis from "@/app_modules/katalog/portofolio/edit/data/ui_new_edit_data";
|
import Portofolio_V3_EditDataBisnis from "@/app_modules/katalog/portofolio/edit/data/ui_new_edit_data";
|
||||||
|
|
||||||
export default async function Page() {
|
export default function Page() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <Portofolio_EditDataBisnis /> */}
|
{/* <Portofolio_EditDataBisnis /> */}
|
||||||
<Portofolio_V3_EditDataBisnis/>
|
<Portofolio_V3_EditDataBisnis />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { LayoutPortofolio_EditLogoBisnis } from "@/app_modules/katalog/portofolio";
|
import { LayoutPortofolio_EditLogoBisnis } from "@/app_modules/katalog/portofolio";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default function Layout({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Portofolio_EditLogoBisnis } from "@/app_modules/katalog/portofolio";
|
import { Portofolio_EditLogoBisnis } from "@/app_modules/katalog/portofolio";
|
||||||
|
|
||||||
export default async function Page() {
|
export default function Page() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Portofolio_EditLogoBisnis />
|
<Portofolio_EditLogoBisnis />
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { LayoutPortofolio_EditMedsosBisnis } from "@/app_modules/katalog/portofolio";
|
import { LayoutPortofolio_EditMedsosBisnis } from "@/app_modules/katalog/portofolio";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default function Layout({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
import { Portofolio_EditMedsosBisnis } from "@/app_modules/katalog/portofolio";
|
import { Portofolio_EditMedsosBisnis } from "@/app_modules/katalog/portofolio";
|
||||||
import { Portofolio_geOnetMedsosById } from "@/app_modules/katalog/portofolio/fun/get/get_one_medsos_by_id";
|
|
||||||
import _ from "lodash";
|
|
||||||
|
|
||||||
export default async function Page() {
|
|
||||||
// let portoId = params.id;
|
|
||||||
// const dataMedsos = await Portofolio_geOnetMedsosById(portoId).then((res) =>
|
|
||||||
// _.omit(res, ["active", "createdAt", "updatedAt", "portofolioId"])
|
|
||||||
// );
|
|
||||||
|
|
||||||
|
export default function Page() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Portofolio_EditMedsosBisnis />
|
<Portofolio_EditMedsosBisnis />
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
|
||||||
import { PortofolioLayoutNew } from "@/app_modules/katalog/portofolio";
|
import { PortofolioLayoutNew } from "@/app_modules/katalog/portofolio";
|
||||||
|
|
||||||
export default async function Layout({ children, }: { children: any; }) {
|
export default function Layout({ children }: { children: any }) {
|
||||||
const userLoginId = await funGetUserIdByToken();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PortofolioLayoutNew userLoginId={userLoginId}>
|
<PortofolioLayoutNew>{children}</PortofolioLayoutNew>
|
||||||
{children}
|
|
||||||
</PortofolioLayoutNew>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,10 @@
|
|||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
|
||||||
import { Portofolio_UiDetailNew } from "@/app_modules/katalog/portofolio";
|
import { Portofolio_UiDetailNew } from "@/app_modules/katalog/portofolio";
|
||||||
|
|
||||||
const mapboxToken = process.env.MAPBOX_TOKEN!;
|
const mapboxToken = process.env.MAPBOX_TOKEN!;
|
||||||
export default async function Page() {
|
export default function Page() {
|
||||||
const userLoginId = await funGetUserIdByToken()
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Portofolio_UiDetailNew
|
<Portofolio_UiDetailNew mapboxToken={mapboxToken} />
|
||||||
mapboxToken={mapboxToken}
|
|
||||||
userLoginId={userLoginId}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,19 +8,11 @@ import UI_NewLayoutTamplate, {
|
|||||||
|
|
||||||
export default function CreatePortofolioLayout({
|
export default function CreatePortofolioLayout({
|
||||||
children,
|
children,
|
||||||
profileId,
|
|
||||||
}: {
|
}: {
|
||||||
children: any;
|
children: any;
|
||||||
profileId: any;
|
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <UIGlobal_LayoutTamplate
|
|
||||||
header={<UIGlobal_LayoutHeaderTamplate title="Tambah Portofolio" />}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</UIGlobal_LayoutTamplate> */}
|
|
||||||
|
|
||||||
<UI_NewLayoutTamplate>
|
<UI_NewLayoutTamplate>
|
||||||
<UI_NewHeader>
|
<UI_NewHeader>
|
||||||
<Component_Header title="Tambah Portofolio" />
|
<Component_Header title="Tambah Portofolio" />
|
||||||
|
|||||||
@@ -1,17 +1,38 @@
|
|||||||
'use client'
|
"use client";
|
||||||
import { Stack } from "@mantine/core";
|
import { Stack } from "@mantine/core";
|
||||||
import Portofolio_UiDetailDataNew from "./ui_detail_data_new";
|
import Portofolio_UiDetailDataNew from "./ui_detail_data_new";
|
||||||
import Portofolio_UiMapNew from "./ui_detail_map_new";
|
import Portofolio_UiMapNew from "./ui_detail_map_new";
|
||||||
import Portofolio_UiSosialMediaNew from "./ui_detail_media_new";
|
import Portofolio_UiSosialMediaNew from "./ui_detail_media_new";
|
||||||
import ComponentPortofolio_ButtonDeleteNew from "../component/button_delete_new";
|
import ComponentPortofolio_ButtonDeleteNew from "../component/button_delete_new";
|
||||||
|
import { apiNewGetUserIdByToken } from "@/app_modules/_global/lib/api_fetch_global";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
export default function Portofolio_UiDetailNew({
|
export default function Portofolio_UiDetailNew({
|
||||||
mapboxToken,
|
mapboxToken,
|
||||||
userLoginId,
|
|
||||||
}: {
|
}: {
|
||||||
mapboxToken: string;
|
mapboxToken: string;
|
||||||
userLoginId: string
|
|
||||||
}) {
|
}) {
|
||||||
|
const [userLoginId, setUserLoginId] = useState("");
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
onLoadDataUser();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function onLoadDataUser() {
|
||||||
|
try {
|
||||||
|
const response = await apiNewGetUserIdByToken();
|
||||||
|
if (response.success) {
|
||||||
|
setUserLoginId(response.userId);
|
||||||
|
} else {
|
||||||
|
console.error("Error get user id", response.message);
|
||||||
|
setUserLoginId("");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error get user id", error);
|
||||||
|
setUserLoginId("");
|
||||||
|
}
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack mb={"lg"}>
|
<Stack mb={"lg"}>
|
||||||
|
|||||||
@@ -5,29 +5,38 @@ import UI_NewLayoutTamplate, {
|
|||||||
UI_NewHeader,
|
UI_NewHeader,
|
||||||
} from "@/app_modules/_global/ui/V2_layout_tamplate";
|
} from "@/app_modules/_global/ui/V2_layout_tamplate";
|
||||||
import ComponentPortofolio_ButtonMoreNew from "../component/button_more_new";
|
import ComponentPortofolio_ButtonMoreNew from "../component/button_more_new";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import { apiNewGetUserIdByToken } from "@/app_modules/_global/lib/api_fetch_global";
|
||||||
|
|
||||||
export default function PortofolioLayoutNew({
|
export default function PortofolioLayoutNew({
|
||||||
children,
|
children,
|
||||||
userLoginId,
|
|
||||||
}: {
|
}: {
|
||||||
children: any;
|
children: any;
|
||||||
userLoginId: string;
|
|
||||||
}) {
|
}) {
|
||||||
|
const [userLoginId, setUserLoginId] = useState("");
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
onLoadDataUser();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function onLoadDataUser() {
|
||||||
|
try {
|
||||||
|
const response = await apiNewGetUserIdByToken();
|
||||||
|
if (response.success) {
|
||||||
|
setUserLoginId(response.userId);
|
||||||
|
} else {
|
||||||
|
console.error("Error get user id", response.message);
|
||||||
|
setUserLoginId("");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error get user id", error);
|
||||||
|
setUserLoginId("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <UIGlobal_LayoutTamplate
|
|
||||||
header={
|
|
||||||
<UIGlobal_LayoutHeaderTamplate
|
|
||||||
title="Detail Portofolio"
|
|
||||||
customButtonRight={
|
|
||||||
<ComponentPortofolio_ButtonMoreNew userLoginId={userLoginId} />
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</UIGlobal_LayoutTamplate> */}
|
|
||||||
|
|
||||||
<UI_NewLayoutTamplate>
|
<UI_NewLayoutTamplate>
|
||||||
<UI_NewHeader>
|
<UI_NewHeader>
|
||||||
<Component_Header
|
<Component_Header
|
||||||
|
|||||||
Reference in New Issue
Block a user