fix: Map
Deskripsi: - Tampilan map - Tampilan portofolio - Kirim file ke wibu storage ## No Image
This commit is contained in:
@@ -113,8 +113,6 @@ model Images {
|
|||||||
Donasi_Kabar Donasi_Kabar[]
|
Donasi_Kabar Donasi_Kabar[]
|
||||||
Donasi_PencairanDana Donasi_PencairanDana[]
|
Donasi_PencairanDana Donasi_PencairanDana[]
|
||||||
Donasi_Invoice Donasi_Invoice[]
|
Donasi_Invoice Donasi_Invoice[]
|
||||||
Image_Map BusinessMaps[] @relation("ImageMap")
|
|
||||||
Image_Pin BusinessMaps[] @relation("ImagePin")
|
|
||||||
Investasi_Invoice Investasi_Invoice[]
|
Investasi_Invoice Investasi_Invoice[]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -926,10 +924,8 @@ model BusinessMaps {
|
|||||||
authorId String?
|
authorId String?
|
||||||
Portofolio Portofolio? @relation(fields: [portofolioId], references: [id])
|
Portofolio Portofolio? @relation(fields: [portofolioId], references: [id])
|
||||||
portofolioId String? @unique
|
portofolioId String? @unique
|
||||||
ImageMap Images? @relation("ImageMap", fields: [imageMapId], references: [id], map: "MapImage")
|
imageId String?
|
||||||
imageMapId String?
|
pinId String?
|
||||||
ImagePin Images? @relation("ImagePin", fields: [imagePinId], references: [id], map: "PinImage")
|
|
||||||
imagePinId String?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kategori App
|
// Kategori App
|
||||||
|
|||||||
BIN
public/aset/global/loading.gif
Normal file
BIN
public/aset/global/loading.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
2
public/aset/global/no-image.svg
Normal file
2
public/aset/global/no-image.svg
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg fill="#000000" width="800px" height="800px" viewBox="0 0 32 32" id="icon" xmlns="http://www.w3.org/2000/svg"><defs><style>.cls-1{fill:none;}</style></defs><title>no-image</title><path d="M30,3.4141,28.5859,2,2,28.5859,3.4141,30l2-2H26a2.0027,2.0027,0,0,0,2-2V5.4141ZM26,26H7.4141l7.7929-7.793,2.3788,2.3787a2,2,0,0,0,2.8284,0L22,19l4,3.9973Zm0-5.8318-2.5858-2.5859a2,2,0,0,0-2.8284,0L19,19.1682l-2.377-2.3771L26,7.4141Z"/><path d="M6,22V19l5-4.9966,1.3733,1.3733,1.4159-1.416-1.375-1.375a2,2,0,0,0-2.8284,0L6,16.1716V6H22V4H6A2.002,2.002,0,0,0,4,6V22Z"/><rect id="_Transparent_Rectangle_" data-name="<Transparent Rectangle>" class="cls-1" width="32" height="32"/></svg>
|
||||||
|
After Width: | Height: | Size: 799 B |
BIN
public/donasi/invoice/b097f87e-c2ac-475d-8c5b-e1b234b18bd7.png
Normal file
BIN
public/donasi/invoice/b097f87e-c2ac-475d-8c5b-e1b234b18bd7.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
BIN
public/map/foto/b41cb5aa-a45d-4ac6-84ba-ad012402b70a.jpg
Normal file
BIN
public/map/foto/b41cb5aa-a45d-4ac6-84ba-ad012402b70a.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
public/map/pin/b7774485-6afc-4770-95ac-fbc0c50c4fdb.png
Normal file
BIN
public/map/pin/b7774485-6afc-4770-95ac-fbc0c50c4fdb.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.2 KiB |
@@ -1,51 +1,53 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { ComponentNotifikasi_CardSkeleton } from "@/app_modules/notifikasi/component";
|
import { Box, Center, Image, Loader, Text } from "@mantine/core";
|
||||||
import Coba_UploadFile from "@/app_modules/zCoba/ui_coba_upload_file";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { Box, Button, Flex, Paper, Stack, Title } from "@mantine/core";
|
import { useState } from "react";
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Coba_UploadFile />
|
<LoadImage
|
||||||
|
url={
|
||||||
|
"https://wibu-storage.wibudev.com/api/files/cm192febp004jkp7j2x1fgekw"
|
||||||
|
}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
return (
|
|
||||||
<Stack
|
function LoadImage({ url }: { url: string }) {
|
||||||
bg={"gray"}
|
const [ada, setAda] = useState<boolean | null>(null);
|
||||||
h={"100vh"}
|
|
||||||
style={{
|
useShallowEffect(() => {
|
||||||
position: "relative",
|
load();
|
||||||
width: "100%",
|
}, []);
|
||||||
overflow: "scroll",
|
|
||||||
}}
|
async function load() {
|
||||||
>
|
try {
|
||||||
<Box
|
const res = await fetch(url);
|
||||||
p={"md"}
|
if (res.ok) {
|
||||||
style={{
|
return setAda(true);
|
||||||
display: "flex",
|
}
|
||||||
// width: "700px",
|
setAda(false);
|
||||||
gap: "20px",
|
} catch (error) {
|
||||||
position: "relative",
|
console.log("");
|
||||||
overflowX: "scroll",
|
}
|
||||||
// scrollSnapType: "x",
|
}
|
||||||
// scrollbarGutter: "unset",
|
|
||||||
scrollbarWidth: "none",
|
if (ada === null)
|
||||||
backgroundColor: "red",
|
return (
|
||||||
}}
|
<Box w={100}>
|
||||||
>
|
<Image w={"100%"} src={"/aset/global/loading.gif"} alt="" />
|
||||||
<Flex gap={"md"} bg={"cyan"}>
|
</Box>
|
||||||
{Array.from(new Array(10), (_, i) => (
|
);
|
||||||
<Paper component={Button} w={"200px"} px={"md"} key={i}>
|
if (!ada)
|
||||||
Contoh
|
return (
|
||||||
</Paper>
|
<Image
|
||||||
))}
|
src={
|
||||||
</Flex>
|
"https://cdn.idntimes.com/content-images/community/2021/06/2318629899-0991efc170-o-cropped-56965fbaa68adf470a17cc45ea5d328d-321a5127ded916230393dbb7bf7d130e_600x400.jpg"
|
||||||
</Box>
|
}
|
||||||
|
alt=""
|
||||||
<Stack>
|
/>
|
||||||
<Title>Ini Bagian Yang Gak Ikut</Title>
|
);
|
||||||
</Stack>
|
return <Image src={url} alt="" />;
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import { portofolio_getOneById } from "@/app_modules/katalog/portofolio/fun/get/
|
|||||||
|
|
||||||
const mapboxToken = process.env.MAPBOX_TOKEN!;
|
const mapboxToken = process.env.MAPBOX_TOKEN!;
|
||||||
export default async function Page({ params }: { params: { id: string } }) {
|
export default async function Page({ params }: { params: { id: string } }) {
|
||||||
const getPorto = await portofolio_getOneById(params.id);
|
const portofolioId = params.id;
|
||||||
|
const dataPortofolio = await portofolio_getOneById(portofolioId);
|
||||||
const userLoginId = await funGetUserIdByToken();
|
const userLoginId = await funGetUserIdByToken();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <pre style={{ color: "white" }}>{JSON.stringify(getPorto, null, 2)}</pre> */}
|
|
||||||
<ViewPortofolio
|
<ViewPortofolio
|
||||||
dataPorto={getPorto as any}
|
dataPorto={dataPortofolio as any}
|
||||||
userLoginId={userLoginId as any}
|
userLoginId={userLoginId as any}
|
||||||
mapboxToken={mapboxToken}
|
mapboxToken={mapboxToken}
|
||||||
/>
|
/>
|
||||||
|
|||||||
79
src/app_modules/_global/component/comp_load_image.tsx
Normal file
79
src/app_modules/_global/component/comp_load_image.tsx
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { AspectRatio, Box, Center, Image } from "@mantine/core";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import { useState } from "react";
|
||||||
|
import ComponentGlobal_Loader from "./loader";
|
||||||
|
|
||||||
|
export function ComponentGlobal_LoadImage({
|
||||||
|
url,
|
||||||
|
maw,
|
||||||
|
h,
|
||||||
|
}: {
|
||||||
|
url: string;
|
||||||
|
maw?: number;
|
||||||
|
h?: number;
|
||||||
|
}) {
|
||||||
|
const [isImage, setIsImage] = useState<boolean | null>(null);
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
onLoadImage();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function onLoadImage() {
|
||||||
|
try {
|
||||||
|
const res = await fetch(url);
|
||||||
|
if (res.ok) {
|
||||||
|
return setIsImage(true);
|
||||||
|
}
|
||||||
|
setIsImage(false);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isImage === null)
|
||||||
|
return (
|
||||||
|
<Center h={h ? h : 250}>
|
||||||
|
<ComponentGlobal_Loader variant="dots" size={50} />
|
||||||
|
</Center>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isImage)
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Center h={250}>
|
||||||
|
<Image
|
||||||
|
alt="No Image"
|
||||||
|
maw={150}
|
||||||
|
m={"auto"}
|
||||||
|
p={"xs"}
|
||||||
|
src={"/aset/global/no-image.svg"}
|
||||||
|
/>
|
||||||
|
</Center>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{h ? (
|
||||||
|
<Image
|
||||||
|
height={h}
|
||||||
|
alt="Image"
|
||||||
|
maw={maw ? maw : 200}
|
||||||
|
m={"auto"}
|
||||||
|
p={"xs"}
|
||||||
|
src={url}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Image
|
||||||
|
alt="Image"
|
||||||
|
maw={maw ? maw : 200}
|
||||||
|
m={"auto"}
|
||||||
|
p={"xs"}
|
||||||
|
src={url}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import ComponentGlobal_BoxInformation from "./box_information";
|
|||||||
import ComponentGlobal_AvatarAndAuthorName from "./comp_author_name_and_avatar";
|
import ComponentGlobal_AvatarAndAuthorName from "./comp_author_name_and_avatar";
|
||||||
import { ComponentGlobal_BoxUploadImage } from "./comp_box_upload_image";
|
import { ComponentGlobal_BoxUploadImage } from "./comp_box_upload_image";
|
||||||
import { ComponentGlobal_CardStyles } from "./comp_card_box_and_background";
|
import { ComponentGlobal_CardStyles } from "./comp_card_box_and_background";
|
||||||
|
import { ComponentGlobal_LoadImage } from "./comp_load_image";
|
||||||
import ComponentGlobal_CardLoadingOverlay from "./comp_loading_card";
|
import ComponentGlobal_CardLoadingOverlay from "./comp_loading_card";
|
||||||
import ComponentGlobal_TampilanAngkaRatusan from "./comp_tampilan_angka_ratusan";
|
import ComponentGlobal_TampilanAngkaRatusan from "./comp_tampilan_angka_ratusan";
|
||||||
import ComponentGlobal_TampilanRupiah from "./comp_tampilan_rupiah";
|
import ComponentGlobal_TampilanRupiah from "./comp_tampilan_rupiah";
|
||||||
@@ -15,3 +16,4 @@ export { ComponentGlobal_BoxInformation };
|
|||||||
export { ComponentGlobal_InputCountDown };
|
export { ComponentGlobal_InputCountDown };
|
||||||
export { ComponentGlobal_CardStyles };
|
export { ComponentGlobal_CardStyles };
|
||||||
export { ComponentGlobal_BoxUploadImage };
|
export { ComponentGlobal_BoxUploadImage };
|
||||||
|
export { ComponentGlobal_LoadImage };
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
import { APIs } from "@/app/lib";
|
||||||
import { MODEL_MAP } from "@/app_modules/map/lib/interface";
|
import { MODEL_MAP } from "@/app_modules/map/lib/interface";
|
||||||
import {
|
import {
|
||||||
Stack,
|
|
||||||
AspectRatio,
|
AspectRatio,
|
||||||
Box,
|
Box,
|
||||||
Grid,
|
|
||||||
Image,
|
|
||||||
Text,
|
|
||||||
Button,
|
Button,
|
||||||
Center,
|
Center,
|
||||||
|
Grid,
|
||||||
|
Image,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import {
|
import {
|
||||||
IconBuildingSkyscraper,
|
IconBuildingSkyscraper,
|
||||||
IconListDetails,
|
IconListDetails,
|
||||||
IconPhoneCall,
|
|
||||||
IconMapPin,
|
IconMapPin,
|
||||||
|
IconPhoneCall,
|
||||||
IconPinned,
|
IconPinned,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -48,8 +48,8 @@ export function ComponentAdminMap_DetailDataDrawer({
|
|||||||
<Image
|
<Image
|
||||||
radius={"md"}
|
radius={"md"}
|
||||||
width={300}
|
width={300}
|
||||||
alt="Foto"
|
alt="Photo"
|
||||||
src={RouterMap.api_foto + data?.imageMapId}
|
src={APIs.GET + data?.imageId}
|
||||||
/>
|
/>
|
||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ export async function adminMap_funGetAllMaps() {
|
|||||||
isActive: true,
|
isActive: true,
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
ImagePin: true,
|
|
||||||
Portofolio: true,
|
Portofolio: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ export async function adminMap_funGetOneById({ mapId }: { mapId: string }) {
|
|||||||
id: mapId,
|
id: mapId,
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
ImageMap: true,
|
|
||||||
ImagePin: true,
|
|
||||||
Author: true,
|
Author: true,
|
||||||
Portofolio: {
|
Portofolio: {
|
||||||
include: {
|
include: {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { ComponentAdminMap_Drawer } from "../component";
|
|||||||
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
|
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
import { RouterPortofolio } from "@/app/lib/router_hipmi/router_katalog";
|
import { RouterPortofolio } from "@/app/lib/router_hipmi/router_katalog";
|
||||||
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
||||||
|
import { APIs } from "@/app/lib";
|
||||||
|
|
||||||
export function UiAdminMap_MapBoxView({
|
export function UiAdminMap_MapBoxView({
|
||||||
mapboxToken,
|
mapboxToken,
|
||||||
@@ -88,9 +89,9 @@ export function UiAdminMap_MapBoxView({
|
|||||||
backgroundColor: "white",
|
backgroundColor: "white",
|
||||||
}}
|
}}
|
||||||
src={
|
src={
|
||||||
e.imagePinId === null
|
e.pinId === null
|
||||||
? RouterPortofolio.api_logo_porto + e.Portofolio.logoId
|
? APIs.GET + e.Portofolio.logoId
|
||||||
: RouterMap.api_custom_pin + e.imagePinId
|
: APIs.GET + e.pinId
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
import { MODEL_JOB } from "../../model/interface";
|
import { MODEL_JOB } from "../../model/interface";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
|
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
|
||||||
|
import { ComponentGlobal_LoadImage } from "@/app_modules/_global/component";
|
||||||
|
|
||||||
export default function ComponentJob_DetailData({
|
export default function ComponentJob_DetailData({
|
||||||
data,
|
data,
|
||||||
@@ -44,36 +45,37 @@ export default function ComponentJob_DetailData({
|
|||||||
<Card.Section px={"xs"} pb={"lg"}>
|
<Card.Section px={"xs"} pb={"lg"}>
|
||||||
<Stack spacing={"xl"}>
|
<Stack spacing={"xl"}>
|
||||||
{data.imageId ? (
|
{data.imageId ? (
|
||||||
<Stack align="center">
|
<ComponentGlobal_LoadImage url={APIs.GET + data?.imageId} />
|
||||||
{isLoading ? (
|
|
||||||
<Paper
|
|
||||||
style={{ zIndex: 1, position: "relative" }}
|
|
||||||
w={200}
|
|
||||||
h={300}
|
|
||||||
bg={AccentColor.blackgray}
|
|
||||||
>
|
|
||||||
<Center h={"100%"}>
|
|
||||||
<ComponentGlobal_Loader size={30} variant="dots" />
|
|
||||||
</Center>
|
|
||||||
</Paper>
|
|
||||||
) : (
|
|
||||||
""
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Image
|
|
||||||
style={{ zIndex: 2, position: "relative" }}
|
|
||||||
onLoad={() => {
|
|
||||||
setIsLoading(false);
|
|
||||||
}}
|
|
||||||
onError={() => {
|
|
||||||
setIsLoading(false);
|
|
||||||
}}
|
|
||||||
alt="Image"
|
|
||||||
src={APIs.GET + data?.imageId}
|
|
||||||
maw={200}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
) : (
|
) : (
|
||||||
|
// <Stack align="center">
|
||||||
|
// {isLoading ? (
|
||||||
|
// <Paper
|
||||||
|
// style={{ zIndex: 1, position: "relative" }}
|
||||||
|
// w={200}
|
||||||
|
// h={300}
|
||||||
|
// bg={AccentColor.blackgray}
|
||||||
|
// >
|
||||||
|
// <Center h={"100%"}>
|
||||||
|
// <ComponentGlobal_Loader size={30} variant="dots" />
|
||||||
|
// </Center>
|
||||||
|
// </Paper>
|
||||||
|
// ) : (
|
||||||
|
// ""
|
||||||
|
// )}
|
||||||
|
|
||||||
|
// <Image
|
||||||
|
// style={{ zIndex: 2, position: "relative" }}
|
||||||
|
// onLoad={() => {
|
||||||
|
// setIsLoading(false);
|
||||||
|
// }}
|
||||||
|
// onError={() => {
|
||||||
|
// setIsLoading(false);
|
||||||
|
// }}
|
||||||
|
// alt="Image"
|
||||||
|
// src={APIs.GET + data?.imageId}
|
||||||
|
// maw={200}
|
||||||
|
// />
|
||||||
|
// </Stack>
|
||||||
""
|
""
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
||||||
|
import {
|
||||||
|
ComponentGlobal_NotifikasiBerhasil,
|
||||||
|
ComponentGlobal_NotifikasiGagal,
|
||||||
|
ComponentGlobal_NotifikasiPeringatan,
|
||||||
|
} from "@/app_modules/_global/notif_global";
|
||||||
|
import { Button } from "@mantine/core";
|
||||||
|
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
||||||
|
import { DIRECTORY_ID } from "@/app/lib";
|
||||||
|
import { portofolio_funEditLogoBisnisById } from "../../fun";
|
||||||
|
|
||||||
|
export function ComponentPortofolio_ButtonEditLogoBisnis({
|
||||||
|
file,
|
||||||
|
portofolioId,
|
||||||
|
}: {
|
||||||
|
file: File;
|
||||||
|
portofolioId: string;
|
||||||
|
}) {
|
||||||
|
const router = useRouter();
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
async function onUpdate() {
|
||||||
|
const uploadFileToStorage = await funGlobal_UploadToStorage({
|
||||||
|
file: file,
|
||||||
|
dirId: DIRECTORY_ID.portofolio_logo,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!uploadFileToStorage.success)
|
||||||
|
return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
|
||||||
|
|
||||||
|
const res = await portofolio_funEditLogoBisnisById({
|
||||||
|
portofolioId: portofolioId,
|
||||||
|
logoId: uploadFileToStorage.data.id,
|
||||||
|
});
|
||||||
|
if (res.status === 200) {
|
||||||
|
setLoading(true);
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
router.back();
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{file ? (
|
||||||
|
<Button
|
||||||
|
loaderPosition="center"
|
||||||
|
loading={loading ? true : false}
|
||||||
|
radius={"xl"}
|
||||||
|
onClick={() => onUpdate()}
|
||||||
|
bg={MainColor.yellow}
|
||||||
|
color="yellow"
|
||||||
|
c={"black"}
|
||||||
|
style={{
|
||||||
|
transition: "0.5s",
|
||||||
|
border: `1px solid ${AccentColor.yellow}`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Button disabled radius={"xl"}>
|
||||||
|
Simpan
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
||||||
import { MainColor } from "@/app_modules/_global/color";
|
import { MainColor } from "@/app_modules/_global/color";
|
||||||
import {
|
import {
|
||||||
|
ComponentGlobal_NotifikasiBerhasil,
|
||||||
ComponentGlobal_NotifikasiGagal,
|
ComponentGlobal_NotifikasiGagal,
|
||||||
ComponentGlobal_NotifikasiPeringatan,
|
ComponentGlobal_NotifikasiPeringatan,
|
||||||
} from "@/app_modules/_global/notif_global";
|
} from "@/app_modules/_global/notif_global";
|
||||||
@@ -42,23 +43,23 @@ export function Portofolio_ComponentButtonSelanjutnya({
|
|||||||
if (_.values(porto).includes(""))
|
if (_.values(porto).includes(""))
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
||||||
|
|
||||||
const uploadFile = await funGlobal_UploadToStorage({
|
const uploadFileToStorage = await funGlobal_UploadToStorage({
|
||||||
file: file,
|
file: file,
|
||||||
dirId: DIRECTORY_ID.portofolio_logo,
|
dirId: DIRECTORY_ID.portofolio_logo,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!uploadFile.success)
|
if (!uploadFileToStorage.success)
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
|
return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
|
||||||
|
|
||||||
const res = await funCreatePortofolio({
|
const res = await funCreatePortofolio({
|
||||||
profileId: profileId,
|
profileId: profileId,
|
||||||
data: dataPortofolio as any,
|
data: dataPortofolio as any,
|
||||||
medsos: dataMedsos,
|
medsos: dataMedsos,
|
||||||
fileId: uploadFile.data.id,
|
fileId: uploadFileToStorage.data.id,
|
||||||
});
|
});
|
||||||
if (res.status === 201) {
|
if (res.status === 201) {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
// ComponentGlobal_NotifikasiBerhasil("Berhasil disimpan");
|
ComponentGlobal_NotifikasiBerhasil("Berhasil disimpan");
|
||||||
router.replace(RouterMap.create + res.id, { scroll: false });
|
router.replace(RouterMap.create + res.id, { scroll: false });
|
||||||
} else {
|
} else {
|
||||||
ComponentGlobal_NotifikasiGagal("Gagal disimpan");
|
ComponentGlobal_NotifikasiGagal("Gagal disimpan");
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { APIs } from "@/app/lib";
|
||||||
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
||||||
import ComponentGlobal_AuthorNameOnHeader from "@/app_modules/_global/author_name_on_header";
|
import ComponentGlobal_AuthorNameOnHeader from "@/app_modules/_global/author_name_on_header";
|
||||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
|
import { ComponentGlobal_LoadImage } from "@/app_modules/_global/component";
|
||||||
import { ComponentMap_SkeletonDrawerDetailData } from "@/app_modules/map/_component";
|
import { ComponentMap_SkeletonDrawerDetailData } from "@/app_modules/map/_component";
|
||||||
import { map_funGetOneById } from "@/app_modules/map/fun/get/fun_get_one_by_id";
|
import { map_funGetOneById } from "@/app_modules/map/fun/get/fun_get_one_by_id";
|
||||||
import { MODEL_MAP } from "@/app_modules/map/lib/interface";
|
import { MODEL_MAP } from "@/app_modules/map/lib/interface";
|
||||||
@@ -14,7 +16,7 @@ import {
|
|||||||
Image,
|
Image,
|
||||||
SimpleGrid,
|
SimpleGrid,
|
||||||
Stack,
|
Stack,
|
||||||
Text
|
Text,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import {
|
import {
|
||||||
@@ -39,7 +41,7 @@ export function ComponentPortofolio_DetailDataMap({ mapId }: { mapId: any }) {
|
|||||||
setData(res);
|
setData(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!data) return <ComponentMap_SkeletonDrawerDetailData/>
|
if (!data) return <ComponentMap_SkeletonDrawerDetailData />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -59,13 +61,14 @@ export function ComponentPortofolio_DetailDataMap({ mapId }: { mapId: any }) {
|
|||||||
{ maxWidth: 600, cols: 1, spacing: "sm" },
|
{ maxWidth: 600, cols: 1, spacing: "sm" },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Image
|
<ComponentGlobal_LoadImage maw={200} url={APIs.GET + data.imageId} />
|
||||||
|
{/* <Image
|
||||||
radius={"sm"}
|
radius={"sm"}
|
||||||
mah={300}
|
mah={300}
|
||||||
maw={200}
|
maw={200}
|
||||||
alt="Foto"
|
alt="Photo"
|
||||||
src={RouterMap.api_foto + data?.imageMapId}
|
src={APIs.GET + data.imageId}
|
||||||
/>
|
/> */}
|
||||||
<Box>
|
<Box>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={2}>
|
<Grid.Col span={2}>
|
||||||
@@ -114,8 +117,6 @@ export function ComponentPortofolio_DetailDataMap({ mapId }: { mapId: any }) {
|
|||||||
<Box />
|
<Box />
|
||||||
|
|
||||||
<Group position="center">
|
<Group position="center">
|
||||||
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
bg={MainColor.yellow}
|
bg={MainColor.yellow}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import { ComponentPortofolio_ButtonEditLogoBisnis } from "./button/comp_button_edit_logo_bisnis";
|
||||||
import { Portofolio_ComponentButtonSelanjutnya } from "./button/comp_button_selanjutnya";
|
import { Portofolio_ComponentButtonSelanjutnya } from "./button/comp_button_selanjutnya";
|
||||||
|
|
||||||
export { ComponentPortofolio_DetailDataMap } from "./detail_data_drawer_map";
|
export { ComponentPortofolio_DetailDataMap } from "./detail_data_drawer_map";
|
||||||
export { Portofolio_ComponentButtonSelanjutnya };
|
export { Portofolio_ComponentButtonSelanjutnya };
|
||||||
|
export { ComponentPortofolio_ButtonEditLogoBisnis };
|
||||||
|
|||||||
@@ -1,26 +1,17 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
import {
|
import { ComponentGlobal_BoxUploadImage } from "@/app_modules/_global/component";
|
||||||
AccentColor,
|
|
||||||
MainColor,
|
|
||||||
} from "@/app_modules/_global/color/color_pallet";
|
|
||||||
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
||||||
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
|
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||||
import {
|
import { BIDANG_BISNIS_OLD } from "@/app_modules/model_global/portofolio";
|
||||||
BIDANG_BISNIS_OLD,
|
|
||||||
MODEL_PORTOFOLIO_OLD,
|
|
||||||
} from "@/app_modules/model_global/portofolio";
|
|
||||||
import {
|
import {
|
||||||
AspectRatio,
|
AspectRatio,
|
||||||
Box,
|
|
||||||
Button,
|
Button,
|
||||||
Center,
|
Center,
|
||||||
FileButton,
|
FileButton,
|
||||||
Image,
|
Image,
|
||||||
Paper,
|
|
||||||
Select,
|
Select,
|
||||||
Stack,
|
Stack,
|
||||||
Text,
|
Text,
|
||||||
@@ -30,12 +21,8 @@ import {
|
|||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { IconCamera } from "@tabler/icons-react";
|
import { IconCamera } from "@tabler/icons-react";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import funCreatePortofolio from "../fun/fun_create_portofolio";
|
|
||||||
import { Portofolio_ComponentButtonSelanjutnya } from "../component";
|
import { Portofolio_ComponentButtonSelanjutnya } from "../component";
|
||||||
import { ComponentGlobal_BoxUploadImage } from "@/app_modules/_global/component";
|
|
||||||
|
|
||||||
export default function CreatePortofolio({
|
export default function CreatePortofolio({
|
||||||
bidangBisnis,
|
bidangBisnis,
|
||||||
@@ -172,16 +159,6 @@ export default function CreatePortofolio({
|
|||||||
|
|
||||||
<Stack>
|
<Stack>
|
||||||
<ComponentGlobal_BoxInformation informasi="Upload Logo Bisnis Anda!" />
|
<ComponentGlobal_BoxInformation informasi="Upload Logo Bisnis Anda!" />
|
||||||
{/* <AspectRatio ratio={16 / 9}>
|
|
||||||
<Paper radius={"md"} withBorder>
|
|
||||||
<Image alt="Foto" src={img ? img : "/aset/no-img.png"} />
|
|
||||||
</Paper>
|
|
||||||
</AspectRatio>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{isFile ? <ComponentGlobal_ErrorInput text="Upload gambar" /> : ""} */}
|
|
||||||
|
|
||||||
<ComponentGlobal_BoxUploadImage>
|
<ComponentGlobal_BoxUploadImage>
|
||||||
{img ? (
|
{img ? (
|
||||||
<AspectRatio ratio={1 / 1} mah={265} mx={"auto"}>
|
<AspectRatio ratio={1 / 1} mah={265} mx={"auto"}>
|
||||||
|
|||||||
@@ -1,39 +1,25 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import { APIs } from "@/app/lib";
|
||||||
RouterPortofolio
|
|
||||||
} from "@/app/lib/router_hipmi/router_katalog";
|
|
||||||
import {
|
import {
|
||||||
AccentColor,
|
AccentColor,
|
||||||
MainColor,
|
MainColor,
|
||||||
} from "@/app_modules/_global/color/color_pallet";
|
} from "@/app_modules/_global/color/color_pallet";
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
import { ComponentGlobal_LoadImage } from "@/app_modules/_global/component";
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
import { Button, Center, FileButton, Image, Paper, Stack } from "@mantine/core";
|
||||||
import {
|
|
||||||
AspectRatio,
|
|
||||||
Button,
|
|
||||||
Center,
|
|
||||||
FileButton,
|
|
||||||
Image,
|
|
||||||
Paper,
|
|
||||||
Stack
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { IconCamera } from "@tabler/icons-react";
|
import { IconCamera } from "@tabler/icons-react";
|
||||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Portofolio_funEditLogoBisnisById } from "../../fun/edit/fun_edit_logo_bisnis_by_id";
|
|
||||||
import { MODEL_PORTOFOLIO } from "../../model/interface";
|
import { MODEL_PORTOFOLIO } from "../../model/interface";
|
||||||
|
import { ComponentPortofolio_ButtonEditLogoBisnis } from "../../component";
|
||||||
|
|
||||||
export default function Portofolio_EditLogoBisnis({
|
export default function Portofolio_EditLogoBisnis({
|
||||||
dataPorto,
|
dataPorto,
|
||||||
}: {
|
}: {
|
||||||
dataPorto: MODEL_PORTOFOLIO;
|
dataPorto: MODEL_PORTOFOLIO;
|
||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
|
||||||
const [file, setFile] = useState<File | null>(null);
|
const [file, setFile] = useState<File | null>(null);
|
||||||
const [image, setImage] = useState<any | null>(null);
|
const [img, setImg] = useState<any | null>(null);
|
||||||
const [loading, setLoading] = useState(false);
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack spacing={"xl"} px={"sm"}>
|
<Stack spacing={"xl"} px={"sm"}>
|
||||||
@@ -47,17 +33,13 @@ export default function Portofolio_EditLogoBisnis({
|
|||||||
color: "white",
|
color: "white",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Stack>
|
<Stack align="center">
|
||||||
<AspectRatio ratio={1 / 1}>
|
{img ? (
|
||||||
<Image
|
<Image maw={250} alt="Image" src={img} />
|
||||||
alt="Foto"
|
) : (
|
||||||
src={
|
<ComponentGlobal_LoadImage url={APIs.GET + dataPorto.logoId} />
|
||||||
image
|
)}
|
||||||
? image
|
|
||||||
: RouterPortofolio.api_logo_porto + `${dataPorto.logoId}`
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</AspectRatio>
|
|
||||||
<Center>
|
<Center>
|
||||||
<FileButton
|
<FileButton
|
||||||
onChange={async (files: any | null) => {
|
onChange={async (files: any | null) => {
|
||||||
@@ -65,9 +47,7 @@ export default function Portofolio_EditLogoBisnis({
|
|||||||
const buffer = URL.createObjectURL(
|
const buffer = URL.createObjectURL(
|
||||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||||
);
|
);
|
||||||
// console.log(buffer, "ini buffer");
|
setImg(buffer);
|
||||||
// console.log(files, " ini file");
|
|
||||||
setImage(buffer);
|
|
||||||
setFile(files);
|
setFile(files);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
@@ -91,54 +71,11 @@ export default function Portofolio_EditLogoBisnis({
|
|||||||
</Center>
|
</Center>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Paper>
|
</Paper>
|
||||||
|
<ComponentPortofolio_ButtonEditLogoBisnis
|
||||||
{file ? (
|
file={file as any}
|
||||||
<Button
|
portofolioId={dataPorto.id}
|
||||||
radius={"xl"}
|
/>
|
||||||
onClick={() =>
|
|
||||||
// onUpdate(router, dataPorto.id, file as any, setLoading)
|
|
||||||
console.log("apa")
|
|
||||||
}
|
|
||||||
bg={MainColor.yellow}
|
|
||||||
color="yellow"
|
|
||||||
c={"black"}
|
|
||||||
style={{
|
|
||||||
transition: "0.5s",
|
|
||||||
border: `1px solid ${AccentColor.yellow}`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Simpan
|
|
||||||
</Button>
|
|
||||||
) : (
|
|
||||||
<Button
|
|
||||||
disabled
|
|
||||||
radius={"xl"}
|
|
||||||
|
|
||||||
>
|
|
||||||
Simpan
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onUpdate(
|
|
||||||
router: AppRouterInstance,
|
|
||||||
portoId: string,
|
|
||||||
file: FormData,
|
|
||||||
setLoading: any
|
|
||||||
) {
|
|
||||||
const gambar = new FormData();
|
|
||||||
gambar.append("file", file as any);
|
|
||||||
|
|
||||||
await Portofolio_funEditLogoBisnisById(portoId, gambar).then((res) => {
|
|
||||||
if (res.status === 200) {
|
|
||||||
setLoading(true);
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
|
||||||
router.back();
|
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,41 +1,21 @@
|
|||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
import prisma from "@/app/lib/prisma";
|
import prisma from "@/app/lib/prisma";
|
||||||
import _ from "lodash";
|
|
||||||
import { v4 } from "uuid";
|
|
||||||
import fs from "fs";
|
|
||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
|
|
||||||
export async function Portofolio_funEditLogoBisnisById(
|
export async function portofolio_funEditLogoBisnisById({
|
||||||
portoId: string,
|
portofolioId,
|
||||||
file: FormData
|
logoId,
|
||||||
) {
|
}: {
|
||||||
const gambar: any = file.get("file");
|
portofolioId: string;
|
||||||
const fileName = gambar.name;
|
logoId: string;
|
||||||
const fileExtension = _.lowerCase(gambar.name.split(".").pop());
|
}) {
|
||||||
const randomNameFile = v4(fileName) + "." + fileExtension;
|
|
||||||
|
|
||||||
const upload = await prisma.images.create({
|
|
||||||
data: {
|
|
||||||
url: randomNameFile,
|
|
||||||
label: "PORTOFOLIO_LOGO",
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
url: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!upload) return { status: 400, message: "Gagal upload gambar" };
|
|
||||||
const upload_toFolder = Buffer.from(await gambar.arrayBuffer());
|
|
||||||
fs.writeFileSync(`./public/portofolio/logo/${upload.url}`, upload_toFolder);
|
|
||||||
|
|
||||||
const updatePorto = await prisma.portofolio.update({
|
const updatePorto = await prisma.portofolio.update({
|
||||||
where: {
|
where: {
|
||||||
id: portoId,
|
id: portofolioId,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
logoId: upload.id,
|
logoId: logoId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ export async function portofolio_getOneById(portoId: string) {
|
|||||||
id: portoId,
|
id: portoId,
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
Logo: true,
|
|
||||||
MasterBidangBisnis: {
|
MasterBidangBisnis: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
@@ -31,8 +30,6 @@ export async function portofolio_getOneById(portoId: string) {
|
|||||||
BusinessMaps: {
|
BusinessMaps: {
|
||||||
include: {
|
include: {
|
||||||
Author: true,
|
Author: true,
|
||||||
ImageMap: true,
|
|
||||||
ImagePin: true,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
3
src/app_modules/katalog/portofolio/fun/index.ts
Normal file
3
src/app_modules/katalog/portofolio/fun/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { portofolio_funEditLogoBisnisById } from "./edit/fun_edit_logo_bisnis_by_id";
|
||||||
|
|
||||||
|
export { portofolio_funEditLogoBisnisById };
|
||||||
@@ -1,29 +1,30 @@
|
|||||||
import {
|
import { APIs } from "@/app/lib";
|
||||||
Paper,
|
|
||||||
Title,
|
|
||||||
Stack,
|
|
||||||
Grid,
|
|
||||||
Text,
|
|
||||||
SimpleGrid,
|
|
||||||
Box,
|
|
||||||
AspectRatio,
|
|
||||||
Image,
|
|
||||||
Group,
|
|
||||||
Divider,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import {
|
|
||||||
IconBuildingSkyscraper,
|
|
||||||
IconPhoneCall,
|
|
||||||
IconMapPin,
|
|
||||||
IconListDetails,
|
|
||||||
IconPinned,
|
|
||||||
} from "@tabler/icons-react";
|
|
||||||
import { MODEL_PORTOFOLIO } from "../model/interface";
|
|
||||||
import {
|
import {
|
||||||
AccentColor,
|
AccentColor,
|
||||||
MainColor,
|
MainColor,
|
||||||
} from "@/app_modules/_global/color/color_pallet";
|
} from "@/app_modules/_global/color/color_pallet";
|
||||||
import { RouterPortofolio } from "@/app/lib/router_hipmi/router_katalog";
|
import {
|
||||||
|
AspectRatio,
|
||||||
|
Box,
|
||||||
|
Divider,
|
||||||
|
Grid,
|
||||||
|
Group,
|
||||||
|
Image,
|
||||||
|
Paper,
|
||||||
|
SimpleGrid,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
|
Title,
|
||||||
|
} from "@mantine/core";
|
||||||
|
import {
|
||||||
|
IconBuildingSkyscraper,
|
||||||
|
IconListDetails,
|
||||||
|
IconMapPin,
|
||||||
|
IconPhoneCall,
|
||||||
|
IconPinned,
|
||||||
|
} from "@tabler/icons-react";
|
||||||
|
import { MODEL_PORTOFOLIO } from "../model/interface";
|
||||||
|
import { ComponentGlobal_LoadImage } from "@/app_modules/_global/component";
|
||||||
|
|
||||||
export function Portofolio_UiDetailData({
|
export function Portofolio_UiDetailData({
|
||||||
dataPorto,
|
dataPorto,
|
||||||
@@ -47,7 +48,9 @@ export function Portofolio_UiDetailData({
|
|||||||
<Title order={6}>Data Bisnis</Title>
|
<Title order={6}>Data Bisnis</Title>
|
||||||
<Text color={MainColor.yellow} fw={"bold"}>
|
<Text color={MainColor.yellow} fw={"bold"}>
|
||||||
id: {" "}
|
id: {" "}
|
||||||
<Text span inherit>#{dataPorto.id_Portofolio}</Text>
|
<Text span inherit>
|
||||||
|
#{dataPorto.id_Portofolio}
|
||||||
|
</Text>
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
<Stack>
|
<Stack>
|
||||||
@@ -61,17 +64,19 @@ export function Portofolio_UiDetailData({
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Box>
|
<Box>
|
||||||
<AspectRatio ratio={1 / 1} mah={200}>
|
<Paper>
|
||||||
<Paper>
|
<ComponentGlobal_LoadImage url={APIs.GET + dataPorto.logoId}/>
|
||||||
|
{/* <AspectRatio ratio={1 / 1} mah={250} mx={"auto"}>
|
||||||
<Image
|
<Image
|
||||||
width={200}
|
// style={{ maxHeight: 200, margin: "auto", padding: "5px" }}
|
||||||
alt="Foto"
|
alt="Foto"
|
||||||
src={
|
h={200}
|
||||||
RouterPortofolio.api_logo_porto + `${dataPorto?.logoId}`
|
m={"auto"}
|
||||||
}
|
p={"xs"}
|
||||||
|
src={APIs.GET + dataPorto.logoId }
|
||||||
/>
|
/>
|
||||||
</Paper>
|
</AspectRatio> */}
|
||||||
</AspectRatio>
|
</Paper>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box>
|
<Box>
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { RouterPortofolio } from "@/app/lib/router_hipmi/router_katalog";
|
import { APIs } from "@/app/lib";
|
||||||
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
|
||||||
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
|
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
import { ComponentMap_DrawerDetailData } from "@/app_modules/map/_component";
|
import { ComponentMap_DrawerDetailData } from "@/app_modules/map/_component";
|
||||||
import { defaultMapZoom } from "@/app_modules/map/lib/default_lat_long";
|
import { defaultMapZoom } from "@/app_modules/map/lib/default_lat_long";
|
||||||
import { MODEL_MAP } from "@/app_modules/map/lib/interface";
|
import { MODEL_MAP } from "@/app_modules/map/lib/interface";
|
||||||
import { Image, Paper, Stack, Title } from "@mantine/core";
|
import { Avatar, Image, Paper, Stack, Title } from "@mantine/core";
|
||||||
import "mapbox-gl/dist/mapbox-gl.css";
|
import "mapbox-gl/dist/mapbox-gl.css";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import {
|
import {
|
||||||
@@ -17,7 +16,7 @@ import {
|
|||||||
ScaleControl,
|
ScaleControl,
|
||||||
} from "react-map-gl";
|
} from "react-map-gl";
|
||||||
import { ComponentPortofolio_DetailDataMap } from "../component";
|
import { ComponentPortofolio_DetailDataMap } from "../component";
|
||||||
import { MODEL_LOGO, MODEL_PORTOFOLIO } from "../model/interface";
|
import { MODEL_PORTOFOLIO } from "../model/interface";
|
||||||
|
|
||||||
export function Portofolio_UiMap({
|
export function Portofolio_UiMap({
|
||||||
mapboxToken,
|
mapboxToken,
|
||||||
@@ -45,7 +44,7 @@ export function Portofolio_UiMap({
|
|||||||
<MapView
|
<MapView
|
||||||
data={data.BusinessMaps}
|
data={data.BusinessMaps}
|
||||||
mapboxToken={mapboxToken}
|
mapboxToken={mapboxToken}
|
||||||
dataLogo={data.Logo}
|
logoId={data.logoId}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Paper>
|
</Paper>
|
||||||
@@ -55,11 +54,11 @@ export function Portofolio_UiMap({
|
|||||||
function MapView({
|
function MapView({
|
||||||
mapboxToken,
|
mapboxToken,
|
||||||
data,
|
data,
|
||||||
dataLogo,
|
logoId,
|
||||||
}: {
|
}: {
|
||||||
mapboxToken: string;
|
mapboxToken: string;
|
||||||
data: MODEL_MAP;
|
data: MODEL_MAP;
|
||||||
dataLogo: MODEL_LOGO;
|
logoId: string;
|
||||||
}) {
|
}) {
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
const [openDrawer, setOpenDrawer] = useState(false);
|
||||||
|
|
||||||
@@ -98,17 +97,14 @@ function MapView({
|
|||||||
pitchAlignment="auto"
|
pitchAlignment="auto"
|
||||||
>
|
>
|
||||||
<Stack spacing={0} align="center">
|
<Stack spacing={0} align="center">
|
||||||
<Image
|
<Avatar
|
||||||
width={"100%"}
|
|
||||||
alt="image"
|
|
||||||
src={
|
src={
|
||||||
data.ImagePin === null
|
data.pinId === null ? APIs.GET + logoId : APIs.GET + data.pinId
|
||||||
? RouterPortofolio.api_logo_porto + dataLogo.id
|
|
||||||
: RouterMap.api_custom_pin + data.ImagePin.id
|
|
||||||
}
|
}
|
||||||
radius={"xl"}
|
alt="Logo"
|
||||||
style={{
|
style={{
|
||||||
border: `2px solid ${AccentColor.softblue}`,
|
border: `2px solid ${AccentColor.softblue}`,
|
||||||
|
backgroundColor: "white",
|
||||||
borderRadius: "100%",
|
borderRadius: "100%",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ export default function Portofolio_UiDetail({
|
|||||||
<Stack mb={"lg"}>
|
<Stack mb={"lg"}>
|
||||||
<Portofolio_UiDetailData dataPorto={dataPorto} />
|
<Portofolio_UiDetailData dataPorto={dataPorto} />
|
||||||
<Portofolio_UiMap mapboxToken={mapboxToken} data={dataPorto} />
|
<Portofolio_UiMap mapboxToken={mapboxToken} data={dataPorto} />
|
||||||
{/* <Portofolio_UiDetailLogo dataPorto={dataPorto} /> */}
|
|
||||||
<Portofolio_UiSosialMedia dataPorto={dataPorto} />
|
<Portofolio_UiSosialMedia dataPorto={dataPorto} />
|
||||||
|
|
||||||
<ComponentPortofolio_ButtonDelete
|
<ComponentPortofolio_ButtonDelete
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { MainColor } from "@/app_modules/_global/color";
|
||||||
|
import {
|
||||||
|
ComponentGlobal_NotifikasiBerhasil,
|
||||||
|
ComponentGlobal_NotifikasiGagal,
|
||||||
|
ComponentGlobal_NotifikasiPeringatan,
|
||||||
|
} from "@/app_modules/_global/notif_global";
|
||||||
|
import { Button } from "@mantine/core";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { map_funCreatePin } from "../../fun/create/fun_create_pin";
|
||||||
|
import { DIRECTORY_ID } from "@/app/lib";
|
||||||
|
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
||||||
|
|
||||||
|
export function ComponentMap_ButtonSavePin({
|
||||||
|
namePin,
|
||||||
|
lat,
|
||||||
|
long,
|
||||||
|
portofolioId,
|
||||||
|
file,
|
||||||
|
}: {
|
||||||
|
namePin: string;
|
||||||
|
lat: string;
|
||||||
|
long: string;
|
||||||
|
portofolioId: string;
|
||||||
|
file: File;
|
||||||
|
}) {
|
||||||
|
const router = useRouter();
|
||||||
|
async function onSavePin() {
|
||||||
|
const uploadFileToStorage = await funGlobal_UploadToStorage({
|
||||||
|
file: file,
|
||||||
|
dirId: DIRECTORY_ID.map_image,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!uploadFileToStorage.success)
|
||||||
|
return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
|
||||||
|
|
||||||
|
const res = await map_funCreatePin({
|
||||||
|
data: {
|
||||||
|
latitude: lat as any,
|
||||||
|
longitude: long as any,
|
||||||
|
namePin: namePin as any,
|
||||||
|
imageId: uploadFileToStorage.data.id,
|
||||||
|
Portofolio: {
|
||||||
|
create: { id: portofolioId } as any,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
res.status === 200
|
||||||
|
? (ComponentGlobal_NotifikasiBerhasil(res.message), router.back())
|
||||||
|
: ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
my={"xl"}
|
||||||
|
style={{ transition: "0.5s" }}
|
||||||
|
disabled={namePin === "" || file === null ? true : false}
|
||||||
|
radius={"xl"}
|
||||||
|
bg={MainColor.yellow}
|
||||||
|
color="yellow"
|
||||||
|
c={"black"}
|
||||||
|
onClick={() => onSavePin()}
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { MainColor } from "@/app_modules/_global/color";
|
||||||
|
import {
|
||||||
|
ComponentGlobal_NotifikasiBerhasil,
|
||||||
|
ComponentGlobal_NotifikasiGagal,
|
||||||
|
ComponentGlobal_NotifikasiPeringatan,
|
||||||
|
} from "@/app_modules/_global/notif_global";
|
||||||
|
import { Button } from "@mantine/core";
|
||||||
|
|
||||||
|
import { map_funEditMap } from "../../fun/edit/fun_edit_map";
|
||||||
|
import { MODEL_MAP } from "../../lib/interface";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { DIRECTORY_ID } from "@/app/lib";
|
||||||
|
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
|
export function ComponentMap_ButtonUpdateDataMap({
|
||||||
|
data,
|
||||||
|
file,
|
||||||
|
}: {
|
||||||
|
data: MODEL_MAP;
|
||||||
|
file: File;
|
||||||
|
}) {
|
||||||
|
const router = useRouter();
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
async function onSavePin() {
|
||||||
|
if (file !== null) {
|
||||||
|
const uploadFileToStorage = await funGlobal_UploadToStorage({
|
||||||
|
file: file,
|
||||||
|
dirId: DIRECTORY_ID.map_image,
|
||||||
|
});
|
||||||
|
if (!uploadFileToStorage.success)
|
||||||
|
return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
|
||||||
|
|
||||||
|
const res = await map_funEditMap({
|
||||||
|
data: data,
|
||||||
|
fileId: uploadFileToStorage.data.id,
|
||||||
|
});
|
||||||
|
res.status === 200
|
||||||
|
? (ComponentGlobal_NotifikasiBerhasil(res.message), router.back())
|
||||||
|
: ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
} else {
|
||||||
|
const res = await map_funEditMap({
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
res.status === 200
|
||||||
|
? (ComponentGlobal_NotifikasiBerhasil(res.message), router.back())
|
||||||
|
: ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
setIsLoading(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
loaderPosition="center"
|
||||||
|
loading={isLoading}
|
||||||
|
mb={"xl"}
|
||||||
|
style={{ transition: "0.5s" }}
|
||||||
|
disabled={data.namePin === "" ? true : false}
|
||||||
|
radius={"xl"}
|
||||||
|
bg={MainColor.yellow}
|
||||||
|
color="yellow"
|
||||||
|
c={"black"}
|
||||||
|
onClick={() => onSavePin()}
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -25,6 +25,8 @@ import { useState } from "react";
|
|||||||
import { map_funGetOneById } from "../fun/get/fun_get_one_by_id";
|
import { map_funGetOneById } from "../fun/get/fun_get_one_by_id";
|
||||||
import { MODEL_MAP } from "../lib/interface";
|
import { MODEL_MAP } from "../lib/interface";
|
||||||
import { ComponentMap_SkeletonDrawerDetailData } from "./skeleton_detail_data";
|
import { ComponentMap_SkeletonDrawerDetailData } from "./skeleton_detail_data";
|
||||||
|
import { APIs } from "@/app/lib";
|
||||||
|
import { ComponentGlobal_LoadImage } from "@/app_modules/_global/component";
|
||||||
|
|
||||||
export function ComponentMap_DetailData({ mapId }: { mapId: any }) {
|
export function ComponentMap_DetailData({ mapId }: { mapId: any }) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -59,13 +61,8 @@ export function ComponentMap_DetailData({ mapId }: { mapId: any }) {
|
|||||||
{ maxWidth: 600, cols: 1, spacing: "sm" },
|
{ maxWidth: 600, cols: 1, spacing: "sm" },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Image
|
<ComponentGlobal_LoadImage url={APIs.GET + data?.imageId} />
|
||||||
radius={"sm"}
|
{/* <Image radius={"sm"} mah={300} maw={200} alt="Photo" src={} /> */}
|
||||||
mah={300}
|
|
||||||
maw={200}
|
|
||||||
alt="Foto"
|
|
||||||
src={RouterMap.api_foto + data?.imageMapId}
|
|
||||||
/>
|
|
||||||
<Box>
|
<Box>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={2}>
|
<Grid.Col span={2}>
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
import { ComponentMap_ButtonSavePin } from "./button/comp_button_save_pin";
|
||||||
|
import { ComponentMap_ButtonUpdateDataMap } from "./button/comp_button_update_data_map";
|
||||||
|
|
||||||
export { ComponentMap_Header } from "./header";
|
export { ComponentMap_Header } from "./header";
|
||||||
export { ComponentMap_DrawerDetailData } from "./drawer";
|
export { ComponentMap_DrawerDetailData } from "./drawer";
|
||||||
export { ComponentMap_SkeletonDrawerDetailData } from "./skeleton_detail_data";
|
export { ComponentMap_SkeletonDrawerDetailData } from "./skeleton_detail_data";
|
||||||
|
export { ComponentMap_ButtonSavePin };
|
||||||
|
export { ComponentMap_ButtonUpdateDataMap };
|
||||||
|
|||||||
@@ -3,42 +3,24 @@
|
|||||||
import prisma from "@/app/lib/prisma";
|
import prisma from "@/app/lib/prisma";
|
||||||
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
import fs from "fs";
|
import { Prisma } from "@prisma/client";
|
||||||
import _ from "lodash";
|
|
||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
import { v4 } from "uuid";
|
|
||||||
|
|
||||||
export async function map_funCreatePin({ data }: { data: any }) {
|
export async function map_funCreatePin({
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
data: Prisma.BusinessMapsCreateInput;
|
||||||
|
}) {
|
||||||
const userLoginId = await funGetUserIdByToken();
|
const userLoginId = await funGetUserIdByToken();
|
||||||
|
|
||||||
const gambar: any = data.gambar.get("file");
|
|
||||||
const fileName = gambar.name;
|
|
||||||
const fileExtension = _.lowerCase(gambar.name.split(".").pop());
|
|
||||||
const fRandomName = v4(fileName) + "." + fileExtension;
|
|
||||||
|
|
||||||
const uploadImage = await prisma.images.create({
|
|
||||||
data: {
|
|
||||||
url: fRandomName,
|
|
||||||
label: "MAP_PHOTO",
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
url: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!uploadImage) return { status: 400, message: "Gagal upload foto lokasi" };
|
|
||||||
const upload_Folder = Buffer.from(await gambar.arrayBuffer());
|
|
||||||
fs.writeFileSync(`./public/map/foto/${uploadImage.url}`, upload_Folder);
|
|
||||||
|
|
||||||
const create = await prisma.businessMaps.create({
|
const create = await prisma.businessMaps.create({
|
||||||
data: {
|
data: {
|
||||||
latitude: data.lat,
|
latitude: data.latitude,
|
||||||
longitude: data.long,
|
longitude: data.longitude,
|
||||||
namePin: data.namePin,
|
namePin: data.namePin,
|
||||||
portofolioId: data?.portofolioId,
|
portofolioId: data.Portofolio?.create?.id,
|
||||||
authorId: userLoginId,
|
authorId: userLoginId,
|
||||||
imageMapId: uploadImage.id,
|
imageId: data.imageId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,50 +1,26 @@
|
|||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
import prisma from "@/app/lib/prisma";
|
import prisma from "@/app/lib/prisma";
|
||||||
import _ from "lodash";
|
|
||||||
import { v4 } from "uuid";
|
|
||||||
import fs from "fs";
|
|
||||||
import { revalidatePath } from "next/cache";
|
|
||||||
import { RouterPortofolio } from "@/app/lib/router_hipmi/router_katalog";
|
import { RouterPortofolio } from "@/app/lib/router_hipmi/router_katalog";
|
||||||
|
import { revalidatePath } from "next/cache";
|
||||||
|
|
||||||
export async function map_funCustomPinMap({
|
export async function map_funCustomPinMap({
|
||||||
mapId,
|
mapId,
|
||||||
file,
|
fileId,
|
||||||
}: {
|
}: {
|
||||||
mapId: string;
|
mapId: string;
|
||||||
file: FormData;
|
fileId: string;
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
const newPin: any = file.get("file");
|
|
||||||
const fileName = newPin.name;
|
|
||||||
const fileExtension = _.lowerCase(newPin.name.split(".").pop());
|
|
||||||
const fileRandomName = v4(fileName) + "." + fileExtension;
|
|
||||||
|
|
||||||
const uploadPin = await prisma.images.create({
|
|
||||||
data: {
|
|
||||||
url: fileRandomName,
|
|
||||||
label: "MAP_CUSTOM_PIN",
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
url: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!uploadPin) return { status: 400, message: "Gagal upload foto lokasi" };
|
|
||||||
const upload_Folder = Buffer.from(await newPin.arrayBuffer());
|
|
||||||
fs.writeFileSync(`./public/map/pin/${uploadPin.url}`, upload_Folder);
|
|
||||||
|
|
||||||
const updt = await prisma.businessMaps.update({
|
const updt = await prisma.businessMaps.update({
|
||||||
where: {
|
where: {
|
||||||
id: mapId,
|
id: mapId,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
imagePinId: uploadPin.id,
|
pinId: fileId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!updt) return { status: 400, message: "Gagal update pin" };
|
if (!updt) return { status: 400, message: "Gagal update pin" };
|
||||||
revalidatePath(RouterPortofolio.main_detail)
|
revalidatePath(RouterPortofolio.main_detail);
|
||||||
return { status: 200, message: "Berhasil update pin" };
|
return { status: 200, message: "Berhasil update pin" };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +1,18 @@
|
|||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
import _, { update } from "lodash";
|
|
||||||
import { MODEL_MAP } from "../../lib/interface";
|
|
||||||
import { v4 } from "uuid";
|
|
||||||
import prisma from "@/app/lib/prisma";
|
import prisma from "@/app/lib/prisma";
|
||||||
import fs from "fs";
|
|
||||||
import { revalidatePath } from "next/cache";
|
|
||||||
import { RouterPortofolio } from "@/app/lib/router_hipmi/router_katalog";
|
import { RouterPortofolio } from "@/app/lib/router_hipmi/router_katalog";
|
||||||
|
import { revalidatePath } from "next/cache";
|
||||||
|
import { MODEL_MAP } from "../../lib/interface";
|
||||||
|
|
||||||
export async function map_funEditMap({
|
export async function map_funEditMap({
|
||||||
data,
|
data,
|
||||||
file,
|
fileId,
|
||||||
|
|
||||||
}: {
|
}: {
|
||||||
data: MODEL_MAP;
|
data: MODEL_MAP;
|
||||||
file: FormData;
|
fileId?: string;
|
||||||
}) {
|
}) {
|
||||||
// console.log(data, file);
|
if (fileId === undefined || fileId === null) {
|
||||||
|
|
||||||
const gambar: any = file.get("file");
|
|
||||||
if (gambar !== "null") {
|
|
||||||
const fileName = gambar.name;
|
|
||||||
const fileExtension = _.lowerCase(gambar.name.split(".").pop());
|
|
||||||
const fRandomName = v4(fileName) + "." + fileExtension;
|
|
||||||
|
|
||||||
const uploadImage = await prisma.images.create({
|
|
||||||
data: {
|
|
||||||
url: fRandomName,
|
|
||||||
label: "MAP_PHOTO",
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
url: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!uploadImage)
|
|
||||||
return { status: 400, message: "Gagal upload foto lokasi" };
|
|
||||||
const upload_Folder = Buffer.from(await gambar.arrayBuffer());
|
|
||||||
fs.writeFileSync(`./public/map/foto/${uploadImage.url}`, upload_Folder);
|
|
||||||
|
|
||||||
const updt = await prisma.businessMaps.update({
|
const updt = await prisma.businessMaps.update({
|
||||||
where: {
|
where: {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
@@ -48,25 +21,25 @@ export async function map_funEditMap({
|
|||||||
latitude: data.latitude,
|
latitude: data.latitude,
|
||||||
longitude: data.longitude,
|
longitude: data.longitude,
|
||||||
namePin: data.namePin,
|
namePin: data.namePin,
|
||||||
imageMapId: uploadImage.id,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!updt) return { status: 400, message: "Gagal update data" };
|
if (!updt) return { status: 400, message: "Gagal update data" };
|
||||||
|
revalidatePath(RouterPortofolio.main_detail);
|
||||||
|
return { status: 200, message: "Berhasil update" };
|
||||||
|
} else {
|
||||||
|
const updt = await prisma.businessMaps.update({
|
||||||
|
where: {
|
||||||
|
id: data.id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
latitude: data.latitude,
|
||||||
|
longitude: data.longitude,
|
||||||
|
namePin: data.namePin,
|
||||||
|
imageId: fileId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!updt) return { status: 400, message: "Gagal update data" };
|
||||||
|
revalidatePath(RouterPortofolio.main_detail);
|
||||||
|
return { status: 200, message: "Berhasil update" };
|
||||||
}
|
}
|
||||||
|
|
||||||
const updt = await prisma.businessMaps.update({
|
|
||||||
where: {
|
|
||||||
id: data.id,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
latitude: data.latitude,
|
|
||||||
longitude: data.longitude,
|
|
||||||
namePin: data.namePin,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (!updt) return { status: 400, message: "Gagal update data" };
|
|
||||||
|
|
||||||
revalidatePath(RouterPortofolio.main_detail);
|
|
||||||
return { status: 200, message: "Berhasil update" };
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export async function map_funGetOneById({ mapId }: { mapId: string }) {
|
|||||||
where: {
|
where: {
|
||||||
id: mapId,
|
id: mapId,
|
||||||
},
|
},
|
||||||
select: {
|
include: {
|
||||||
Author: {
|
Author: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
@@ -20,15 +20,6 @@ export async function map_funGetOneById({ mapId }: { mapId: string }) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
id: true,
|
|
||||||
isActive: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
namePin: true,
|
|
||||||
latitude: true,
|
|
||||||
longitude: true,
|
|
||||||
authorId: true,
|
|
||||||
imageMapId: true,
|
|
||||||
Portofolio: {
|
Portofolio: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
|||||||
@@ -12,12 +12,9 @@ export async function map_funGetOneBusinessMapByPortofolioId({
|
|||||||
portofolioId: portofolioId,
|
portofolioId: portofolioId,
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
ImageMap: true,
|
|
||||||
ImagePin: true,
|
|
||||||
Portofolio: {
|
Portofolio: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
Logo: true,
|
|
||||||
logoId: true
|
logoId: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ export interface MODEL_MAP {
|
|||||||
authorId: string;
|
authorId: string;
|
||||||
Author: MODEL_USER;
|
Author: MODEL_USER;
|
||||||
portofolioId: string;
|
portofolioId: string;
|
||||||
Portofolio: MODEL_PORTOFOLIO
|
Portofolio: MODEL_PORTOFOLIO;
|
||||||
imageMapId: string
|
imageId: string;
|
||||||
ImageMap: any
|
pinId: string;
|
||||||
imagePinId: string
|
|
||||||
ImagePin: any
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,10 @@ import {
|
|||||||
AccentColor,
|
AccentColor,
|
||||||
MainColor,
|
MainColor,
|
||||||
} from "@/app_modules/_global/color/color_pallet";
|
} from "@/app_modules/_global/color/color_pallet";
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
import { ComponentGlobal_BoxUploadImage } from "@/app_modules/_global/component";
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||||
import {
|
import {
|
||||||
AspectRatio,
|
AspectRatio,
|
||||||
Box,
|
|
||||||
Button,
|
Button,
|
||||||
Center,
|
Center,
|
||||||
FileButton,
|
FileButton,
|
||||||
@@ -22,7 +20,6 @@ import {
|
|||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { IconCamera } from "@tabler/icons-react";
|
import { IconCamera } from "@tabler/icons-react";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import Map, {
|
import Map, {
|
||||||
AttributionControl,
|
AttributionControl,
|
||||||
@@ -30,7 +27,7 @@ import Map, {
|
|||||||
NavigationControl,
|
NavigationControl,
|
||||||
ScaleControl,
|
ScaleControl,
|
||||||
} from "react-map-gl";
|
} from "react-map-gl";
|
||||||
import { map_funCreatePin } from "../fun/create/fun_create_pin";
|
import { ComponentMap_ButtonSavePin } from "../_component";
|
||||||
import { defaultLatLong, defaultMapZoom } from "../lib/default_lat_long";
|
import { defaultLatLong, defaultMapZoom } from "../lib/default_lat_long";
|
||||||
|
|
||||||
export function UiMap_CreatePin({
|
export function UiMap_CreatePin({
|
||||||
@@ -116,52 +113,26 @@ export function UiMap_CreatePin({
|
|||||||
</Paper>
|
</Paper>
|
||||||
|
|
||||||
<Stack>
|
<Stack>
|
||||||
{img ? (
|
<ComponentGlobal_BoxUploadImage>
|
||||||
<AspectRatio ratio={1 / 1} mah={300}>
|
{img ? (
|
||||||
<Paper
|
<AspectRatio ratio={1 / 1} mah={265} mx={"auto"}>
|
||||||
style={{
|
|
||||||
border: `2px solid ${AccentColor.blue}`,
|
|
||||||
backgroundColor: AccentColor.darkblue,
|
|
||||||
padding: "10px",
|
|
||||||
borderRadius: "10px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Image
|
<Image
|
||||||
radius={"sm"}
|
style={{ maxHeight: 250, margin: "auto", padding: "5px" }}
|
||||||
alt="Foto"
|
alt="Foto"
|
||||||
src={img ? img : "/aset/no-img.png"}
|
height={250}
|
||||||
maw={200}
|
src={img}
|
||||||
/>
|
/>
|
||||||
</Paper>
|
</AspectRatio>
|
||||||
</AspectRatio>
|
) : (
|
||||||
) : (
|
<Stack spacing={5} justify="center" align="center" h={"100%"}>
|
||||||
<AspectRatio ratio={1 / 1} mah={300}>
|
<Title order={3}>Foto Lokasi Bisnis</Title>
|
||||||
<Paper
|
<Text fs={"italic"} fz={10} align="center">
|
||||||
style={{
|
Upload foto lokasi bisnis anda untuk ditampilkan dalam detail
|
||||||
border: `2px solid ${AccentColor.blue}`,
|
map
|
||||||
backgroundColor: AccentColor.darkblue,
|
</Text>
|
||||||
padding: "10px",
|
</Stack>
|
||||||
borderRadius: "10px",
|
)}
|
||||||
}}
|
</ComponentGlobal_BoxUploadImage>
|
||||||
>
|
|
||||||
<Box
|
|
||||||
h={250}
|
|
||||||
w={200}
|
|
||||||
style={{
|
|
||||||
color: "white",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Stack spacing={5} justify="center" align="center" h={"100%"}>
|
|
||||||
<Title order={3}>Foto Lokasi Bisnis</Title>
|
|
||||||
<Text fs={"italic"} fz={10} align="center">
|
|
||||||
Upload foto lokasi bisnis anda untuk ditampilkan dalam
|
|
||||||
detail map
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</Box>
|
|
||||||
</Paper>
|
|
||||||
</AspectRatio>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Center>
|
<Center>
|
||||||
<FileButton
|
<FileButton
|
||||||
@@ -202,7 +173,7 @@ export function UiMap_CreatePin({
|
|||||||
</Center>
|
</Center>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<ButtonSavePin
|
<ComponentMap_ButtonSavePin
|
||||||
namePin={namePin}
|
namePin={namePin}
|
||||||
lat={lat as any}
|
lat={lat as any}
|
||||||
long={long as any}
|
long={long as any}
|
||||||
@@ -213,47 +184,3 @@ export function UiMap_CreatePin({
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ButtonSavePin({
|
|
||||||
namePin,
|
|
||||||
lat,
|
|
||||||
long,
|
|
||||||
portofolioId,
|
|
||||||
file,
|
|
||||||
}: {
|
|
||||||
namePin: string;
|
|
||||||
lat: string;
|
|
||||||
long: string;
|
|
||||||
portofolioId: string;
|
|
||||||
file: FormData;
|
|
||||||
}) {
|
|
||||||
const router = useRouter();
|
|
||||||
async function onSavePin() {
|
|
||||||
const gambar = new FormData();
|
|
||||||
gambar.append("file", file as any);
|
|
||||||
|
|
||||||
const res = await map_funCreatePin({
|
|
||||||
data: { namePin, lat, long, portofolioId, gambar },
|
|
||||||
});
|
|
||||||
res.status === 200
|
|
||||||
? (ComponentGlobal_NotifikasiBerhasil(res.message), router.back())
|
|
||||||
: ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Button
|
|
||||||
mt={"xl"}
|
|
||||||
style={{ transition: "0.5s" }}
|
|
||||||
disabled={namePin === "" || file === null ? true : false}
|
|
||||||
radius={"xl"}
|
|
||||||
bg={MainColor.yellow}
|
|
||||||
color="yellow"
|
|
||||||
c={"black"}
|
|
||||||
onClick={() => onSavePin()}
|
|
||||||
>
|
|
||||||
Simpan
|
|
||||||
</Button>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -11,13 +11,7 @@ import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empt
|
|||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||||
import {
|
import { Avatar, Button, Center, FileButton, Stack } from "@mantine/core";
|
||||||
Avatar,
|
|
||||||
Button,
|
|
||||||
Center,
|
|
||||||
FileButton,
|
|
||||||
Stack
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { IconCamera } from "@tabler/icons-react";
|
import { IconCamera } from "@tabler/icons-react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -31,6 +25,8 @@ import {
|
|||||||
import { map_funCustomPinMap } from "../fun";
|
import { map_funCustomPinMap } from "../fun";
|
||||||
import { defaultMapZoom } from "../lib/default_lat_long";
|
import { defaultMapZoom } from "../lib/default_lat_long";
|
||||||
import { MODEL_MAP } from "../lib/interface";
|
import { MODEL_MAP } from "../lib/interface";
|
||||||
|
import { APIs, DIRECTORY_ID } from "@/app/lib";
|
||||||
|
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
||||||
|
|
||||||
export function UiMap_CustomPin({
|
export function UiMap_CustomPin({
|
||||||
dataMap,
|
dataMap,
|
||||||
@@ -62,7 +58,7 @@ export function UiMap_CustomPin({
|
|||||||
<Avatar
|
<Avatar
|
||||||
size={200}
|
size={200}
|
||||||
radius={"100%"}
|
radius={"100%"}
|
||||||
src={imgPin ? imgPin : "/aset/no-img.png"}
|
src={imgPin ? imgPin : "/aset/global/no-image.svg"}
|
||||||
style={{
|
style={{
|
||||||
border: `2px solid ${AccentColor.skyblue}`,
|
border: `2px solid ${AccentColor.skyblue}`,
|
||||||
backgroundColor: AccentColor.darkblue,
|
backgroundColor: AccentColor.darkblue,
|
||||||
@@ -75,9 +71,9 @@ export function UiMap_CustomPin({
|
|||||||
size={200}
|
size={200}
|
||||||
radius={"100%"}
|
radius={"100%"}
|
||||||
src={
|
src={
|
||||||
data.imagePinId === null
|
data.pinId === null
|
||||||
? RouterPortofolio.api_logo_porto + data.Portofolio.logoId
|
? APIs.GET + data.Portofolio.logoId
|
||||||
: RouterMap.api_custom_pin + data.imagePinId
|
: APIs.GET + data.pinId
|
||||||
}
|
}
|
||||||
style={{
|
style={{
|
||||||
border: `2px solid ${AccentColor.skyblue}`,
|
border: `2px solid ${AccentColor.skyblue}`,
|
||||||
@@ -158,9 +154,9 @@ export function UiMap_CustomPin({
|
|||||||
src={
|
src={
|
||||||
imgPin
|
imgPin
|
||||||
? imgPin
|
? imgPin
|
||||||
: data.imagePinId === null
|
: data.pinId === null
|
||||||
? RouterPortofolio.api_logo_porto + data.Portofolio.logoId
|
? APIs.GET + data.Portofolio.logoId
|
||||||
: RouterMap.api_custom_pin + data.imagePinId
|
: APIs.GET + data.pinId
|
||||||
}
|
}
|
||||||
style={{
|
style={{
|
||||||
border: `2px solid ${AccentColor.softblue}`,
|
border: `2px solid ${AccentColor.softblue}`,
|
||||||
@@ -180,23 +176,27 @@ export function UiMap_CustomPin({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ButtonSimpan({
|
function ButtonSimpan({ mapId, filePin }: { mapId: string; filePin: File }) {
|
||||||
mapId,
|
|
||||||
filePin,
|
|
||||||
}: {
|
|
||||||
mapId: string;
|
|
||||||
filePin: FormData;
|
|
||||||
}) {
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isLoading, setLoading] = useState(false);
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
async function onCustom() {
|
async function onCustom() {
|
||||||
const file = new FormData();
|
const uploadFileToStorage = await funGlobal_UploadToStorage({
|
||||||
file.append("file", filePin as any);
|
file: filePin,
|
||||||
|
dirId: DIRECTORY_ID.map_pin,
|
||||||
|
});
|
||||||
|
|
||||||
const res = await map_funCustomPinMap({ mapId: mapId, file: file });
|
if (!uploadFileToStorage.success)
|
||||||
|
return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
|
||||||
|
|
||||||
|
const res = await map_funCustomPinMap({
|
||||||
|
mapId: mapId,
|
||||||
|
fileId: uploadFileToStorage.data.id,
|
||||||
|
});
|
||||||
res.status === 200
|
res.status === 200
|
||||||
? (ComponentGlobal_NotifikasiBerhasil(res.message), router.back())
|
? (ComponentGlobal_NotifikasiBerhasil(res.message),
|
||||||
|
setLoading(true),
|
||||||
|
router.back())
|
||||||
: ComponentGlobal_NotifikasiGagal(res.message);
|
: ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ import {
|
|||||||
Image,
|
Image,
|
||||||
Paper,
|
Paper,
|
||||||
Stack,
|
Stack,
|
||||||
|
Text,
|
||||||
TextInput,
|
TextInput,
|
||||||
|
Title,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { IconCamera } from "@tabler/icons-react";
|
import { IconCamera } from "@tabler/icons-react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
@@ -33,6 +35,9 @@ import Map, {
|
|||||||
import { map_funEditMap } from "../fun/edit/fun_edit_map";
|
import { map_funEditMap } from "../fun/edit/fun_edit_map";
|
||||||
import { defaultMapZoom } from "../lib/default_lat_long";
|
import { defaultMapZoom } from "../lib/default_lat_long";
|
||||||
import { MODEL_MAP } from "../lib/interface";
|
import { MODEL_MAP } from "../lib/interface";
|
||||||
|
import { APIs } from "@/app/lib";
|
||||||
|
import { ComponentGlobal_BoxUploadImage, ComponentGlobal_LoadImage } from "@/app_modules/_global/component";
|
||||||
|
import { ComponentMap_ButtonUpdateDataMap } from "../_component";
|
||||||
|
|
||||||
export function UiMap_EditMap({
|
export function UiMap_EditMap({
|
||||||
mapboxToken,
|
mapboxToken,
|
||||||
@@ -84,9 +89,9 @@ export function UiMap_EditMap({
|
|||||||
>
|
>
|
||||||
<Avatar
|
<Avatar
|
||||||
src={
|
src={
|
||||||
data.ImagePin === null
|
data.pinId === null
|
||||||
? RouterPortofolio.api_logo_porto + dataMap.Portofolio.logoId
|
? APIs.GET + dataMap.Portofolio.logoId
|
||||||
: RouterMap.api_custom_pin + data.imagePinId
|
: APIs.GET + data.pinId
|
||||||
}
|
}
|
||||||
alt="Logo"
|
alt="Logo"
|
||||||
style={{
|
style={{
|
||||||
@@ -127,11 +132,29 @@ export function UiMap_EditMap({
|
|||||||
/>
|
/>
|
||||||
</Paper>
|
</Paper>
|
||||||
|
|
||||||
{/* Foto Usaha */}
|
{/* Photo Usaha */}
|
||||||
<Stack spacing={"xs"}>
|
<Stack spacing={"xs"}>
|
||||||
<ComponentGlobal_BoxInformation informasi="Masukan foto toko atau tempat usaha anda !" />
|
<ComponentGlobal_BoxInformation informasi="Masukan photo toko atau tempat usaha anda !" />
|
||||||
|
|
||||||
{img ? (
|
<ComponentGlobal_BoxUploadImage>
|
||||||
|
{img ? (
|
||||||
|
<AspectRatio ratio={1 / 1} mah={265} mx={"auto"}>
|
||||||
|
<Image
|
||||||
|
style={{ maxHeight: 250, margin: "auto", padding: "5px" }}
|
||||||
|
alt="Photo"
|
||||||
|
height={250}
|
||||||
|
src={img}
|
||||||
|
/>
|
||||||
|
</AspectRatio>
|
||||||
|
) : (
|
||||||
|
<ComponentGlobal_LoadImage
|
||||||
|
|
||||||
|
url={APIs.GET + data.imageId}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</ComponentGlobal_BoxUploadImage>
|
||||||
|
|
||||||
|
{/* {img ? (
|
||||||
<AspectRatio ratio={1 / 1} mah={300}>
|
<AspectRatio ratio={1 / 1} mah={300}>
|
||||||
<Paper
|
<Paper
|
||||||
style={{
|
style={{
|
||||||
@@ -143,7 +166,7 @@ export function UiMap_EditMap({
|
|||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
radius={"sm"}
|
radius={"sm"}
|
||||||
alt="Foto"
|
alt="Photo"
|
||||||
src={img ? img : "/aset/no-img.png"}
|
src={img ? img : "/aset/no-img.png"}
|
||||||
maw={250}
|
maw={250}
|
||||||
/>
|
/>
|
||||||
@@ -161,13 +184,13 @@ export function UiMap_EditMap({
|
|||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
radius={"sm"}
|
radius={"sm"}
|
||||||
alt="Foto"
|
alt="Photo"
|
||||||
src={RouterMap.api_foto + data.imageMapId}
|
src={RouterMap.api_foto + data.imageId}
|
||||||
maw={250}
|
maw={250}
|
||||||
/>
|
/>
|
||||||
</Paper>
|
</Paper>
|
||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
)}
|
)} */}
|
||||||
|
|
||||||
<Center>
|
<Center>
|
||||||
<FileButton
|
<FileButton
|
||||||
@@ -207,41 +230,10 @@ export function UiMap_EditMap({
|
|||||||
</Center>
|
</Center>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<ButtonSavePin data={data as any} file={file} />
|
<ComponentMap_ButtonUpdateDataMap data={data as any} file={file} />
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ButtonSavePin({ data, file }: { data: MODEL_MAP; file: FormData }) {
|
|
||||||
const router = useRouter();
|
|
||||||
async function onSavePin() {
|
|
||||||
const gambar = new FormData();
|
|
||||||
gambar.append("file", file as any);
|
|
||||||
|
|
||||||
const res = await map_funEditMap({
|
|
||||||
data: data,
|
|
||||||
file: gambar,
|
|
||||||
});
|
|
||||||
res.status === 200
|
|
||||||
? (ComponentGlobal_NotifikasiBerhasil(res.message), router.back())
|
|
||||||
: ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Button
|
|
||||||
mb={"xl"}
|
|
||||||
style={{ transition: "0.5s" }}
|
|
||||||
disabled={data.namePin === "" ? true : false}
|
|
||||||
radius={"xl"}
|
|
||||||
bg={MainColor.yellow}
|
|
||||||
color="yellow"
|
|
||||||
c={"black"}
|
|
||||||
onClick={() => onSavePin()}
|
|
||||||
>
|
|
||||||
Simpan
|
|
||||||
</Button>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { RouterPortofolio } from "@/app/lib/router_hipmi/router_katalog";
|
import { APIs } from "@/app/lib";
|
||||||
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
|
||||||
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
|
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
|
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||||
import { Avatar, Stack } from "@mantine/core";
|
import { Avatar, Stack } from "@mantine/core";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import "mapbox-gl/dist/mapbox-gl.css";
|
import "mapbox-gl/dist/mapbox-gl.css";
|
||||||
@@ -18,7 +18,6 @@ import { ComponentMap_DetailData } from "../_component/detail_data";
|
|||||||
import { map_funGetAllMap } from "../fun/get/fun_get_all_map";
|
import { map_funGetAllMap } from "../fun/get/fun_get_all_map";
|
||||||
import { defaultLatLong, defaultMapZoom } from "../lib/default_lat_long";
|
import { defaultLatLong, defaultMapZoom } from "../lib/default_lat_long";
|
||||||
import { MODEL_MAP } from "../lib/interface";
|
import { MODEL_MAP } from "../lib/interface";
|
||||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
|
||||||
|
|
||||||
export function UiMap_MapBoxView({
|
export function UiMap_MapBoxView({
|
||||||
mapboxToken,
|
mapboxToken,
|
||||||
@@ -91,9 +90,9 @@ export function UiMap_MapBoxView({
|
|||||||
backgroundColor: "white",
|
backgroundColor: "white",
|
||||||
}}
|
}}
|
||||||
src={
|
src={
|
||||||
e.imagePinId === null
|
e.pinId === null
|
||||||
? RouterPortofolio.api_logo_porto + e.Portofolio.logoId
|
? APIs.GET + e.Portofolio.logoId
|
||||||
: RouterMap.api_custom_pin + e.imagePinId
|
: APIs.GET + e.pinId
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
export const pages = {
|
export const pages = {
|
||||||
"/": "/",
|
"/": "/",
|
||||||
"/zCoba": "/zCoba",
|
"/zCoba": "/zCoba",
|
||||||
|
|||||||
Reference in New Issue
Block a user