"use client"; import { RouterPortofolio } from "@/app/lib/router_hipmi/router_katalog"; import { RouterMap } from "@/app/lib/router_hipmi/router_map"; import { AccentColor, MainColor, } from "@/app_modules/_global/color/color_pallet"; import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information"; import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data"; import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil"; import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal"; import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan"; import { Avatar, Button, Center, FileButton, Stack } from "@mantine/core"; import { IconCamera } from "@tabler/icons-react"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { AttributionControl, Map, Marker, NavigationControl, ScaleControl, } from "react-map-gl"; import { map_funCustomPinMap } from "../fun"; import { defaultMapZoom } from "../lib/default_lat_long"; import { MODEL_MAP } from "../lib/interface"; import { APIs, DIRECTORY_ID } from "@/app/lib"; import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun"; import { MAX_SIZE } from "@/app_modules/_global/lib"; import { PemberitahuanMaksimalFile } from "@/app_modules/_global/lib/max_size"; export function UiMap_CustomPin({ dataMap, mapboxToken, }: { dataMap: MODEL_MAP; mapboxToken: string; }) { const [data, setData] = useState(dataMap); const [filePin, setFilePin] = useState(null); const [imgPin, setImgPin] = useState(null); if (!mapboxToken) return ; return ( <> {/* Logo Custom */} {imgPin ? (
) : (
)}
{ try { const buffer = URL.createObjectURL( new Blob([new Uint8Array(await files.arrayBuffer())]) ); if (files.size > MAX_SIZE) { ComponentGlobal_NotifikasiPeringatan( PemberitahuanMaksimalFile, 3000 ); } else { setImgPin(buffer); setFilePin(files); } } catch (error) { console.log(error); } }} accept="image/png,image/jpeg" > {(props) => ( )}
{/* Map */}
); } function ButtonSimpan({ mapId, filePin }: { mapId: string; filePin: File }) { const router = useRouter(); const [isLoading, setLoading] = useState(false); async function onCustom() { const uploadFileToStorage = await funGlobal_UploadToStorage({ file: filePin, dirId: DIRECTORY_ID.map_pin, }); if (!uploadFileToStorage.success) return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar"); const res = await map_funCustomPinMap({ mapId: mapId, fileId: uploadFileToStorage.data.id, }); res.status === 200 ? (ComponentGlobal_NotifikasiBerhasil(res.message), setLoading(true), router.back()) : ComponentGlobal_NotifikasiGagal(res.message); } return ( <> ); }