# fix
## Deskripsi: - Perubahan tampilan notifikasi - Pin map sesuai logo - Pin map bisa custom ### No Issue
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
export { UiMap_MapBoxView } from "./ui_map";
|
||||
export { UiMap_SplashView } from "./ui_splash";
|
||||
export { UiMap_CreatePin } from "./ui_create_pin"
|
||||
export { UiMap_EditPin } from "./ui_edit_pin"
|
||||
export { UiMap_CreatePin } from "./ui_create_pin";
|
||||
export { UiMap_EditMap as UiMap_EditPin } from "./ui_edit_map";
|
||||
export { UiMap_CustomPin } from "./ui_custom_pin";
|
||||
|
||||
224
src/app_modules/map/ui/ui_custom_pin.tsx
Normal file
224
src/app_modules/map/ui/ui_custom_pin.tsx
Normal file
@@ -0,0 +1,224 @@
|
||||
"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";
|
||||
|
||||
export function UiMap_CustomPin({
|
||||
dataMap,
|
||||
mapboxToken,
|
||||
}: {
|
||||
dataMap: MODEL_MAP;
|
||||
mapboxToken: string;
|
||||
}) {
|
||||
const [data, setData] = useState(dataMap);
|
||||
const [filePin, setFilePin] = useState<File | any>(null);
|
||||
const [imgPin, setImgPin] = useState<any | null>(null);
|
||||
|
||||
if (!mapboxToken)
|
||||
return <ComponentGlobal_IsEmptyData text="Mapbox token not found" />;
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Logo Custom */}
|
||||
<Stack spacing={50} px={"sm"} mb={"md"}>
|
||||
<Stack>
|
||||
<ComponentGlobal_BoxInformation
|
||||
informasi={
|
||||
"Pin map akan secara otomatis menampilkan logo pada porotofolio ini, jika anda ingin melakukan custom silahkan upload logo pin baru anda !"
|
||||
}
|
||||
/>
|
||||
|
||||
{imgPin ? (
|
||||
<Center>
|
||||
<Avatar
|
||||
size={200}
|
||||
radius={"100%"}
|
||||
src={imgPin ? imgPin : "/aset/no-img.png"}
|
||||
style={{
|
||||
border: `2px solid ${AccentColor.skyblue}`,
|
||||
backgroundColor: AccentColor.darkblue,
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
) : (
|
||||
<Center>
|
||||
<Avatar
|
||||
size={200}
|
||||
radius={"100%"}
|
||||
src={
|
||||
data.imagePinId === null
|
||||
? RouterPortofolio.api_logo_porto + data.Portofolio.logoId
|
||||
: RouterMap.api_custom_pin + data.imagePinId
|
||||
}
|
||||
style={{
|
||||
border: `2px solid ${AccentColor.skyblue}`,
|
||||
backgroundColor: AccentColor.darkblue,
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
)}
|
||||
|
||||
<Center>
|
||||
<FileButton
|
||||
onChange={async (files: any | null) => {
|
||||
try {
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
if (files.size > 2000000) {
|
||||
ComponentGlobal_NotifikasiPeringatan(
|
||||
"Maaf, Ukuran file terlalu besar, maximum 2mb",
|
||||
3000
|
||||
);
|
||||
} else {
|
||||
setImgPin(buffer);
|
||||
setFilePin(files);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}}
|
||||
accept="image/png,image/jpeg"
|
||||
>
|
||||
{(props) => (
|
||||
<Button
|
||||
{...props}
|
||||
radius={"xl"}
|
||||
leftIcon={<IconCamera />}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
c={"black"}
|
||||
>
|
||||
Upload
|
||||
</Button>
|
||||
)}
|
||||
</FileButton>
|
||||
</Center>
|
||||
</Stack>
|
||||
|
||||
{/* Map */}
|
||||
<Map
|
||||
mapboxAccessToken={mapboxToken}
|
||||
mapStyle={"mapbox://styles/mapbox/streets-v11"}
|
||||
initialViewState={{
|
||||
latitude: data.latitude,
|
||||
longitude: data.longitude,
|
||||
zoom: defaultMapZoom,
|
||||
}}
|
||||
style={{
|
||||
cursor: "pointer",
|
||||
width: "100%",
|
||||
height: "30vh",
|
||||
borderRadius: "10px",
|
||||
}}
|
||||
attributionControl={false}
|
||||
>
|
||||
<Marker
|
||||
style={{
|
||||
color: "red",
|
||||
width: 40,
|
||||
// height: 40,
|
||||
cursor: "pointer",
|
||||
}}
|
||||
latitude={data.latitude}
|
||||
longitude={data.longitude}
|
||||
anchor="bottom"
|
||||
>
|
||||
<Avatar
|
||||
alt="Logo"
|
||||
src={
|
||||
imgPin
|
||||
? imgPin
|
||||
: data.imagePinId === null
|
||||
? RouterPortofolio.api_logo_porto + data.Portofolio.logoId
|
||||
: RouterMap.api_custom_pin + data.imagePinId
|
||||
}
|
||||
style={{
|
||||
border: `2px solid ${AccentColor.softblue}`,
|
||||
backgroundColor: "white",
|
||||
borderRadius: "100%",
|
||||
}}
|
||||
/>
|
||||
</Marker>
|
||||
<NavigationControl />
|
||||
<ScaleControl position="top-left" />
|
||||
<AttributionControl customAttribution="Map design by PT. Bali Interaktif Perkasa" />
|
||||
</Map>
|
||||
|
||||
<ButtonSimpan mapId={data.id} filePin={filePin} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonSimpan({
|
||||
mapId,
|
||||
filePin,
|
||||
}: {
|
||||
mapId: string;
|
||||
filePin: FormData;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
|
||||
async function onCustom() {
|
||||
const file = new FormData();
|
||||
file.append("file", filePin as any);
|
||||
|
||||
const res = await map_funCustomPinMap({ mapId: mapId, file: file });
|
||||
res.status === 200
|
||||
? (ComponentGlobal_NotifikasiBerhasil(res.message), router.back())
|
||||
: ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
disabled={filePin == null}
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
radius={"xl"}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
c={"black"}
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
}}
|
||||
onClick={() => {
|
||||
onCustom();
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,27 +1,27 @@
|
||||
"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_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 {
|
||||
AspectRatio,
|
||||
Box,
|
||||
Avatar,
|
||||
Button,
|
||||
Center,
|
||||
FileButton,
|
||||
Image,
|
||||
Paper,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { IconCamera } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import Map, {
|
||||
@@ -30,13 +30,11 @@ import Map, {
|
||||
NavigationControl,
|
||||
ScaleControl,
|
||||
} from "react-map-gl";
|
||||
import { map_funCreatePin } from "../fun/create/fun_create_pin";
|
||||
import { defaultLatLong, defaultMapZoom } from "../lib/default_lat_long";
|
||||
import { MODEL_MAP } from "../lib/interface";
|
||||
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
||||
import { map_funEditMap } from "../fun/edit/fun_edit_map";
|
||||
import { defaultMapZoom } from "../lib/default_lat_long";
|
||||
import { MODEL_MAP } from "../lib/interface";
|
||||
|
||||
export function UiMap_EditPin({
|
||||
export function UiMap_EditMap({
|
||||
mapboxToken,
|
||||
dataMap,
|
||||
}: {
|
||||
@@ -47,10 +45,9 @@ export function UiMap_EditPin({
|
||||
const [file, setFile] = useState<File | any>(null);
|
||||
const [img, setImg] = useState<any | null>(null);
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<Stack spacing={30} px={"sm"}>
|
||||
<Map
|
||||
mapboxAccessToken={mapboxToken}
|
||||
mapStyle={"mapbox://styles/mapbox/streets-v11"}
|
||||
@@ -85,13 +82,20 @@ export function UiMap_EditPin({
|
||||
longitude={data.longitude}
|
||||
anchor="bottom"
|
||||
>
|
||||
<Stack spacing={0}>
|
||||
<Image
|
||||
w={"100%"}
|
||||
alt="image"
|
||||
src="https://cdn-icons-png.flaticon.com/512/5860/5860579.png"
|
||||
/>
|
||||
</Stack>
|
||||
<Avatar
|
||||
src={
|
||||
data.ImagePin === null
|
||||
? RouterPortofolio.api_logo_porto + dataMap.Portofolio.logoId
|
||||
: RouterMap.api_custom_pin + data.imagePinId
|
||||
}
|
||||
alt="Logo"
|
||||
style={{
|
||||
border: `2px solid ${AccentColor.softblue}`,
|
||||
backgroundColor: "white",
|
||||
|
||||
borderRadius: "100%",
|
||||
}}
|
||||
/>
|
||||
</Marker>
|
||||
<NavigationControl />
|
||||
<ScaleControl position="top-left" />
|
||||
@@ -123,7 +127,10 @@ export function UiMap_EditPin({
|
||||
/>
|
||||
</Paper>
|
||||
|
||||
<Stack>
|
||||
{/* Foto Usaha */}
|
||||
<Stack spacing={"xs"}>
|
||||
<ComponentGlobal_BoxInformation informasi="Masukan foto toko atau tempat usaha anda !" />
|
||||
|
||||
{img ? (
|
||||
<AspectRatio ratio={1 / 1} mah={300}>
|
||||
<Paper
|
||||
@@ -155,7 +162,7 @@ export function UiMap_EditPin({
|
||||
<Image
|
||||
radius={"sm"}
|
||||
alt="Foto"
|
||||
src={RouterMap.api_foto + data.imagesId}
|
||||
src={RouterMap.api_foto + data.imageMapId}
|
||||
maw={250}
|
||||
/>
|
||||
</Paper>
|
||||
@@ -214,8 +221,7 @@ function ButtonSavePin({ data, file }: { data: MODEL_MAP; file: FormData }) {
|
||||
|
||||
const res = await map_funEditMap({
|
||||
data: data,
|
||||
file: gambar
|
||||
|
||||
file: gambar,
|
||||
});
|
||||
res.status === 200
|
||||
? (ComponentGlobal_NotifikasiBerhasil(res.message), router.back())
|
||||
@@ -225,7 +231,7 @@ function ButtonSavePin({ data, file }: { data: MODEL_MAP; file: FormData }) {
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
mt={"xl"}
|
||||
mb={"xl"}
|
||||
style={{ transition: "0.5s" }}
|
||||
disabled={data.namePin === "" ? true : false}
|
||||
radius={"xl"}
|
||||
@@ -1,6 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import { Image, Stack, Text } from "@mantine/core";
|
||||
import { RouterPortofolio } from "@/app/lib/router_hipmi/router_katalog";
|
||||
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
||||
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { Avatar, Stack } from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import "mapbox-gl/dist/mapbox-gl.css";
|
||||
import { useState } from "react";
|
||||
@@ -8,13 +11,14 @@ import Map, {
|
||||
AttributionControl,
|
||||
Marker,
|
||||
NavigationControl,
|
||||
ScaleControl
|
||||
ScaleControl,
|
||||
} from "react-map-gl";
|
||||
import { ComponentMap_DrawerDetailData } from "../_component";
|
||||
import { ComponentMap_DetailData } from "../_component/detail_data";
|
||||
import { map_funGetAllMap } from "../fun/get/fun_get_all_map";
|
||||
import { defaultLatLong, defaultMapZoom } from "../lib/default_lat_long";
|
||||
import { MODEL_MAP } from "../lib/interface";
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
|
||||
export function UiMap_MapBoxView({
|
||||
mapboxToken,
|
||||
@@ -36,6 +40,9 @@ export function UiMap_MapBoxView({
|
||||
setData(loadData as any);
|
||||
}
|
||||
|
||||
if (!mapboxToken)
|
||||
return <ComponentGlobal_IsEmptyData text="Mapbox token not found" />;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack style={{ borderRadius: "10px" }}>
|
||||
@@ -76,25 +83,19 @@ export function UiMap_MapBoxView({
|
||||
setOpenDrawer(true);
|
||||
}}
|
||||
>
|
||||
<Image
|
||||
w={"100%"}
|
||||
alt="image"
|
||||
src="https://cdn-icons-png.flaticon.com/512/5860/5860579.png"
|
||||
/>
|
||||
<Text
|
||||
fz={"xs"}
|
||||
bg={"dark"}
|
||||
c={"white"}
|
||||
align="center"
|
||||
<Avatar
|
||||
alt="Logo"
|
||||
style={{
|
||||
borderRadius: "5px",
|
||||
padding: "5px",
|
||||
width: 50,
|
||||
border: `2px solid ${AccentColor.softblue}`,
|
||||
borderRadius: "100%",
|
||||
backgroundColor: "white",
|
||||
}}
|
||||
lineClamp={2}
|
||||
>
|
||||
{e.namePin}
|
||||
</Text>
|
||||
src={
|
||||
e.imagePinId === null
|
||||
? RouterPortofolio.api_logo_porto + e.Portofolio.logoId
|
||||
: RouterMap.api_custom_pin + e.imagePinId
|
||||
}
|
||||
/>
|
||||
</Stack>
|
||||
</Marker>
|
||||
</Stack>
|
||||
|
||||
Reference in New Issue
Block a user